# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5656 | baneling100 | Crazy old lady (IZhO13_crazy) | C++98 | 12 ms | 1096 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 <stdio.h>
int T, N, P[1001], check[1001], ans;
void input(void)
{
int i;
scanf("%d",&N);
for(i=1 ; i<=N ; i++)
scanf("%d",&P[i]);
ans=0;
}
void process(void)
{
int i, j, now, ok;
for(i=1 ; i<=N ; i++)
{
for(j=1 ; j<=N ; j++)
check[j]=0;
check[P[1]]=ok=1;
now=0;
for(j=2 ; j<=N && ok ; j++)
{
now++;
if(now==i)
now++;
if(check[now])
{
if(now==P[j])
ok=0;
else
{
if(check[P[j]])
ok=0;
else
check[P[j]]=1;
}
}
else
{
if(now==P[j])
check[now]=1;
else
ok=0;
}
}
if(ok)
{
if(ans)
{
ans=0;
break;
}
else
ans=i;
}
}
}
void output(void)
{
printf("%d\n",ans);
}
int main(void)
{
int i;
scanf("%d",&T);
for(i=1 ; i<=T ; i++)
{
input();
process();
output();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |