Submission #1039519

#TimeUsernameProblemLanguageResultExecution timeMemory
1039519vjudge1Crazy old lady (IZhO13_crazy)C++17
100 / 100
10 ms476 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll maxn = 1007; ll t, n, cnt, sol; ll seats[maxn]; ll visited[maxn]; void solve(){ cnt = 0, sol = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> seats[i], seats[i]--; } for (int k = 0; k < n; k++) { bool pos = true; for (int i = 0; i < n; i++) visited[i] = 0; visited[seats[0]] = 1; int j = 0; for (int i = 0; i < n; i++) { if (i == k) continue; j++; if (visited[i] == 0 && seats[j] != i) { pos = false; break; } visited[seats[j]] = 1; } if (pos) { cnt++; sol = k; } } if (cnt > 1) cout << "0\n"; else cout << sol+1 << '\n'; } int main(){ cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...