結果
| 問題 |
No.2283 Prohibit Three Consecutive
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-04 14:49:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 2,054 ms |
| コンパイル使用メモリ | 192,500 KB |
| 最終ジャッジ日時 | 2025-02-12 16:53:22 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 5 |
ソースコード
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define PII std::pair<int, int>
using ll = long long;
void solve() {
int n; std::cin >> n;
std::string s; std::cin >> s;
s += s;
for (int i = 2; i < n + n; i++) {
if(s[i - 1] == s[i - 2] and s[i - 2] != '?') {
if(s[i] == s[i - 1]) {
std::cout << "No\n";
return;
} else if(s[i] == '?') {
char x = '1' - s[i - 1] + '0';
if(s[i + 1] == s[i + 2] and s[i + 1] == x) {
std::cout << "No\n";
return;
} else {
s[i] = x;
}
}
}
}
std::cout << "Yes\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while(T--) {
solve();
}
return 0;
}