Submission #4776

#TimeUsernameProblemLanguageResultExecution timeMemory
4776gs13068Crazy old lady (IZhO13_crazy)C++98
100 / 100
12 ms1092 KiB
#include<cstdio> int a[1000]; bool seat[1001]; int main() { int tc; scanf("%d",&tc); while(tc--) { int ans=0; int 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++)seat[j]=false; seat[a[0]]=true; for(j=1;j<n;j++) { t=j; if(t>=i)t++; if(!seat[t]&&a[j]!=t)break; seat[a[j]]=true; } if(j==n) { if(ans)ans=-1; else ans=i; } } printf("%d\n",ans>0?ans:0); } }
#Verdict Execution timeMemoryGrader output
Fetching results...