QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#420671 | #6569. Splitting Pairs | fishy15 | WA | 61ms | 10908kb | Python3 | 1.4kb | 2024-05-24 21:03:22 | 2024-05-24 21:03:23 |
Judging History
answer
from itertools import combinations
from functools import lru_cache
def all_rems(lst, sz):
n = len(lst)
for idxs in combinations(range(n), sz):
res = []
for i, x in enumerate(lst):
if i not in idxs:
res += [x]
yield res
def split(lst, idxs, cur_lst, idx):
if idx == len(lst):
yield cur_lst
else:
if idx in idxs:
for i in range(1, lst[idx] // 2 + 1):
yield from split(lst, idxs, cur_lst + [i, lst[idx] - i], idx+1)
else:
yield from split(lst, idxs, cur_lst + [lst[idx]], idx+1)
def all_splits(lst, sz):
n = len(lst)
for idxs in combinations(range(n), sz):
yield from split(lst, idxs, [], 0)
@lru_cache(maxsize=None)
def wins(lst):
n = len(lst)
for sz in range(1, n//2 + 1):
for after_rems in all_rems(lst, sz):
for after_splits in all_splits(after_rems, sz):
after_splits.sort()
if not wins(tuple(after_splits)):
return True
return False
def solve(lst):
if len(lst) % 2 == 1:
while all(x % 2 == 0 for x in lst):
for i in range(len(lst)):
lst[i] /= 2
if any(x % 2 == 0 for x in lst):
print("1")
else:
print("0")
for i in range(1, 30):
for j in range(i, 30):
for k in range(j, 30):
if not wins((i, j, k)):
print(i, j, k)
'''
t = int(input())
for _ in range(t):
n = int(input())
nums = list(map(int, input().split()))
solve(nums)
'''
詳細信息
Test #1:
score: 0
Wrong Answer
time: 61ms
memory: 10908kb
input:
4 3 1 1 1 3 1 1 2 3 2 2 2 4 4 4 4 4
output:
1 1 1 1 1 3 1 1 5 1 1 7 1 1 9 1 1 11 1 1 13 1 1 15 1 1 17 1 1 19 1 1 21 1 1 23 1 1 25 1 1 27 1 1 29 1 3 3 1 3 5 1 3 7 1 3 9 1 3 11 1 3 13 1 3 15 1 3 17 1 3 19 1 3 21 1 3 23 1 3 25 1 3 27 1 3 29 1 5 5 1 5 7 1 5 9 1 5 11 1 5 13 1 5 15 1 5 17 1 5 19 1 5 21 1 5 23 1 5 25 1 5 27 1 5 29 1 7 7 1 7 9 1 7 11...
result:
wrong answer 1st lines differ - expected: '0', found: '1 1 1'