結果
| 問題 | 
                            No.1425 Yet Another Cyclic Shifts Sorting
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Nachia
                         | 
                    
| 提出日時 | 2021-03-12 23:14:57 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 685 bytes | 
| コンパイル時間 | 4,442 ms | 
| コンパイル使用メモリ | 254,312 KB | 
| 最終ジャッジ日時 | 2025-01-19 15:42:57 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 35 WA * 13 | 
コンパイルメッセージ
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}; }
      |                    ~~~~~^~~~~~~~~
            
            ソースコード
#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;
}
            
            
            
        
            
Nachia