結果

問題 No.2283 Prohibit Three Consecutive
ユーザー achapi
提出日時 2023-04-29 20:47:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 196,668 KB
最終ジャッジ日時 2025-02-12 16:08:20
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = s + s + s;
	for (int i = n; i < n * 2; i++){
		string t = s.substr(i - 2, 5);
		if (t.find('0') != string::npos and t.find('0') != string::npos){
			cout << "No" << endl;
			return;
		}
		if (s[i] == '?'){
			if (t.find('0') == string::npos){
				s[i] = '1';
			}else{
				s[i] = '0';
			}
		}
	}
	cout << "Yes" << endl; 
}

int main() {
	int t;
	cin >> t;
	while (t--){
		solve();
	}
}
0