結果
| 問題 | 
                            No.1425 Yet Another Cyclic Shifts Sorting
                             | 
                    
| コンテスト | |
| ユーザー | 
                             milanis48663220
                         | 
                    
| 提出日時 | 2021-03-12 22:04:12 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,573 bytes | 
| コンパイル時間 | 796 ms | 
| コンパイル使用メモリ | 95,084 KB | 
| 最終ジャッジ日時 | 2025-01-19 14:48:52 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 WA * 4 | 
ソースコード
#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;
    }
}
            
            
            
        
            
milanis48663220