CF 370

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

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<cmath>
 4 #include<algorithm>
 5 using namespace std;
 6 
 7 int main()
 8 {
 9     int chess[10][10];
10     memset(chess,0,sizeof(chess));
11     for(int i = 1; i <= 8; i+=2)
12     {
13         for(int j = 2; j <= 8; j+=2)
14             chess[i][j] = 1;
15     }
16     for(int i = 2; i <= 8; i += 2)
17     {
18         for(int j = 1; j <= 8; j+=2)
19             chess[i][j] = 1;
20     }
21     int r1,c1,r2,c2;
22     int ans1,ans2,ans3;
23     while(~scanf("%d %d %d %d",&r1,&c1,&r2,&c2))
24     {
25         if(r1 == r2 && c1 == c2)
26         {
27             printf("0 0 0\n");
28             continue;
29         }
30         if(r1 == r2 || c1 == c2)
31             ans1 = 1;
32         else ans1 = 2;
33 
34         if(chess[r1][c1] == chess[r2][c2])
35         {
36             if(abs(r1-r2) == abs(c1-c2))
37                 ans2 = 1;
38             else ans2 = 2;
39         }
40         else ans2 = 0;
41 
42         ans3 = max(abs(r1-r2),abs(c1-c2));
43         printf("%d %d %d\n",ans1,ans2,ans3);
44     }
45     return 0;
46 }
View Code

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

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

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     int a[110][110];
 6     int cnt[110],x,n;
 7     while(~scanf("%d",&n))
 8     {
 9         memset(a,0,sizeof(a));
10         for(int i = 0; i < n; i++)
11         {
12             scanf("%d",&cnt[i]);
13             for(int j = 0; j < cnt[i]; j++)
14             {
15                 scanf("%d",&x);
16                 a[i][x]++;
17             }
18         }
19 
20         for(int i = 0; i < n; i++)
21         {
22             int flag = 1;
23             for(int j = 0; j < n && flag; j++)
24             {
25                 if(i == j) continue;
26                 flag = 0;
27                 for(int k = 1; k <= 100&&!flag; k++)
28                 {
29                     if(a[j][k] && !a[i][k])
30                         flag = 1;
31                 }
32             }
33             if(flag)
34                 printf("YES\n");
35             else printf("NO\n");
36         }
37     }
38     return 0;
39 }
View Code

 

 

转载于:https://www.cnblogs.com/LK1994/p/3463692.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值