#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]);
}
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
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 |
1 |
Correct |
0 ms |
1096 KB |
Output is correct |
2 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
9 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
1096 KB |
Output isn't correct |
14 |
Incorrect |
4 ms |
1096 KB |
Output isn't correct |
15 |
Incorrect |
4 ms |
1096 KB |
Output isn't correct |
16 |
Incorrect |
4 ms |
1096 KB |
Output isn't correct |
17 |
Incorrect |
8 ms |
1096 KB |
Output isn't correct |
18 |
Incorrect |
4 ms |
1096 KB |
Output isn't correct |
19 |
Incorrect |
4 ms |
1096 KB |
Output isn't correct |
20 |
Incorrect |
12 ms |
1096 KB |
Output isn't correct |