QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#420674 | #6569. Splitting Pairs | fishy15 | AC ✓ | 137ms | 10816kb | Python3 | 1.4kb | 2024-05-24 21:03:59 | 2024-05-24 21:04:00 |
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)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 10704kb
input:
4 3 1 1 1 3 1 1 2 3 2 2 2 4 4 4 4 4
output:
0 1 0 1
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 21ms
memory: 10748kb
input:
1000 10 16 16 16 16 16 16 16 16 16 16 10 16 16 16 16 16 16 16 16 17 16 10 16 16 16 16 16 16 16 18 16 16 10 16 16 16 19 16 16 16 16 16 16 10 16 16 16 16 20 16 16 16 16 16 10 17 16 16 16 17 16 16 16 16 16 10 16 16 16 16 16 16 16 16 18 17 10 16 16 19 16 16 16 16 17 16 16 10 17 16 16 16 16 16 16 20 16 1...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000 lines
Test #3:
score: 0
Accepted
time: 16ms
memory: 10816kb
input:
1000 2 4 4 2 5 4 2 4 6 2 7 4 2 4 8 2 5 5 2 6 5 2 7 5 2 8 5 2 6 6 2 7 6 2 8 6 2 7 7 2 7 8 2 8 8 3 4 4 4 3 4 5 4 3 4 4 6 3 4 7 4 3 8 4 4 3 4 5 5 3 6 4 5 3 4 5 7 3 8 5 4 3 6 4 6 3 7 4 6 3 8 4 6 3 4 7 7 3 7 8 4 3 8 8 4 3 5 5 5 3 5 6 5 3 5 5 7 3 5 8 5 3 6 5 6 3 6 7 5 3 6 5 8 3 7 7 5 3 8 5 7 3 5 8 8 3 6 6...
output:
1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000 lines
Test #4:
score: 0
Accepted
time: 16ms
memory: 10656kb
input:
1000 3 4 4 4 3 4 5 4 3 4 6 4 3 4 7 4 3 4 4 8 3 5 4 5 3 4 5 6 3 5 4 7 3 4 8 5 3 4 6 6 3 6 4 7 3 6 4 8 3 7 7 4 3 4 7 8 3 8 4 8 3 5 5 5 3 5 6 5 3 5 7 5 3 5 8 5 3 6 5 6 3 7 5 6 3 8 6 5 3 7 7 5 3 7 5 8 3 8 8 5 3 6 6 6 3 6 7 6 3 8 6 6 3 7 7 6 3 6 8 7 3 8 6 8 3 7 7 7 3 7 7 8 3 8 8 7 3 8 8 8 5 4 4 4 4 4 5 4...
output:
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 ...
result:
ok 1000 lines
Test #5:
score: 0
Accepted
time: 129ms
memory: 10656kb
input:
1000 49 70984400896 988463235072 689895899136 448069107712 139972313088 432801841152 571884961792 572723822592 147287179264 253252075520 941688356864 914542821376 100344528896 317945020416 796062121984 504306335744 30417092608 36054237184 652314935296 547994206208 335393325056 959203770368 824583389...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000 lines
Test #6:
score: 0
Accepted
time: 137ms
memory: 10648kb
input:
1000 49 70492821504 404687910912 805429737472 657584551936 442074908672 204355868672 763966863360 396972795904 831477815296 928168810496 299311560704 748747630592 727295735808 22145292288 324382889984 95878944768 714705733632 301275334656 282344843264 158970316800 536299845632 89674733568 3273064878...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 1000 lines
Test #7:
score: 0
Accepted
time: 20ms
memory: 10632kb
input:
1000 50 831747260416 348831875072 22145925120 740210769920 728399609856 59458453504 476607152128 683034017792 993076969472 614046105600 326820167680 485197086720 157168959488 490297360384 651627069440 187770601472 746384785408 685986807808 665585713152 562238062592 459158847488 173543522304 65296924...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 ...
result:
ok 1000 lines