結果
問題 | No.2518 Adjacent Larger |
ユーザー |
|
提出日時 | 2023-10-27 21:53:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 1,774 ms |
コンパイル使用メモリ | 194,688 KB |
最終ジャッジ日時 | 2025-02-17 14:56:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; void solve(){ int N; cin>>N; vector A(N,0); for(int &i:A)cin>>i; if(*max_element(A.begin(),A.end())!=2||*min_element(A.begin(),A.end())!=0){ cout<<"No\n"; return; } int t=1; for(int i=0;i<N*2;i++){ if(A[i%N]==2){ if(t==2){ cout<<"No\n"; return; }else{ t=2; } }else if(A[i%N]==0){ if(t==0){ cout<<"No\n"; return; }else{ t=0; } } } cout<<"Yes\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int test_case; cin>>test_case; while (test_case--){ solve(); } }