# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958562 | adaawf | Crazy old lady (IZhO13_crazy) | C++14 | 7 ms | 456 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int a[1005], dd[1005];
int main() {
int t;
cin >> t;
for (int jj = 0; jj < t; jj++) {
int n, c = 0, res = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int k = 1; k <= n; k++) {
int flag = 0;
for (int i = 1; i <= n; i++) dd[i] = 0;
dd[a[1]] = 1;
int j = 1;
for (int i = 1; i <= n; i++) {
if (i == k) continue;
j++;
if (dd[i] == 0 && a[j] != i) {
flag = 1;
break;
}
dd[a[j]] = 1;
}
if (flag == 0) {
c++;
res = k;
}
}
if (c > 1) cout << 0;
else cout << res;
cout << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |