首页 > 其他分享 >牛客小白月赛86(真小白)

牛客小白月赛86(真小白)

时间:2024-01-20 12:45:02浏览次数:20  
标签:maxx maxy miny 真小白 ++ minx 牛客 int 86

A.水盐平衡

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
    
void solve() {
    int a, b, c, d; cin >> a >> b >> c >> d;

    if (a * d < c * b) cout << "Y\n";
    else cout << "S\n";
}

int main()
{
    IO;
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

 

B.水平考试

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
    
void solve() {
    string a, b; cin >> a >> b;
    for (auto& x : a) {
        if (!count(b.begin(), b.end(), x)) {
            cout << "0\n";
            return ;
        }
    }
    cout << "10\n";
}

int main()
{
    IO;
    int t; cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

  

 

D

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1005;

char arr[N][N];
int n, m, cnt, maxx, maxy, minx, miny;
int dirs[][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

bool isVild(int x, int y) {
    if (x >= 0 && x < n && y >= 0 && y < m && arr[x][y] == '.') {
        return true;
    }
    return false;
}

void dfs(int x, int y) {
    arr[x][y] = '*';
    cnt ++;
    maxx = max(maxx, x), maxy = max(maxy, y);
    minx = min(minx, x), miny = min(miny, y);

    for (int i = 0; i < 4; i++) {
        int dx = dirs[i][0] + x;
        int dy = dirs[i][1] + y;
        if (isVild(dx, dy)) {
            dfs(dx, dy);
        }
    }
}

bool check(int maxx, int maxy, int minx, int miny, int cnt) {
    return (maxx - minx + 1) * (maxy - miny + 1) == cnt;
}
int main()
{
    IO;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) cin >> arr[i][j];
    }

    int ans = 0; 

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (arr[i][j] == '.') {
                cnt = 0, maxx = maxy = 0, minx = miny = N;
                dfs(i, j);
                if (check(maxx, maxy, minx, miny, cnt)) ans ++;
            }
        }
    }
    return cout << ans << '\n', 0;
}

  

标签:maxx,maxy,miny,真小白,++,minx,牛客,int,86
From: https://www.cnblogs.com/youhualiuh/p/17976334

相关文章

  • 题解 [ABC186F] Rook on Grid
    【洛谷博客】有一点难度,但不多。题意一个\(H\timesW\)的地图上有\(M\)个障碍物。有一辆车在\((1,1)\),一次行动可以向下或向右移动任意格(不得穿过障碍物)。求这辆车在最多两次行动中可能到达多少个格子。分析车有四种选择:向右、向下、先向右再向下、先向下再向右。然......
  • 题解 [ABC186E] Throne
    【洛谷博客】同余方程板子题,没过的可以先去看看。题意翻译给的很清楚。分析看到这个转圈圈的就很容易想到同余方程。为了方便处理,我们就将编号全部减\(1\),于是编号就变成\(0\simN-1\)。然后就可以很容易的列出同余方程:\[S+Kx\equiv0\pmod{N}\]移项可得:\[Kx\equ......
  • [BZOJ3786] 星系探索 题解
    题目链接:\(BZOJ\)本题通过\(dyf\_DYF\)的题解理解\(ETT\),代码则借鉴\(lcyfrog\)的题解,图片则使用了何太郎的题解。在此笔者感谢这三位神犇。声明变量:\(ls\):左儿子\(rs\):右儿子\(sz\):子树大小\(rk\):对应堆值\(fa\):节点父亲\(sm\):子树权值和\(p\):\(1/-1\)表示第一......
  • 牛科小白月赛86
    A:比较一下两杯盐水浓度大小即可,第一杯盐水浓度较大就输出S,否则输出Yvoidsolve(){doublea,b,c,d;cin>>a>>b>>c>>d;if(a/b>c/d)cout<<'S'<<endl;elsecout<<'Y'<<endl;} B:判断一下原有字符......
  • 洛谷 P9869 [NOIP2023] 三值逻辑 题解
    Solution模拟程序,容易发现每个点最后的取值都是定值或一个点的初始值(可能是该值取反)。最后是定值的点可以确定初始值,最后取值由该点决定的点也可以确定取值。求出这些取值,答案加上取之为U的点的个数。即第\(i\)个点最后的取值是\(to_i\)的初始值,\(sg_i\)表示是否取反,那......
  • 吴师兄学算法day08 贪心 860. 柠檬水找零
    题目:860.柠檬水找零易错点:我写的是ifesle哈哈,第一次还写错了。i==20的时候,5元只找了1张。哈哈哈.应该找3张 我的代码:classSolution:deflemonadeChange(self,bills:List[int])->bool:dic={5:0,10:0,20:0}foriinbills:......
  • /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found问题解决
    有一个go实现的项目代码最近有更新,自己在开发环境上手动构建并运行都没有问题(构建和运行时相同环境,肯定没有问题^_^)。后面通过jenkins构建镜像也没有问题,运行时却报错 之前的版本在jenkins上构建也是成功的,后沟通得知jenkins集群版本最近有更新 那么,大概知道原因了,由于jenk......
  • CF1286C1题解
    Madhouse(Easyversion)题目传送门题解这种水题还能有蓝?不能因为困难版是黑就把简单版难度往上强拉啊!第一次问\([1,n]\),第二次问\([1,n-1]\),把读入的所有字符串先各自内部把字符排序(反正本来就是乱序)后存入map,第一次询问有,第二次询问没有的字符串就是原串后缀的乱序,都找出......
  • P3867题解
    P3867[TJOI2009]排列计数题目传送门题解\(k\)很小,不是分讨就是突破口。如果我们用这种方式生成排列:将\(1\)到\(n\)按顺序插入当前状态,那么你会发现当前的数\(x\)的插入被很大程度的限制住了,我们只需记录当前\(x-k\)到\(x-1\)的位置即可枚举出所有可能的下一状态,因......
  • hey_left 7 Codeforces Round 886 (Div. 4) 续
    题目链接F.记录下出现的数字和个数注意放置陷阱的位置1-n都有可能然后遍历1-n,对每个数进行因子分解,对于在因子的位置上有青蛙的,加上青蛙的个数,取最大即可#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongconstintN=2e5+10;voidsolve(){int......