# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
341118 | 2020-12-29T03:11:12 Z | juggernaut | 성질 급한 지학이 (IZhO13_crazy) | C++14 | 19 ms | 512 KB |
#include<bits/stdc++.h> using namespace std; int a[1000]; bool flag[1001]; int main(){ int test; scanf("%d",&test); while(test--){ int ans=0,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++)flag[j]=false; flag[a[0]]=true; for(j=1;j<n;j++){ t=j; if(t>=i)t++; if(!flag[t]&&a[j]!=t)break; flag[a[j]]=true; } if(j==n){ if(ans)ans=-1; else ans=i; } } ans=max(ans,0); printf("%d\n",ans); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 2 ms | 364 KB | Output is correct |
9 | Correct | 3 ms | 364 KB | Output is correct |
10 | Correct | 4 ms | 364 KB | Output is correct |
11 | Correct | 5 ms | 512 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 6 ms | 364 KB | Output is correct |
14 | Correct | 7 ms | 364 KB | Output is correct |
15 | Correct | 8 ms | 364 KB | Output is correct |
16 | Correct | 11 ms | 364 KB | Output is correct |
17 | Correct | 11 ms | 364 KB | Output is correct |
18 | Correct | 16 ms | 492 KB | Output is correct |
19 | Correct | 14 ms | 364 KB | Output is correct |
20 | Correct | 19 ms | 364 KB | Output is correct |