# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4776 | gs13068 | Crazy old lady (IZhO13_crazy) | C++98 | 12 ms | 1092 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<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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |