結果
問題 | No.130 XOR Minimax |
ユーザー | bal4u |
提出日時 | 2019-08-07 11:24:48 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 144 ms / 5,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 405 ms |
コンパイル使用メモリ | 29,860 KB |
実行使用メモリ | 99,752 KB |
最終ジャッジ日時 | 2023-10-10 00:24:35 |
合計ジャッジ時間 | 2,630 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
43,868 KB |
testcase_01 | AC | 0 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,372 KB |
testcase_03 | AC | 0 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,352 KB |
testcase_05 | AC | 14 ms
14,076 KB |
testcase_06 | AC | 19 ms
17,388 KB |
testcase_07 | AC | 25 ms
22,584 KB |
testcase_08 | AC | 144 ms
99,752 KB |
testcase_09 | AC | 8 ms
5,656 KB |
testcase_10 | AC | 10 ms
7,148 KB |
testcase_11 | AC | 24 ms
15,092 KB |
testcase_12 | AC | 4 ms
4,348 KB |
testcase_13 | AC | 21 ms
13,140 KB |
testcase_14 | AC | 125 ms
80,772 KB |
testcase_15 | AC | 2 ms
4,352 KB |
testcase_16 | AC | 90 ms
58,400 KB |
testcase_17 | AC | 94 ms
60,588 KB |
testcase_18 | AC | 102 ms
64,808 KB |
testcase_19 | AC | 120 ms
75,888 KB |
testcase_20 | AC | 60 ms
39,472 KB |
testcase_21 | AC | 124 ms
79,948 KB |
testcase_22 | AC | 29 ms
20,008 KB |
testcase_23 | AC | 10 ms
7,444 KB |
コンパイルメッセージ
main.c: 関数 ‘in’ 内: main.c:8:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 8 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:14:24: 備考: in expansion of macro ‘gc’ 14 | int n = 0, c = gc(); | ^~
ソースコード
// yukicoder: No.130 XOR Minimax // 2019.8.7 bal4u #include <stdio.h> #include <stdlib.h> #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int a[100005]; int calc(int sz, int *a, int b) { int *u, *v, wu, wv, i, ans; if (b < 0) return 0; u = malloc(sizeof(int)*sz), v = malloc(sizeof(int)*sz); wu = wv = 0; for (i = 0; i < sz; i++) { if ((a[i] >> b) & 1) u[wu++] = a[i]; else v[wv++] = a[i]; } if (wu == 0 || wv == 0) ans = calc(sz, a, b-1); else { ans = calc(wu, u, b-1); int t = calc(wv, v, b-1); if (t < ans) ans = t; ans |= 1<<b; } return ans; } int main() { int i, N, ma; N = in(); if (N == 1) { puts("0"); return 0; } ma = 0; for (i = 0; i < N; i++) { a[i] = in(); if (a[i] > ma) ma = a[i]; } i = -1; while (ma) ma >>= 1, i++; printf("%d\n", calc(N, a, i)); return 0; }