Submission #1010776

#TimeUsernameProblemLanguageResultExecution timeMemory
1010776ivopavCrazy old lady (IZhO13_crazy)C++17
100 / 100
10 ms600 KiB
#include <bits/stdc++.h> using namespace std; void prim(){ int n; cin >> n; vector<int> lis={0}; for (int i=0;i<n;i++){ int unos; cin >> unos; lis.push_back(unos); } vector<int> rje={}; for (int i=1;i<=n;i++){ bool dob=1; vector<bool> bio(n,0); bio[lis[1]]=1; for (int j=1;j<i;j++){ if (bio[j]==0 && lis[j+1]!=j){ dob=0; break; } bio[lis[j+1]]=1; } for (int j=i+1;j<=n;j++){ if (bio[j]==0 && lis[j]!=j){ dob=0; break; } bio[lis[j]]=1; } if (dob){ rje.push_back(i); } } if (rje.size()==1){ cout << rje[0] << "\n"; } else { cout << "0\n"; } } int main(){ long long int t; cin >> t; for (long long int i=0;i<t;i++){ prim(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...