# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341118 | juggernaut | Crazy old lady (IZhO13_crazy) | C++14 | 19 ms | 512 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 a[1000];
bool flag[1001];
int main(){
int test;
scanf("%d",&test);
while(test--){
int ans=0,i,j,n,t;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)flag[j]=false;
flag[a[0]]=true;
for(j=1;j<n;j++){
t=j;
if(t>=i)t++;
if(!flag[t]&&a[j]!=t)break;
flag[a[j]]=true;
}
if(j==n){
if(ans)ans=-1;
else ans=i;
}
}
ans=max(ans,0);
printf("%d\n",ans);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |