zoukankan      html  css  js  c++  java
  • 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
    ");
    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
    ",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
    ");
    35             else printf("NO
    ");
    36         }
    37     }
    38     return 0;
    39 }
    View Code
  • 相关阅读:
    洛谷P1070 道路游戏
    洛谷P1556 幸福的路
    洛谷P1457 城堡 The Castle
    洛谷P1298 最接近的分数
    2017-9-13 NOIP模拟赛[xxy]
    洛谷P3405 [USACO16DEC]Cities and States省市
    洛谷P1549 棋盘问题(2)
    洛谷P1578 奶牛浴场
    洛谷P2073 送花
    洛谷P3797 妖梦斩木棒
  • 原文地址:https://www.cnblogs.com/LK1994/p/3463692.html
Copyright © 2011-2022 走看看