# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546230 | sidon | Crazy old lady (IZhO13_crazy) | C++17 | 29 ms | 212 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 <bits/stdc++.h>
using namespace std;
int main() {
int T; cin >> T;
while(T--) {
int N; cin >> N;
int p[N], ans = N; for(int &i : p) cin >> i, --i;
for(int i = N; i--; ) {
bool vis[N] {}, ok = 1;
vis[*p] = 1;
for(int j = 1; j < N; vis[p[j++]] = 1)
if(!vis[j - (j <= i)] && p[j] != j - (j <= i)) ok = 0;
if(ok && ans >= 0)
ans = ans == N ? i : -1;
}
cout << (ans % N) + 1 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |