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);
}
}
}
D
#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;
}