結果
問題 |
No.2283 Prohibit Three Consecutive
|
ユーザー |
|
提出日時 | 2023-04-29 20:53:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,065 bytes |
コンパイル時間 | 2,173 ms |
コンパイル使用メモリ | 198,068 KB |
最終ジャッジ日時 | 2025-02-12 16:08:27 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; void solve(){ int n; cin >> n; string s; cin >> s; s = s + s + s; for (int i = n; i < n * 2; i++){ if (s[i] == '?'){ s[i] = '0'; string t = s.substr(i - 2, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ goto no; } t = s.substr(i - 1, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ goto no; } t = s.substr(i, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ goto no; } } no:s[i] = '1'; string t = s.substr(i - 2, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ cout << "No" << endl; return; } t = s.substr(i - 1, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ cout << "No" << endl; return; } t = s.substr(i, 3); if (t.find('0') != string::npos and t.find('0') != string::npos){ cout << "No" << endl; return; } } cout << "Yes" << endl; } int main() { int t; cin >> t; while (t--){ solve(); } }