結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー 👑 Nachia
提出日時 2021-03-12 23:10:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 636 bytes
コンパイル時間 4,277 ms
コンパイル使用メモリ 254,280 KB
最終ジャッジ日時 2025-01-19 15:38:52
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |   scanf("%d",&N);
      |   ~~~~~^~~~~~~~~
main.cpp:18:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   rep(i,N){ int a; scanf("%d",&a); A[i]=a; Q[i]={a,i}; }
      |                    ~~~~~^~~~~~~~~

ソースコード

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;
  rep(i,xp) if((P[i]+1)%(xp+1)!=P[i+1]) ans=2;
  printf("%d\n",ans);
  return 0;
}
0