結果
問題 | No.1246 ANDORゲーム(max) |
ユーザー | mkawa2 |
提出日時 | 2024-06-27 16:04:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,276 ms / 2,000 ms |
コード長 | 2,295 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,844 KB |
実行使用メモリ | 90,932 KB |
最終ジャッジ日時 | 2024-06-27 16:05:06 |
合計ジャッジ時間 | 18,257 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
55,936 KB |
testcase_01 | AC | 46 ms
55,808 KB |
testcase_02 | AC | 47 ms
55,680 KB |
testcase_03 | AC | 47 ms
55,936 KB |
testcase_04 | AC | 46 ms
56,064 KB |
testcase_05 | AC | 53 ms
56,960 KB |
testcase_06 | AC | 48 ms
56,320 KB |
testcase_07 | AC | 47 ms
56,448 KB |
testcase_08 | AC | 48 ms
56,576 KB |
testcase_09 | AC | 47 ms
55,808 KB |
testcase_10 | AC | 47 ms
55,424 KB |
testcase_11 | AC | 249 ms
79,580 KB |
testcase_12 | AC | 162 ms
78,080 KB |
testcase_13 | AC | 186 ms
78,720 KB |
testcase_14 | AC | 236 ms
79,568 KB |
testcase_15 | AC | 235 ms
79,616 KB |
testcase_16 | AC | 1,064 ms
90,496 KB |
testcase_17 | AC | 1,276 ms
90,932 KB |
testcase_18 | AC | 1,075 ms
90,880 KB |
testcase_19 | AC | 1,058 ms
90,496 KB |
testcase_20 | AC | 1,045 ms
90,752 KB |
testcase_21 | AC | 1,013 ms
90,752 KB |
testcase_22 | AC | 1,069 ms
90,624 KB |
testcase_23 | AC | 175 ms
90,308 KB |
testcase_24 | AC | 917 ms
90,112 KB |
testcase_25 | AC | 951 ms
90,496 KB |
testcase_26 | AC | 884 ms
90,240 KB |
testcase_27 | AC | 237 ms
89,984 KB |
testcase_28 | AC | 956 ms
90,880 KB |
testcase_29 | AC | 881 ms
90,880 KB |
testcase_30 | AC | 928 ms
90,624 KB |
testcase_31 | AC | 329 ms
89,636 KB |
testcase_32 | AC | 339 ms
89,344 KB |
testcase_33 | AC | 331 ms
89,472 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 from collections import defaultdict from random import randrange class Defaultdict(defaultdict): def __init__(self, df): super().__init__(df) self.x = randrange(1 << 31) def __setitem__(self, key, value): super().__setitem__(key ^ self.x, value) def __getitem__(self, item): return super().__getitem__(item ^ self.x) def __missing__(self, key): return super().__missing__(key ^ self.x) def __iter__(self): for a in super().__iter__(): yield a ^ self.x def __contains__(self, item): return super().__contains__(item ^ self.x) def __delitem__(self, key): super().__delitem__(key ^ self.x) def items(self): return [(k ^ self.x, v) for k, v in super().items()] class Set(set): def __init__(self): super().__init__() self.x = randrange(1 << 31) def add(self, a): super().add(a ^ self.x) def pop(self): return super().pop() ^ self.x def remove(self, a): super().remove(a ^ self.x) def discard(self, a): super().discard(a ^ self.x) def __contains__(self, item): return super().__contains__(item ^ self.x) def __iter__(self): for a in super().__iter__(): yield a ^ self.x def chmax(t, nt): ndp[nt] = max(ndp[nt], dp[t]+abs(nt-t)) n, t = LI() aa = LI() dp = Defaultdict(int) dp[t] = 0 for a in aa: ndp = Defaultdict(int) for t in dp: chmax(t,t|a) chmax(t,t&a) dp=ndp print(max(dp.values()))