結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー hir355hir355
提出日時 2021-03-12 22:22:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,715 bytes
コンパイル時間 2,465 ms
コンパイル使用メモリ 207,056 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-22 13:24:32
合計ジャッジ時間 4,814 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,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 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 20 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 22 ms
5,376 KB
testcase_26 AC 25 ms
5,376 KB
testcase_27 AC 52 ms
8,064 KB
testcase_28 AC 59 ms
8,192 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 13 ms
5,376 KB
testcase_31 AC 57 ms
8,064 KB
testcase_32 AC 16 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 22 ms
5,632 KB
testcase_35 AC 55 ms
8,192 KB
testcase_36 WA -
testcase_37 AC 7 ms
5,376 KB
testcase_38 AC 45 ms
8,192 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 39 ms
8,064 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 4 ms
5,376 KB
testcase_44 AC 7 ms
5,376 KB
testcase_45 WA -
testcase_46 AC 45 ms
8,192 KB
testcase_47 AC 45 ms
8,192 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/segtree>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
const long long INF_LL = 2000000000000000000LL;
const int INF = 2000000000;
const long long MOD = 1000000007;
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

typedef vector<vector<edge>> graph;

// using mint = modint998244353;

vector<long long> prime_factorize(long long N) {
    vector<long long> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        while (N % a == 0) {
            N /= a;
        }
        res.push_back(a);
    }
    if (N != 1) res.push_back(N);
    return res;
}

int op1(int a, int b){
    return max(a, b);
}

int op2(int a, int b){
    return min(a, b);
}

bool op3(bool a, bool b){
    return a | b;
}

int e1(){return 0;}

int e2(){return INF;}

bool e3(){return false;}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    bool flg = true;
    rep(i, n - 1){
        if(a[i] > a[i + 1]){
            flg = false;
        }
    }
    if(flg){
        cout << 0 << endl;
        return 0;
    }
    segtree<int, op1, e1> maxseg(a);
    segtree<int, op2, e2> minseg(a);
    segtree<bool, op3, e3> orseg(n - 1);
    rep(i, n - 1){
        if(a[i] <= a[i + 1]) orseg.set(i, true);
    }
    REP(i, 1, n){
        if(!orseg.prod(i - 1, n - 1) || !orseg.prod(0, i)){
            break;
        }
        int l = i, r = n + 1;
        while(r - l > 1){
            int m = (l + r) / 2;
            if(maxseg.prod(i, m) <= minseg.prod(0, i - 1)){
                l = m;
            }else{
                r = m;
            }
        }
        if(maxseg.prod(0, i) <= minseg.prod(l, n)){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 2 << endl;
    return 0;
}
0