結果
| 問題 |
No.2283 Prohibit Three Consecutive
|
| コンテスト | |
| ユーザー |
yukster714
|
| 提出日時 | 2023-04-28 23:14:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 742 bytes |
| コンパイル時間 | 1,274 ms |
| コンパイル使用メモリ | 168,644 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 22:08:50 |
| 合計ジャッジ時間 | 1,870 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define yesif(x) cout << ((x) ? "Yes": "No") << endl
bool out(char a, char b, char c, char q){
if(a == '?') a = q;
if(b == '?') b = q;
if(c == '?') c = q;
return (a == b and b == c);
}
bool solve(int n, string s){
bool ans1 = true;
bool ans2 = true;
rep(i,n) {
if(out(s[i%n], s[(i+1)%n], s[(i+2)%n], '0')) {
ans1 = false;
}
if(out(s[i%n], s[(i+1)%n], s[(i+2)%n], '1')) {
ans2 = false;
}
}
return ans1 or ans2;
}
int main() {
int t; cin>>t;
while(t--){
int n; cin >> n;
string s; cin>> s;
yesif(solve(n,s));
}
return 0;
}
yukster714