結果
| 問題 |
No.2518 Adjacent Larger
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-27 21:42:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 871 bytes |
| コンパイル時間 | 1,744 ms |
| コンパイル使用メモリ | 169,852 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 13:47:27 |
| 合計ジャッジ時間 | 3,111 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int test; cin >> test;
while(test--){
int N; cin >> N;
vector<int> A(N);
for(auto &a : A) cin >> a;
bool zero = false,two = false;
for(int i=0; i<N; i++){
if(A.at(i) == 0) zero = true;
if(A.at(i) == 2) two = true;
}
if(!zero || !two){cout << "No" << endl; continue;}
int before = -1;
bool yes = true;
for(int i=0; i<2*N; i++){
int pos = i%N;
if(A.at(pos) == 1) continue;
if(A.at(pos) == 0 && before == 0) yes = false;
if(A.at(pos) == 2 && before == 2) yes = false;
before = A.at(pos);
}
if(yes) cout << "Yes" << endl;
else cout << "No" << endl;
}
}