結果
| 問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
| コンテスト | |
| ユーザー |
m_tsubasa
|
| 提出日時 | 2021-03-12 22:20:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 925 bytes |
| コンパイル時間 | 1,890 ms |
| コンパイル使用メモリ | 194,756 KB |
| 最終ジャッジ日時 | 2025-01-19 15:02:44 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 WA * 4 |
ソースコード
#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;
if (id - 1 != lid) {
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) % len] > a[(id + i + len) % len]) ch = 0;
if (ch) return 1;
}
}
return 2;
}
m_tsubasa