結果

問題 No.2024 Xer
ユーザー publfl2publfl2
提出日時 2022-07-29 22:06:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,775 bytes
コンパイル時間 2,366 ms
コンパイル使用メモリ 57,608 KB
実行使用メモリ 15,380 KB
最終ジャッジ日時 2023-09-26 21:07:08
合計ジャッジ時間 4,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 93 ms
15,380 KB
testcase_08 AC 80 ms
7,540 KB
testcase_09 AC 32 ms
5,936 KB
testcase_10 AC 70 ms
6,004 KB
testcase_11 AC 31 ms
4,380 KB
testcase_12 AC 85 ms
5,008 KB
testcase_13 AC 52 ms
4,848 KB
testcase_14 AC 91 ms
6,008 KB
testcase_15 AC 38 ms
4,380 KB
testcase_16 AC 60 ms
5,252 KB
testcase_17 AC 33 ms
4,520 KB
testcase_18 AC 33 ms
4,380 KB
testcase_19 AC 84 ms
6,168 KB
testcase_20 AC 57 ms
5,044 KB
testcase_21 AC 101 ms
6,052 KB
testcase_22 AC 90 ms
6,244 KB
testcase_23 AC 92 ms
5,964 KB
testcase_24 AC 102 ms
6,012 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 3 ms
4,376 KB
testcase_32 AC 4 ms
4,500 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,376 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 4 ms
4,380 KB
testcase_45 AC 25 ms
5,320 KB
testcase_46 AC 7 ms
4,376 KB
testcase_47 AC 19 ms
4,376 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
#include <algorithm>

int b, control = 1;
int x[200010];
void func(int L, int R, int C)
{
	//printf("%d %d %d!!\n",L,R,C);
	if(L>R) return;
	if(C<0) return;
	
	std::vector<int> V1,V2;
	for(int i=L;i<=R;i++)
	{
		if(((x[i]>>C)&1)==1) V2.push_back(x[i]);
		else V1.push_back(x[i]);
	}
	
	if(((b>>C)&1)==0)
	{
		for(int i=L;i<L+V1.size();i++) x[i] = V1[i-L];
		for(int i=L+V1.size();i<=R;i++) x[i] = V2[i-L-(int)V1.size()];
		func(L,L+(int)V1.size()-1,C-1);
		func(L+(int)V1.size(),R,C-1);
	}
	else
	{
		if(V1.size()==V2.size()+1)
		{
			std::sort(V1.begin(),V1.end());
			std::sort(V2.begin(),V2.end());
			for(int i=0;i<V1.size();i++) x[L+2*i] = V1[i];
			for(int i=0;i<V2.size();i++) x[L+2*i+1] = V2[i];
		}
		else if(V2.size()==V1.size()+1)
		{
			std::sort(V1.begin(),V1.end());
			std::sort(V2.begin(),V2.end());
			for(int i=0;i<V2.size();i++) x[L+2*i] = V2[i];
			for(int i=0;i<V1.size();i++) x[L+2*i+1] = V1[i];
		}
		else if(V1.size()==V2.size())
		{
			std::sort(V1.begin(),V1.end());
			std::sort(V2.begin(),V2.end());
			for(int i=0;i<V1.size();i++) x[L+2*i] = V1[i];
			for(int i=0;i<V2.size();i++) x[L+2*i+1] = V2[i];
			int t = 1;
			for(int i=L;i<R;i++)
			{
				if(x[i] < (x[i+1]^b) && (x[i]^b) < x[i+1]);
				else
				{
					t = 0;
					break;
				}
			}
			if(t==0)
			{
				for(int i=0;i<V2.size();i++) x[L+2*i] = V2[i];
				for(int i=0;i<V1.size();i++) x[L+2*i+1] = V1[i];
			}
		}
		else
		{
			control = 0;
			return;
		}
	}
}
int main()
{
	int a;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	func(1,a,30);
	
	if(control==1)
	{
		for(int i=1;i<a;i++)
		{
			if(x[i] < (x[i+1]^b) && (x[i]^b) < x[i+1]);
			else
			{
				printf("No");
				return 0;
			}
		}
		printf("Yes");
	}
	else printf("No");
}
0