結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
5,376 KB
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 AC 2 ms
5,376 KB
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 66 ms
5,376 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 15 ms
5,376 KB
testcase_25 AC 70 ms
5,376 KB
testcase_26 AC 83 ms
5,376 KB
testcase_27 AC 80 ms
5,376 KB
testcase_28 AC 98 ms
5,376 KB
testcase_29 AC 28 ms
5,376 KB
testcase_30 AC 23 ms
5,376 KB
testcase_31 AC 99 ms
5,376 KB
testcase_32 AC 28 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 31 ms
5,376 KB
testcase_35 AC 96 ms
5,376 KB
testcase_36 AC 74 ms
5,376 KB
testcase_37 AC 16 ms
5,376 KB
testcase_38 AC 109 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 88 ms
5,376 KB
testcase_41 AC 34 ms
5,376 KB
testcase_42 AC 42 ms
5,376 KB
testcase_43 AC 7 ms
5,376 KB
testcase_44 AC 15 ms
5,376 KB
testcase_45 AC 110 ms
5,376 KB
testcase_46 AC 110 ms
5,376 KB
testcase_47 AC 111 ms
5,376 KB
testcase_48 AC 111 ms
5,376 KB
testcase_49 AC 111 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
    {
      vector<int> v(n);
      iota(v.begin(), v.end(), 0);
      sort(v.begin(), v.end(), [](int l, int r) {
        if (a[l] != a[r]) return a[l] < a[r];
        return l < r;
      });
      while (v.back() == v.size() - 1) v.pop_back();
      {
        int id = -1, len = v.size();
        for (int i = 0; i < len; ++i)
          if (v[i] == 0) id = i;
        bool ch = 1;
        for (int i = 0; i < len; ++i)
          if (v[(i + id) % len] != i) ch = 0;
        if (ch) return 1;
      }
    }
  }
  return 2;
}
0