結果

問題 No.2283 Prohibit Three Consecutive
ユーザー ococonomy1ococonomy1
提出日時 2023-04-28 21:41:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,888 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 108,332 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:20:19
合計ジャッジ時間 1,896 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
using namespace std;
using lg = long long;
#define TEST clog << "TEST" << endl
#define IINF 2147483647
#define LLINF 9223372036854775807LL
#define AMARI 998244353
#define TEMOTO ((sizeof(long double) == 16) ? false : true)
#define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000)
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE true
void solve(void) {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++)s.push_back(s[i]);
    vector<int> zyoutai(2 * n);
    //zyoutai[i] == 0 0のみ取り得る 1:1のみ取り得る 2:0も1も取り得る
    if (s[0] == '0')zyoutai[0] = 0;
    if (s[0] == '1')zyoutai[0] = 1;
    if (s[0] == '?')zyoutai[0] = 2;
    if (s[1] == '0')zyoutai[1] = 0;
    if (s[1] == '1')zyoutai[1] = 1;
    if (s[1] == '?')zyoutai[1] = 2;
    for (int i = 2; i < 2 * n; i++) {
        //clog << i << el;
        if (s[i] == '0')zyoutai[i] = 0;
        if (s[i] == '1')zyoutai[i] = 1;
        if (s[i] == '?') {
            if (zyoutai[i - 1] == zyoutai[i - 2] && zyoutai[i - 1] != 2)zyoutai[i] = zyoutai[i - 1] ^ 1;
            else zyoutai[i] = 2;
        }
    }
    for (int i = 0; i < 2 * n - 2; i++) {
        if (zyoutai[i] == zyoutai[i + 1] && zyoutai[i + 1] == zyoutai[i + 2] && zyoutai[i] != 2) {
            cout << "No" << el;
            return;
        }
    }
    cout << "Yes" << El;
    return;
}

void calc(void) {
    return;
}

int main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t = 1;
    if (MULTI_TEST_CASE)cin >> t;
    while (t--) {
        solve();
    }
    calc();
    return 0;
}
0