結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー milanis48663220milanis48663220
提出日時 2021-03-12 22:04:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,573 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 99,556 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-22 13:02:08
合計ジャッジ時間 4,819 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 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 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 63 ms
11,264 KB
testcase_23 AC 15 ms
5,376 KB
testcase_24 AC 13 ms
5,376 KB
testcase_25 AC 66 ms
11,648 KB
testcase_26 AC 78 ms
13,184 KB
testcase_27 AC 78 ms
11,904 KB
testcase_28 AC 85 ms
13,312 KB
testcase_29 AC 22 ms
6,272 KB
testcase_30 AC 16 ms
5,628 KB
testcase_31 AC 82 ms
13,184 KB
testcase_32 AC 24 ms
6,344 KB
testcase_33 AC 4 ms
5,376 KB
testcase_34 AC 27 ms
6,772 KB
testcase_35 AC 73 ms
12,544 KB
testcase_36 AC 61 ms
9,984 KB
testcase_37 AC 11 ms
5,376 KB
testcase_38 AC 107 ms
13,312 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 80 ms
11,392 KB
testcase_41 AC 25 ms
6,416 KB
testcase_42 AC 32 ms
7,116 KB
testcase_43 AC 4 ms
5,376 KB
testcase_44 AC 11 ms
5,376 KB
testcase_45 AC 105 ms
13,440 KB
testcase_46 AC 103 ms
13,440 KB
testcase_47 AC 103 ms
13,440 KB
testcase_48 AC 101 ms
13,440 KB
testcase_49 AC 103 ms
13,440 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n);
    multiset<int> st;
    bool ok = true;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        st.insert(a[i]);
        if(i >= 1 && a[i] < a[i-1]) ok = false;
    }
    if(ok){
        cout << 0 << endl;
        return 0;
    }
    int r = -1;
    for(int i = n-1; i >= 1; i--){
        st.erase(st.find(a[i]));
        auto p = st.end();
        p--;
        if(*p > a[i]){
            r = i+1;
            break;
        }
    }
    int mn = 2e9;
    for(int i = 0; i < r; i++){
        chmin(mn, a[i]);
    }
    int x = -1;
    for(int i = 0; i < r; i++){
        if(a[i] == mn) {
            x = i;
            break;
        }
    }
    ok = true;
    for(int i = x; ;i = (i+1)%r){
        if((i+1)%r == x) break;
        if(a[i] > a[(i+1)%r]) ok = false;
    }
    if(ok){
        cout << 1 << endl;
    }else{
        cout << 2 << endl;
    }
}
0