結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
![]() |
提出日時 | 2021-03-12 22:17:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 874 bytes |
コンパイル時間 | 1,828 ms |
コンパイル使用メモリ | 195,980 KB |
最終ジャッジ日時 | 2025-01-19 14:59:17 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n; vector<int> a; int solve(); int main() { cin >> n; a.resize(n); for (auto &p : a) cin >> p; cout << solve() << endl; return 0; } int solve() { { // 0 bool ch = 1; for (int i = 1; i < n; ++i) if (a[i - 1] > a[i]) ch = 0; if (ch) return 0; } { // 1 int id = 0; for (int i = 0; i < n; ++i) if (a[id] > a[i]) id = i; if (id) { int last = a[id - 1], lid = id - 1; for (int i = id + 1; i < n; ++i) if (last <= a[i]) { lid = i; break; } bool ch = 1; for (int i = lid + 1; i < n; ++i) if (a[i - 1] > a[i]) ch = 0; int len = (id - 1 == lid ? n : lid); for (int i = 1; i < len; ++i) if (a[(id + i - 1) % len] > a[(id + i) % len]) ch = 0; if (ch) return 1; } } return 2; }