結果

問題 No.3823 Make 1
コンテスト
ユーザー Rho
提出日時 2026-11-08 04:38:38
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 230 ms / 2,000 ms
+ 262µs
コード長 1,692 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,920 ms
コンパイル使用メモリ 382,040 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-11-22 12:37:23
合計ジャッジ時間 4,704 ms
ジャッジサーバーID
(参考情報)
judge5_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/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ull=unsigned long long;
typedef pair<ll,ll> P;
#define vec vector
#define pb emplace_back
#define fs first
#define sc second
#define pcnt __builtin_popcountll
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rng(i,s,t) for(ll i=s;i<t;i++)
#define len(a) int((a).size())
#define all(a) a.begin(),a.end()
#define compress(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
constexpr ll INF=4e18;
constexpr ld EPS=1e-11;
template<typename T> bool inline chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool inline chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename itr> void printvec(itr begin, itr end) {
	for (itr p = begin; p < end; p++){
		if(p!=begin)cout<<" "; cout << *p;
	}
	cout << endl;
}
template <class T> T makevec(T value) {return value;}
template <class T, class... Args,
		std::enable_if_t<(sizeof...(Args) > 0), int> = 0>
auto makevec(std::size_t n, Args... args) {
	auto inner = makevec<T>(args...);
	return std::vector<decltype(inner)>(n, inner);
}

#include "atcoder/modint.hpp"
using namespace atcoder;
typedef modint998244353 mint;
const ll mod=998244353;

void solve(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n==1){
		if(s=="1")cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else{
		ll adj=0;
		rep(i,n-1)if(s[i]==s[i+1])adj=1;
		ll cost=0;
		rep(i,n){
			if(s[i]=='0')cost+=1;
			else cost+=2;
		}
		if(adj&&cost%3==2)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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