結果

問題 No.2283 Prohibit Three Consecutive
ユーザー anonymouslyanonymously
提出日時 2023-04-28 22:21:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 592 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 169,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:51:50
合計ジャッジ時間 2,509 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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%n]+s[2%n]+s[3%n];
		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