結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー m_tsubasam_tsubasa
提出日時 2021-03-12 22:20:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 925 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 196,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 13:21:59
合計ジャッジ時間 5,694 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 1 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 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 65 ms
5,376 KB
testcase_23 AC 16 ms
5,376 KB
testcase_24 AC 14 ms
5,376 KB
testcase_25 AC 64 ms
5,376 KB
testcase_26 AC 77 ms
5,376 KB
testcase_27 AC 67 ms
5,376 KB
testcase_28 AC 78 ms
5,376 KB
testcase_29 AC 25 ms
5,376 KB
testcase_30 AC 18 ms
5,376 KB
testcase_31 AC 76 ms
5,376 KB
testcase_32 AC 24 ms
5,376 KB
testcase_33 AC 4 ms
5,376 KB
testcase_34 AC 26 ms
5,376 KB
testcase_35 AC 74 ms
5,376 KB
testcase_36 AC 54 ms
5,376 KB
testcase_37 AC 12 ms
5,376 KB
testcase_38 AC 79 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 64 ms
5,376 KB
testcase_41 AC 26 ms
5,376 KB
testcase_42 AC 32 ms
5,376 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 12 ms
5,376 KB
testcase_45 AC 82 ms
5,376 KB
testcase_46 AC 79 ms
5,376 KB
testcase_47 AC 80 ms
5,376 KB
testcase_48 AC 77 ms
5,376 KB
testcase_49 AC 79 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;
      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;
}
0