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