結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー 👑 NachiaNachia
提出日時 2021-03-12 23:16:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 5,164 ms
コンパイル使用メモリ 257,764 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-22 17:15:54
合計ジャッジ時間 6,521 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 1 ms
5,376 KB
testcase_06 AC 1 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 1 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 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 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 25 ms
5,760 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 27 ms
5,888 KB
testcase_26 AC 32 ms
6,400 KB
testcase_27 AC 29 ms
6,016 KB
testcase_28 AC 39 ms
6,400 KB
testcase_29 AC 11 ms
5,376 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 39 ms
6,528 KB
testcase_32 AC 11 ms
5,376 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 12 ms
5,376 KB
testcase_35 AC 40 ms
6,144 KB
testcase_36 AC 29 ms
5,504 KB
testcase_37 AC 8 ms
5,376 KB
testcase_38 AC 44 ms
6,528 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 36 ms
5,888 KB
testcase_41 AC 14 ms
5,376 KB
testcase_42 AC 17 ms
5,376 KB
testcase_43 AC 4 ms
5,376 KB
testcase_44 AC 6 ms
5,376 KB
testcase_45 AC 48 ms
6,528 KB
testcase_46 AC 48 ms
6,528 KB
testcase_47 AC 47 ms
6,528 KB
testcase_48 AC 45 ms
6,656 KB
testcase_49 AC 46 ms
6,656 KB
testcase_50 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using mll=atcoder::static_modint<1000000007>;

int N;
vector<int> A;
vector<pair<int,int>> Q;
vector<int> P;

int main(){
  scanf("%d",&N);
  A.resize(N);
  Q.resize(N);
  rep(i,N){ int a; scanf("%d",&a); A[i]=a; Q[i]={a,i}; }
  sort(Q.begin(),Q.end());
  P.resize(N);
  rep(i,N) P[i]=Q[i].second;
  int xp=-1; rep(i,N) if(P[i]!=i) xp=i;
  if(xp==-1){ printf("0\n"); return 0; }
  int ans=1;
  int cinv=0;
  rep(i,xp) if(A[i]>A[i+1]) cinv++;
  if(A[0]<A[xp]) cinv++;
  if(cinv>1) ans=2;
  printf("%d\n",ans);
  return 0;
}
0