結果

問題 No.2283 Prohibit Three Consecutive
ユーザー yukster714yukster714
提出日時 2023-04-28 22:35:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 167,260 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 00:02:52
合計ジャッジ時間 2,414 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 6 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 5 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 4 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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; break;}
    rep(i,n) if(out(s[i%n], s[(i+1)%n], s[(i+2)%n], '1')) {ans2 = false; break;}
    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;
}

0