# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92654 | 2019-01-04T09:34:23 Z | SamAnd | 성질 급한 지학이 (IZhO13_crazy) | C++17 | 10 ms | 632 KB |
#include <iostream> #include <algorithm> using namespace std; const int N=1003; void sp(); void fp(); int n; int a[N]; bool c[N]; int main() { //fp(); int tt; cin>>tt; for(int ii=0;ii<tt;++ii) { cin>>n; for(int i=1;i<=n;++i) { cin>>a[i]; c[i]=false; } int ans=0; for(int i=1;i<=n;++i) { for(int i=1;i<=n;++i) c[i]=false; c[a[1]]=true; bool z=true; for(int j=1,k=2;j<=n,k<=n;++j,++k) { if(j==i) { --k; continue; } if(a[k]!=j && !c[j]) { z=false; break; } c[a[k]]=true; } if(z && !ans) ans=i; else if(z && ans) { ans=0; break; } } cout<<ans<<endl; } sp(); return 0; } void fp() { #ifndef OLYMP freopen("crazy.in","r",stdin); freopen("crazy.out","w",stdout); #endif } void sp() { #ifdef OLYMP system("pause"); #endif }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 632 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 4 ms | 404 KB | Output is correct |
11 | Correct | 4 ms | 380 KB | Output is correct |
12 | Correct | 4 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 6 ms | 376 KB | Output is correct |
16 | Correct | 6 ms | 376 KB | Output is correct |
17 | Correct | 7 ms | 376 KB | Output is correct |
18 | Correct | 10 ms | 376 KB | Output is correct |
19 | Correct | 8 ms | 376 KB | Output is correct |
20 | Correct | 10 ms | 380 KB | Output is correct |