結果
問題 |
No.2283 Prohibit Three Consecutive
|
ユーザー |
![]() |
提出日時 | 2023-04-28 22:25:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 1,732 ms |
コンパイル使用メモリ | 167,448 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 21:22:48 |
合計ジャッジ時間 | 2,369 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; rep(i,n) 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; }