Submission #958562

# Submission time Handle Problem Language Result Execution time Memory
958562 2024-04-06T03:59:10 Z adaawf Crazy old lady (IZhO13_crazy) C++14
100 / 100
7 ms 456 KB
#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
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 440 KB Output is correct
8 Correct 1 ms 352 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 356 KB Output is correct
12 Correct 2 ms 352 KB Output is correct
13 Correct 2 ms 456 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 4 ms 352 KB Output is correct
16 Correct 5 ms 352 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 6 ms 348 KB Output is correct
19 Correct 5 ms 356 KB Output is correct
20 Correct 7 ms 348 KB Output is correct