結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
![]() |
提出日時 | 2021-03-12 21:59:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 760 bytes |
コンパイル時間 | 660 ms |
コンパイル使用メモリ | 71,272 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-14 12:23:11 |
合計ジャッジ時間 | 3,977 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 WA * 4 |
ソースコード
#include <algorithm> #include <iostream> using namespace std; typedef pair<int, int> P; int main() { int n; cin >> n; int a[200005]; P p[200005]; for(int i = 0; i < n; i++){ cin >> a[i]; p[i] = P(a[i], i); } sort(p, p + n); int l = p[0].second; int i; for(i = 0; l + i < n; i++){ if(p[i].first != a[l + i]) break; } if(i == n){ cout << 0 << endl; return 0; } int r = l + i; l = -i; for(; i < r; i++){ if(p[i].first != a[l + i]){ cout << 2 << endl; return 0; } } for(; i < n; i++){ if(p[i].first != a[i]){ cout << 2 << endl; return 0; } } cout << 1 << endl; }