首页 > 其他 > 详细

水题 Codeforces Round #303 (Div. 2) A. Toy Cars

时间:2015-05-21 22:30:18      阅读:177      评论:0      收藏:0      [点我收藏+]

 

题目传送门

 1 /*
 2     题意:5种情况对应对应第i或j辆车翻了没
 3     水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次
 4     3: if both cars turned over during the collision.
 5     是指i,j两辆车,而不是全部
 6 */
 7 #include <cstdio>
 8 #include <algorithm>
 9 #include <cstring>
10 #include <cmath>
11 #include <iostream>
12 using namespace std;
13 
14 const int MAXN = 1e2 + 10;
15 const int INF = 0x3f3f3f3f;
16 int a[MAXN][MAXN];
17 bool vis[MAXN];
18 int ans[MAXN];
19 
20 int main(void)        //Codeforces Round #303 (Div. 2) A. Toy Cars
21 {
22     //freopen ("A.in", "r", stdin);
23 
24     int n;
25     while (scanf ("%d", &n) == 1)
26     {
27         memset (vis, false, sizeof (vis));
28         for (int i=1; i<=n; ++i)
29         {
30             for (int j=1; j<=n; ++j)    scanf ("%d", &a[i][j]);
31         }
32 
33         for (int i=1; i<=n; ++i)
34         {
35             for (int j=i+1; j<=n; ++j)
36             {
37                 if (a[i][j] == 3)
38                 {
39                     vis[i] = vis[j] = true;
40                 }
41                 else if (a[i][j] == 2)    vis[j] = true;
42                 else if (a[i][j] == 1)    vis[i] = true;
43             }
44         }
45 
46         int cnt = 0;
47         for (int i=1; i<=n; ++i)
48         {
49             if (!vis[i])    ans[++cnt] = i;
50         }
51         printf ("%d\n", cnt);
52         for (int i=1; i<=cnt; ++i)    printf ("%d%c", ans[i], (i==cnt) ? \n :  );
53     }
54 
55     return 0;
56 }

 

水题 Codeforces Round #303 (Div. 2) A. Toy Cars

原文:http://www.cnblogs.com/Running-Time/p/4520839.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!