# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47528 | ngkan146 | Crazy old lady (IZhO13_crazy) | C++11 | 46 ms | 1236 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 test, n, a[1005];
int main(){
scanf("%d",&test);
while(test--){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
vector <int> ans;
for(int oldLady=1;oldLady<=n;oldLady++){
vector <int> peopleId;
peopleId.push_back(-1);
peopleId.push_back(oldLady);
for(int i=1;i<=n;i++) if (i != oldLady) peopleId.push_back(i);
//cerr << oldLady << endl;
int curSeat = a[1];
bool ok = 1;
for(int i=2;i<=n;i++){
//cerr << i << ' ' << curSeat << endl;
if (peopleId[i] == curSeat){
curSeat = a[i];
}
else{
if (a[i] != peopleId[i]){
ok = 0;
break;
}
}
}
if (ok) ans.push_back(oldLady);
}
assert(ans.size());
if (ans.size() > 1) cout << 0 << '\n';
else cout << ans[0] << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |