牛客小白月赛86ABCD

A

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int T=sc.nextInt();
        for(int i=1;i<=T;i++){
            int x1=sc.nextInt(), y1=sc.nextInt();
            int x2= sc.nextInt(),y2= sc.nextInt();
            x1*=y2;
            x2*=y1;
            if(x1<=x2) System.out.println("Y");
            else System.out.println("S");
        }
    }
}

B

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int T=sc.nextInt();
        for(int i=1;i<=T;i++){
            String s= sc.next();
            String f=sc.next();
            int sum=0;
            for(int p=0;p<s.length();p++)
            {
                for(int q=0;q<f.length();q++)
                {
                    if(s.charAt(p)==f.charAt(q))
                    {
                        sum++;
                    }
                }
            }
            if(sum==s.length()) System.out.println("10");
            else System.out.println("0");
        }
    }
}

 C

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n= sc.nextInt();
        int m= sc.nextInt();
        int[] a=new int[n+1];
        int[] sum=new int[n+1];
        for(int i=1;i<=n;i++)
        {
            int x= sc.nextInt();
            a[i]=x;
            if(i==1) sum[i]=1;
            else
            {
                if(a[i]==a[i-1]) sum[i]=sum[i-1];
                else sum[i]=sum[i-1]+1;
            }
        }
        for(int i=1;i<=m;i++)
        {
            int x= sc.nextInt();
            int y=sc.nextInt();
            System.out.println(sum[y]-sum[x]+1);
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=200200,M=2023;
int n,m,ans=0;
char c[M][M];
bool st[M][M];
int dx[]={-1,0,0,1},dy[]={0,1,-1,0};
int dfs(int x,int y)
{
    int x1=x,x2=x,y1=y,y2=y,num=1;
    queue<PII> q;
    q.push({x,y});
    st[x][y]=true;
    while(q.size())
    {
        auto t=q.front();
        q.pop();
        for(int i=0;i<4;i++)
        {
            int xx=t.first+dx[i],yy=t.second+dy[i];
            if(xx<0||xx>=n||yy<0||yy>=m||c[xx][yy]=='*'||st[xx][yy]==true) continue;
            x1=max(x1,xx),x2=min(x2,xx);
            y1=max(y1,yy),y2=min(y2,yy);
            num++;
            st[xx][yy]=true;
            q.push({xx,yy});
        }
    }
    if(num==((x1-x2+1)*(y1-y2+1))) return 1;
    else return 0;
}
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cin>>c[i][j];
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(c[i][j]=='.'&&st[i][j]==false)
                {
                    ans+=dfs(i,j);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Vijurria

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值