답안 #4776

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4776 2014-01-01T10:22:58 Z gs13068 성질 급한 지학이 (IZhO13_crazy) C++
100 / 100
12 ms 1092 KB
#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);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1092 KB Output is correct
2 Correct 0 ms 1092 KB Output is correct
3 Correct 0 ms 1092 KB Output is correct
4 Correct 0 ms 1092 KB Output is correct
5 Correct 0 ms 1092 KB Output is correct
6 Correct 0 ms 1092 KB Output is correct
7 Correct 0 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 0 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 4 ms 1092 KB Output is correct
15 Correct 4 ms 1092 KB Output is correct
16 Correct 8 ms 1092 KB Output is correct
17 Correct 8 ms 1092 KB Output is correct
18 Correct 12 ms 1092 KB Output is correct
19 Correct 8 ms 1092 KB Output is correct
20 Correct 12 ms 1092 KB Output is correct