"Topic link": Click here~~
"To the effect of the topic":
Give a n*n matrix, 1 only on the diagonal (because you can't hit yourself), 0 for no car in collision, 1 for the first car (horizontal axis) was crashed, 2 for the first J car (ordinate) was crashed, 3 for two cars have crashed. Ask which cars are intact.
Code:
/ * * problem:codeforces-545a * Running time:15ms * complier:g++ * Author:herongwei * Create time: 7: 47 2015/9/17 Thursday * Count the number of 1 and 3 per line, and if either one of them, the car means it's broken. */ #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm>using namespace std;typedef long long ll;const int N=1e5+100;const int inf= 0x7f7f7f7f;bool Ok[n];int Main () { int t,n,m; memset (ok,false,sizeof (OK)); scanf ("%d", &t); for (int i=1, i<=t; ++i) {for (int j=1; j<=t; ++j) { int x; scanf ("%d", &x); if (x==1| | x==3) ok[i]=true; } } int ans=0; for (int i=1; i<=t; ++i) { if (!ok[i]) ans++; } printf ("%d\n", ans); for (int i=1; i<=t; ++i) { if (!ok[i]) printf ("%d", I); } if (ans) puts (""); return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
codeforces-545a Toy Cars (analogue)