結果

問題 No.3823 Make 1
コンテスト
ユーザー okkuu
提出日時 2026-11-20 18:34:03
言語 C++23(gnu拡張gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=gnu++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 207 ms / 2,000 ms
+ 545µs
コード長 1,306 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,880 ms
コンパイル使用メモリ 400,444 KB
実行使用メモリ 9,860 KB
最終ジャッジ日時 2026-11-22 12:44:42
合計ジャッジ時間 6,701 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

//*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//*/
#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
/*
#include<atcoder/all>
using namespace atcoder;
using mint=modint998244353;
using Mint=modint1000000007;
//*/
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using P=pair<int,int>;
using Pl=pair<ll,ll>;
constexpr int mod=998244353;
constexpr int Mod=1e9+7;
constexpr int inf=Mod;
constexpr ll linf=(ll)inf*inf;
constexpr int dx[]={1,0,0,-1},dy[]={0,1,-1,0};
constexpr int Dx[]={1,1,1,0,0,-1,-1,-1},Dy[]={1,0,-1,1,-1,1,0,-1};
struct initio{
	initio(){
		cin.tie(0)->sync_with_stdio(0);
		cout<<fixed<<setprecision(20);
	};
}iio;
template<class T>
bool chmax(T&a,const T&b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a,const T&b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}
int fl2(ll n){
	return 63-__builtin_clzll(n);
}
int main(){
	int t,n;
	string s;
	cin>>t;
	while(cin>>n>>s){
		int cnt=count(s.begin(),s.end(),'1');
		if(cnt%3!=(2*n-1)%3){
			cout<<"No"<<endl;
			continue;
		}
		if(n==1){
			cout<<"Yes"<<endl;
			continue;
		}
		bool ok=0;
		for(int i=0;i<n-1;i++)
			if(s[i]==s[i+1])
				ok=1;
		cout<<(ok?"Yes":"No")<<endl;
	}
}
0