結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
|
提出日時 | 2021-03-13 04:22:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 68,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 16:53:54 |
合計ジャッジ時間 | 3,547 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,A[2<<17],B[2<<17]; main() { cin>>N; for(int i=0;i<N;i++) { cin>>A[i]; B[i]=A[i]; } sort(B,B+N); int r=N; while(r>0&&A[r-1]==B[r-1])r--; if(r==0)cout<<0<<endl; else { int id=r-1; while(A[id]!=B[r-1])id--; for(int i=0;i<r;i++)if(A[(id+1+i)%r]!=B[i]) { cout<<2<<endl; return 0; } cout<<1<<endl; } }