結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー m_tsubasam_tsubasa
提出日時 2021-03-12 22:25:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,303 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 201,288 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 13:28:43
合計ジャッジ時間 5,579 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_06 WA -
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 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
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 69 ms
5,376 KB
testcase_26 AC 83 ms
5,376 KB
testcase_27 AC 79 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 32 ms
5,376 KB
testcase_35 AC 95 ms
5,376 KB
testcase_36 AC 73 ms
5,376 KB
testcase_37 AC 15 ms
5,376 KB
testcase_38 AC 109 ms
5,376 KB
testcase_39 AC 5 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 111 ms
5,376 KB
testcase_47 AC 110 ms
5,376 KB
testcase_48 AC 110 ms
5,376 KB
testcase_49 AC 110 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;
      });
      int cnt = 0;
      for (int i = 1; i < n; ++i)
        if (v[i - 1] > v[i]) ++cnt;
      if (cnt == 1) return 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