結果

問題 No.2343 (l+r)/2
ユーザー 沙耶花沙耶花
提出日時 2023-06-09 21:29:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 1,434 bytes
コンパイル時間 4,460 ms
コンパイル使用メモリ 263,012 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 12:54:53
合計ジャッジ時間 5,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 322 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 44 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 11 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 10 ms
4,384 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

bool check(vector<double> a){
	if(a.size()==1)return abs(a[0]-0.5)<1e-10;
	rep(i,a.size()-1){
		auto b = a;
		b.erase(b.begin()+i,b.begin()+i+2);
		b.insert(b.begin()+i,(a[i] + a[i+1])/2.0);
		if(check(b))return true;
	}
	return false;
}

bool sol(vector<int> a){
	int c = 0;
	int n  =a.size();
	//if(n>=10)return true;
	rep(i,n-1){
		if(a[i]!=a[i+1])c++;
	}
	
	if(c%2==1 || c>=8){
		return true;
	}
	
	int t = a[0]^1;
	c = 0;
	rep(i,n-1){
		if(a[i]==t && a[i+1]==t){
			c = 1;
		}
	}
	if(c){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	
	int _t;
	cin>>_t;
	/*
	rep(i,1<<_t){
		vector<int> a(_t);
		vector<double> b(_t);
		rep(j,_t){
			if((i>>j)&1){
				a[j] = 1;
				b[j] = 1;
			}
			else{
				a[j] = 0;
				b[j] = 0;
			}
		}
		if(sol(a)!=check(b)){
			cout<<(bitset<10>(i))<<":"<<endl;
			cout<<sol(a)<<endl;
			cout<<check(b)<<endl;
		}
	}
	*/
	rep(_,_t){
		int n;
		cin>>n;
		vector<int> a(n);
		rep(i,n){
			scanf("%d",&a[i]);
		}
		//cout<<sol(a)<<','<<check(b)<<endl;
		if(sol(a))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		/*
		{
			vector<double> b(n);
			rep(i,n)b[i] = a[i];
			cout<<check(b)<<endl;
		}
		cout<<sol(a)<<endl;
		*/
		
	}
	
	return 0;
}
0