# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1039519 | vjudge1 | Crazy old lady (IZhO13_crazy) | C++17 | 10 ms | 476 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;
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |