結果

問題 No.2283 Prohibit Three Consecutive
ユーザー anonymously
提出日時 2023-04-28 22:05:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 168,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 21:02:12
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const string YES="Yes";
const string NO="No";
/*
 s=文字列
 S=s+s[0]+s[1]
 Sの中に"000","111","00?11","11?00"が含まれていたらNo
*/
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		s=s+s[0]+s[1];
		if(s.find("000")!=string::npos){
			cout<<NO<<endl;
		}else if(s.find("111")!=string::npos){
			cout<<NO<<endl;
		}else if(s.find("00?11")!=string::npos){
			cout<<NO<<endl;
		}else if(s.find("11?00")!=string::npos){
			cout<<NO<<endl;
		}else{
			cout<<YES<<endl;
		}
	}
	return 0;
}
0