結果

問題 No.2283 Prohibit Three Consecutive
ユーザー jianglyjiangly
提出日時 2023-04-28 21:30:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 205,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:11:41
合計ジャッジ時間 2,902 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 11 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
testcase_10 AC 10 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int N;
    std::cin >> N;
    
    std::string S;
    std::cin >> S;
    S = S + S;
    
    for (auto t : std::vector<std::string>{"000", "111", "00?11", "11?00"}) {
        for (int i = 0; i < N; i++) {
            if (N >= t.size() && S.substr(i, t.size()) == t) {
                std::cout << "No\n";
                return;
            }
        }
    }
    
    std::cout << "Yes\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}
0