結果

問題 No.2283 Prohibit Three Consecutive
ユーザー jiangly
提出日時 2023-04-28 21:30:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 199,444 KB
最終ジャッジ日時 2025-02-12 14:54:00
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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