結果
問題 | No.130 XOR Minimax |
ユーザー | bal4u |
提出日時 | 2019-08-07 12:07:36 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,094 bytes |
コンパイル時間 | 316 ms |
コンパイル使用メモリ | 30,128 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2023-09-25 22:35:45 |
合計ジャッジ時間 | 2,291 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
7,268 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | WA | - |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 14 ms
14,108 KB |
testcase_06 | AC | 15 ms
14,216 KB |
testcase_07 | AC | 20 ms
19,456 KB |
testcase_08 | AC | 17 ms
14,680 KB |
testcase_09 | AC | 4 ms
4,376 KB |
testcase_10 | AC | 6 ms
4,708 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 16 ms
10,496 KB |
testcase_14 | AC | 21 ms
13,116 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 16 ms
9,916 KB |
testcase_18 | AC | 18 ms
10,676 KB |
testcase_19 | AC | 21 ms
12,388 KB |
testcase_20 | AC | 10 ms
6,724 KB |
testcase_21 | WA | - |
testcase_22 | AC | 5 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,380 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 || sz == 1) return 0; if (sz == 2) { return ((a[0] >> b) ^ (a[1] >> b))? 1<<b: 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) { // free(u), free(v); 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; // free(u), free(v); } 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; }