結果

問題 No.1900 Don't be Powers of 2
ユーザー publflpublfl
提出日時 2022-04-08 22:58:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 67,280 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-19 01:29:25
合計ジャッジ時間 4,286 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
#include <atcoder/maxflow>

std::vector<int> V[2010];
int color[2010];
void init(int k, int col)
{
	if(color[k]) return;
	color[k] = col;
	for(int i=0;i<V[k].size();i++) init(V[k][i],3-col);
}

std::vector< std::pair<int,int> > edge;
int x[2010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	
	for(int i=1;i<=a;i++)
	{
		for(int j=i+1;j<=a;j++)
		{
			int val = (x[i]^x[j]);
			while(val%2==0) val/=2;
			if(val==1)
			{
				V[i].push_back(j);
				V[j].push_back(i);
				edge.push_back(std::make_pair(i,j));
			}
		}
	}
	for(int i=1;i<=a;i++) init(i,1);
	
	atcoder::mf_graph<int> G(2*a+3);
	int source = 2*a+1, sink = 2*a+2;
	
	for(int i=1;i<=a;i++) G.add_edge(source,i,1);
	for(int i=1;i<=a;i++) G.add_edge(i+a,sink,1);
	
	for(int i=0;i<edge.size();i++)
	{
		int s = edge[i].first, t = edge[i].second;
		if(color[s]==2)
		{
			int temp = s;
			s = t;
			t = temp;
		}
		G.add_edge(s,a+t,1);
	}
	
	printf("%d",a-G.flow(source,sink));
}
0