結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー 👑 NachiaNachia
提出日時 2021-03-12 23:14:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 685 bytes
コンパイル時間 4,834 ms
コンパイル使用メモリ 258,036 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-22 14:46:53
合計ジャッジ時間 6,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 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 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
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 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 28 ms
5,632 KB
testcase_23 AC 8 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 29 ms
5,888 KB
testcase_26 AC 35 ms
6,528 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 33 ms
5,504 KB
testcase_37 AC 7 ms
5,376 KB
testcase_38 AC 48 ms
6,656 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 39 ms
5,888 KB
testcase_41 AC 16 ms
5,376 KB
testcase_42 AC 19 ms
5,376 KB
testcase_43 AC 4 ms
5,376 KB
testcase_44 AC 7 ms
5,376 KB
testcase_45 AC 49 ms
6,528 KB
testcase_46 AC 49 ms
6,400 KB
testcase_47 AC 48 ms
6,656 KB
testcase_48 AC 49 ms
6,528 KB
testcase_49 AC 49 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[N-1]) cinv++;
  if(cinv>1) ans=2;
  printf("%d\n",ans);
  return 0;
}
0