結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー m_tsubasam_tsubasa
提出日時 2021-03-12 22:17:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 198,108 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 13:18:35
合計ジャッジ時間 5,783 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 67 ms
5,376 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 70 ms
5,376 KB
testcase_26 AC 82 ms
5,376 KB
testcase_27 AC 74 ms
5,376 KB
testcase_28 AC 86 ms
5,376 KB
testcase_29 AC 27 ms
5,376 KB
testcase_30 AC 20 ms
5,376 KB
testcase_31 AC 84 ms
5,376 KB
testcase_32 AC 26 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 30 ms
5,376 KB
testcase_35 AC 80 ms
5,376 KB
testcase_36 AC 58 ms
5,376 KB
testcase_37 AC 13 ms
5,376 KB
testcase_38 AC 84 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 70 ms
5,376 KB
testcase_41 AC 28 ms
5,376 KB
testcase_42 AC 34 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 13 ms
5,376 KB
testcase_45 AC 85 ms
5,376 KB
testcase_46 AC 86 ms
5,376 KB
testcase_47 AC 85 ms
5,376 KB
testcase_48 AC 85 ms
5,376 KB
testcase_49 AC 85 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0