結果
問題 | No.1425 Yet Another Cyclic Shifts Sorting |
ユーザー |
![]() |
提出日時 | 2021-03-12 22:02:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 1,501 ms |
コンパイル使用メモリ | 169,612 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 16:16:17 |
合計ジャッジ時間 | 4,273 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector<int> p; for (int i = 0; i < N - 1; i++){ if (A[i] > A[i + 1]){ p.push_back(i); } } if (p.empty()){ cout << 0 << endl; } else if (p.size() == 1){ bool ok = false; for (int i = p[0] + 1; i < N - 1; i++){ if (A[i] <= A[0] && A[p[0]] <= A[i + 1]){ ok = true; } } if (A[N - 1] <= A[0]){ ok = true; } if (ok){ cout << 1 << endl; } else { cout << 2 << endl; } } else { cout << 2 << endl; } }