結果

問題 No.1900 Don't be Powers of 2
ユーザー 37zigen37zigen
提出日時 2022-02-24 22:40:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 91,304 KB
実行使用メモリ 35,620 KB
最終ジャッジ日時 2023-09-25 14:18:31
合計ジャッジ時間 9,106 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 305 ms
4,376 KB
testcase_04 AC 302 ms
4,376 KB
testcase_05 AC 311 ms
4,376 KB
testcase_06 AC 306 ms
4,380 KB
testcase_07 AC 305 ms
4,380 KB
testcase_08 AC 46 ms
4,376 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 65 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 205 ms
4,380 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 278 ms
4,376 KB
testcase_18 AC 228 ms
4,380 KB
testcase_19 AC 303 ms
4,380 KB
testcase_20 AC 211 ms
4,380 KB
testcase_21 AC 201 ms
4,380 KB
testcase_22 AC 190 ms
4,376 KB
testcase_23 AC 171 ms
4,376 KB
testcase_24 AC 171 ms
4,380 KB
testcase_25 AC 212 ms
4,380 KB
testcase_26 AC 302 ms
35,092 KB
testcase_27 AC 93 ms
8,600 KB
testcase_28 AC 90 ms
4,376 KB
testcase_29 AC 83 ms
4,376 KB
testcase_30 AC 7 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 314 ms
35,620 KB
testcase_34 AC 309 ms
35,192 KB
testcase_35 AC 297 ms
35,220 KB
testcase_36 AC 310 ms
34,728 KB
testcase_37 AC 120 ms
4,380 KB
testcase_38 AC 47 ms
13,096 KB
testcase_39 AC 34 ms
6,544 KB
testcase_40 AC 301 ms
4,380 KB
testcase_41 AC 302 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/maxflow>
#include <iostream>

using namespace std;
using namespace atcoder;

int popcount(int a) {
	if (a == 0) return 0;
	return popcount(a / 2) + a % 2;
}

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    
    mf_graph<int> g(n + 2);
    int s = n;
	int t = n + 1;

    for (int i = 0; i < n; ++i) {
    	for (int j = 0; j < n; ++j) {
    		if (popcount(a[i]) % 2 == 0 && popcount(a[j]) % 2 == 1 && popcount(a[i] ^ a[j]) ==1) {
    			g.add_edge(i, j, 1);	
    		}
    	}
    }
	
	for (int i = 0; i < n; ++i) if (popcount(a[i]) % 2 == 0) g.add_edge(s, i, 1);
	for (int i = 0; i < n; ++i) if (popcount(a[i]) % 2 == 1) g.add_edge(i, t, 1);

	cout << n-g.flow(s, t) << endl;
    return 0;
}
0