CF 370

时间:2023-11-17 08:10:14

A:http://codeforces.com/problemset/problem/370/A

 #include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std; int main()
{
int chess[][];
memset(chess,,sizeof(chess));
for(int i = ; i <= ; i+=)
{
for(int j = ; j <= ; j+=)
chess[i][j] = ;
}
for(int i = ; i <= ; i += )
{
for(int j = ; j <= ; j+=)
chess[i][j] = ;
}
int r1,c1,r2,c2;
int ans1,ans2,ans3;
while(~scanf("%d %d %d %d",&r1,&c1,&r2,&c2))
{
if(r1 == r2 && c1 == c2)
{
printf("0 0 0\n");
continue;
}
if(r1 == r2 || c1 == c2)
ans1 = ;
else ans1 = ; if(chess[r1][c1] == chess[r2][c2])
{
if(abs(r1-r2) == abs(c1-c2))
ans2 = ;
else ans2 = ;
}
else ans2 = ; ans3 = max(abs(r1-r2),abs(c1-c2));
printf("%d %d %d\n",ans1,ans2,ans3);
}
return ;
}

B:http://codeforces.com/problemset/problem/370/B

如果第i个是第j个的子集,第j个输出NO,如果没有任何一个集合是第j个的子集,输出YES

 #include<stdio.h>
#include<string.h>
int main()
{
int a[][];
int cnt[],x,n;
while(~scanf("%d",&n))
{
memset(a,,sizeof(a));
for(int i = ; i < n; i++)
{
scanf("%d",&cnt[i]);
for(int j = ; j < cnt[i]; j++)
{
scanf("%d",&x);
a[i][x]++;
}
} for(int i = ; i < n; i++)
{
int flag = ;
for(int j = ; j < n && flag; j++)
{
if(i == j) continue;
flag = ;
for(int k = ; k <= &&!flag; k++)
{
if(a[j][k] && !a[i][k])
flag = ;
}
}
if(flag)
printf("YES\n");
else printf("NO\n");
}
}
return ;
}