結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー auauaauaua
提出日時 2021-03-12 22:41:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 168,252 KB
実行使用メモリ 10,756 KB
最終ジャッジ日時 2024-04-22 17:13:53
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 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 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 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 70 ms
5,632 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 16 ms
5,376 KB
testcase_25 AC 72 ms
5,888 KB
testcase_26 AC 86 ms
6,272 KB
testcase_27 AC 74 ms
6,656 KB
testcase_28 AC 91 ms
10,624 KB
testcase_29 AC 28 ms
5,488 KB
testcase_30 AC 21 ms
5,376 KB
testcase_31 AC 88 ms
10,696 KB
testcase_32 AC 26 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 29 ms
5,376 KB
testcase_35 AC 82 ms
10,496 KB
testcase_36 AC 63 ms
9,592 KB
testcase_37 AC 14 ms
5,376 KB
testcase_38 AC 86 ms
10,464 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 73 ms
9,888 KB
testcase_41 AC 30 ms
5,512 KB
testcase_42 AC 36 ms
6,776 KB
testcase_43 AC 6 ms
5,376 KB
testcase_44 AC 12 ms
5,376 KB
testcase_45 AC 88 ms
10,628 KB
testcase_46 AC 91 ms
10,632 KB
testcase_47 AC 90 ms
10,756 KB
testcase_48 AC 91 ms
10,632 KB
testcase_49 AC 90 ms
10,636 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF;
const ll mod=INF;
const ll MAX=200010;





signed main(){
    ll n;cin>>n;
    vector<ll>b(n);
    rep(i,n)cin>>b[i];
    vector<ll>m(n);
    m[0]=b[0];
    REP(i,1,n){
        m[i]=max(m[i],b[i]);
        m[i]=max(m[i],m[i-1]);
    }
    vector<ll>a(0);
    ll la=n;
    for(int i=n-1;i>=1;i--){
        if(m[i-1]>b[i]){
            break;
        }
        la--;
    }
    rep(i,la){
        a.pb(b[i]);
    }
    rep(i,la){
        a.pb(a[i]);
    }
    ll cnt=1;
    ll ma=1;
    REP(i,1,2*la){
        if(a[i]>=a[i-1]){
            cnt++;
        }else{
            ma=max(ma,cnt);
            cnt=1;
        }
    }
    ma=max(ma,cnt);
    bool f=1;
    REP(i,1,n){
        if(b[i-1]>b[i])f=0;
    }
    if(f){
        cout<<0<<endl;
    }else if(ma>=la){
        cout<<1<<endl;
    }else{
        cout<<2<<endl;
    }
}
0