結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー TrpFrogTrpFrog
提出日時 2021-03-12 23:06:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,797 bytes
コンパイル時間 2,559 ms
コンパイル使用メモリ 206,168 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-22 14:36:03
合計ジャッジ時間 8,614 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
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 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 148 ms
11,264 KB
testcase_23 AC 33 ms
5,496 KB
testcase_24 AC 27 ms
5,376 KB
testcase_25 AC 157 ms
11,648 KB
testcase_26 AC 189 ms
13,056 KB
testcase_27 AC 166 ms
11,904 KB
testcase_28 AC 188 ms
13,312 KB
testcase_29 AC 50 ms
6,304 KB
testcase_30 AC 34 ms
5,480 KB
testcase_31 AC 178 ms
13,184 KB
testcase_32 AC 49 ms
6,332 KB
testcase_33 AC 7 ms
5,376 KB
testcase_34 AC 56 ms
6,748 KB
testcase_35 AC 165 ms
12,672 KB
testcase_36 AC 190 ms
16,128 KB
testcase_37 AC 29 ms
5,376 KB
testcase_38 AC 333 ms
17,920 KB
testcase_39 AC 7 ms
5,376 KB
testcase_40 AC 252 ms
17,664 KB
testcase_41 AC 72 ms
7,680 KB
testcase_42 AC 95 ms
10,112 KB
testcase_43 AC 11 ms
5,376 KB
testcase_44 AC 28 ms
5,376 KB
testcase_45 AC 333 ms
18,048 KB
testcase_46 AC 330 ms
17,920 KB
testcase_47 AC 371 ms
19,712 KB
testcase_48 AC 366 ms
19,712 KB
testcase_49 AC 347 ms
19,712 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define ans_return(x) { cout << x << endl; return; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define r_rep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)
#define r_reps(i, n, m) for (ll i = (ll)(m) - 1; i >= (ll)(n); i--)
#define debugarr(a) {cerr << #a << ":"; \
                    for(auto _e:a){cerr << " " <<_e;} cerr << endl;}

using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;

unused constexpr ll MOD = 1e9 + 7;
unused constexpr ll INF = 1 << 29;
unused constexpr ll LINF = 1LL << 61;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline void modadd(ll &a, ll b, ll m = MOD) { a = mod(a + b, m); }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused inline bool in_range(T a, T x, T b) { return a <= x && x < b; }
unused inline bool in_range(ll x, ll b) { return in_range(0LL, x, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    {
        map<int, int> m;
        rep(i, n) m[a[i]] = 0;
        int i = 0;
        for(auto p : m) {
            m[p.first] = i;
            i++;
        }
        rep(i, n) a[i] = m[a[i]];
    }
    
    vector<vector<int>> v(1);
    v.back().pb(a.front());

    reps(i, 1, n) {
        if(v.back().back() == a[i] || v.back().back() + 1 == a[i]) {
            v.back().pb(a[i]);
        } else {
            v.pb(vector<int>());
            v.back().pb(a[i]);
        }
    }

    if(v.size() == 1) {
        cout << 0 << endl;
    } else if(v.size() == 2 && v[1].back() <= v[0].front()) {
        cout << 1 << endl;
    } else if(v.size() == 3 && v[1].back() <= v[0].front() && v[0].back() <= v[2].front()) {
        cout << 1 << endl;
    } else {
        cout << 2 << endl;
    }
}
0