# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47528 | 2018-05-05T02:40:59 Z | ngkan146 | Crazy old lady (IZhO13_crazy) | C++11 | 46 ms | 1236 KB |
#include <bits/stdc++.h> using namespace std; int test, n, a[1005]; int main(){ scanf("%d",&test); while(test--){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); vector <int> ans; for(int oldLady=1;oldLady<=n;oldLady++){ vector <int> peopleId; peopleId.push_back(-1); peopleId.push_back(oldLady); for(int i=1;i<=n;i++) if (i != oldLady) peopleId.push_back(i); //cerr << oldLady << endl; int curSeat = a[1]; bool ok = 1; for(int i=2;i<=n;i++){ //cerr << i << ' ' << curSeat << endl; if (peopleId[i] == curSeat){ curSeat = a[i]; } else{ if (a[i] != peopleId[i]){ ok = 0; break; } } } if (ok) ans.push_back(oldLady); } assert(ans.size()); if (ans.size() > 1) cout << 0 << '\n'; else cout << ans[0] << '\n'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 784 KB | Output is correct |
5 | Correct | 2 ms | 904 KB | Output is correct |
6 | Correct | 2 ms | 904 KB | Output is correct |
7 | Correct | 4 ms | 904 KB | Output is correct |
8 | Correct | 6 ms | 904 KB | Output is correct |
9 | Correct | 8 ms | 904 KB | Output is correct |
10 | Correct | 10 ms | 932 KB | Output is correct |
11 | Correct | 11 ms | 968 KB | Output is correct |
12 | Correct | 14 ms | 1112 KB | Output is correct |
13 | Correct | 16 ms | 1112 KB | Output is correct |
14 | Correct | 21 ms | 1168 KB | Output is correct |
15 | Correct | 22 ms | 1168 KB | Output is correct |
16 | Correct | 41 ms | 1168 KB | Output is correct |
17 | Correct | 29 ms | 1168 KB | Output is correct |
18 | Correct | 40 ms | 1168 KB | Output is correct |
19 | Correct | 39 ms | 1196 KB | Output is correct |
20 | Correct | 46 ms | 1236 KB | Output is correct |