Submission #00068
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio; int N; cin>>N; bool flag= false ; int a[N],A[N],b=0,ans,c[N]; for ( int i=0;i<N;i++){ cin>>a[i]; A[i]=a[i]; } sort(A,A+N); for ( int i=0;i<N;i++){ if (a[i]==A[i]){ c[i]=1; } else { c[i]=0; b++; } } int Q,x,y; cin>>Q; if (b==0){ ans=0; flag= true ; } for ( int i=0;i<Q;i++){ cin>>x>>y; x--; y--; swap(a[x],a[y]); if (a[x]==A[x]&&c[x]==1){ c[x]==0; b++; } else if (a[x]==A[x]&&c[x]==0){ c[x]==1; b--; } if (a[y]==A[y]&&c[y]==1){ c[x]==0; b++; } else if (a[y]==A[y]&&c[y]==0){ c[x]==1; b--; } if (b==0&&flag== false ){ ans=i+1; flag= true ; } } if (flag== true ) cout<<ans<< "\n" ; else cout<< "-1" << "\n" ; return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - ボゾソート |
ユーザー名 | ナタ |
投稿日時 | 2021-09-10 16:32:01 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 1130 Byte |
最大実行時間 | 286 ms |
最大メモリ使用量 | 4252 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 6 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 19 ms | 344 KB |
1
|
in2.txt | AC | 18 ms | 636 KB |
1
|
in3.txt | AC | 22 ms | 736 KB |
1
|
in4.txt | AC | 16 ms | 708 KB |
1
|
in5.txt | AC | 21 ms | 680 KB |
1
|
in6.txt | AC | 22 ms | 656 KB |
1
|
in7.txt | AC | 24 ms | 632 KB |
1
|
in8.txt | WA | 18 ms | 600 KB |
1
|
in9.txt | AC | 26 ms | 696 KB |
1
|
in10.txt | WA | 186 ms | 3896 KB |
1
|
in11.txt | WA | 286 ms | 3944 KB |
1
|
in12.txt | AC | 275 ms | 3860 KB |
1
|
in13.txt | WA | 195 ms | 3900 KB |
1
|
in14.txt | AC | 175 ms | 4080 KB |
1
|
in15.txt | WA | 136 ms | 4124 KB |
1
|
in16.txt | AC | 190 ms | 4164 KB |
1
|
in17.txt | AC | 227 ms | 4204 KB |
1
|
in18.txt | AC | 223 ms | 4252 KB |
1
|
in19.txt | WA | 214 ms | 4172 KB |
1
|
in20.txt | AC | 110 ms | 1632 KB |
1
|
in21.txt | AC | 79 ms | 1392 KB |
1
|
in22.txt | AC | 66 ms | 872 KB |
1
|
in23.txt | AC | 164 ms | 2988 KB |
1
|
in24.txt | AC | 43 ms | 1652 KB |
1
|
in25.txt | AC | 172 ms | 2928 KB |
1
|
in26.txt | AC | 114 ms | 1144 KB |
1
|