結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー SSRS
提出日時 2021-03-12 21:56:56
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 170,300 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-14 12:19:48
合計ジャッジ時間 4,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> p;
  for (int i = 0; i < N - 1; i++){
    if (A[i] > A[i + 1]){
      p.push_back(i);
    }
  }
  if (p.empty()){
    cout << 0 << endl;
  } else if (p.size() == 1){
    bool ok = false;
    for (int i = p[0] + 1; i < N - 1; i++){
      if (A[i] <= A[0] && A[p[0]] <= A[i + 1]){
        ok = true;
      }
    }
    if (ok){
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  } else {
    cout << 2 << endl;
  }
}
0