結果
問題 | No.2518 Adjacent Larger |
ユーザー |
|
提出日時 | 2023-10-27 21:29:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 675 ms |
コンパイル使用メモリ | 77,540 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 13:32:26 |
合計ジャッジ時間 | 1,973 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include<iostream>#include<cassert>#include<algorithm>#include<cmath>#include<iomanip>using namespace std;int N,A[2<<17];int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int T;cin>>T;for(;T--;){cin>>N;int si=-1;for(int i=0;i<N;i++){cin>>A[i];if(A[i]!=1)si=i;}if(si==-1){cout<<"No\n";continue;}rotate(A,A+si,A+N);int prv=A[0];bool ok=true;for(int i=1;i<N;i++)if(A[i]!=1){if(prv==A[i])ok=false;prv=A[i];}if(prv==A[0])ok=false;cout<<(ok?"Yes\n":"No\n");}}