QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#742357 | #3136. The Spectrum | vwxyz# | WA | 15ms | 10664kb | Python3 | 851b | 2024-11-13 16:26:49 | 2024-11-13 16:26:51 |
Judging History
answer
N=int(input())
A=list(map(int,input().split()))
M=1000
cnt=[0]*M
for a in A:
cnt[a]+=1
l,r=0,max(A)
def solve(X,cnt):
if max(cnt)==0:
retu=[X]
else:
retu=[]
for d in range(M-1,-1,-1):
if cnt[d]:
for y in (d,r-d):
cnt_=cnt[:]
ok=True
for x in X:
cnt_[abs(x-y)]-=1
if cnt_[abs(x-y)]<0:
ok=False
if ok:
retu+=solve(X+[y],cnt_)
break
return retu
cnt[r-l]-=1
ans_lst=solve([l,r],cnt)
le=len(ans_lst)
for i in range(le):
ans_lst[i].sort()
ans_lst[i]=tuple(ans_lst[i])
ans_lst=set(ans_lst)
le=len(ans_lst)
print(le)
for tpl in ans_lst:
print(*tpl)
详细
Test #1:
score: 100
Accepted
time: 15ms
memory: 10584kb
input:
4 2 2 2 4 4 6
output:
1 0 2 4 6
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 15ms
memory: 10628kb
input:
5 3 3 6 9 9 12 12 15 18 21
output:
2 0 3 12 15 21 0 6 9 18 21
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 15ms
memory: 10624kb
input:
4 5 6 7 8 9 10
output:
0
result:
ok single line: '0'
Test #4:
score: -100
Wrong Answer
time: 15ms
memory: 10664kb
input:
9 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 5 5 6 6 7 7 8 8 8 9 9 10 10 11 11 12 12 12 13 14 15
output:
4 0 1 3 4 5 7 12 13 15 0 1 3 8 9 11 12 13 15 0 2 3 8 10 11 12 14 15 0 2 3 4 6 7 12 14 15
result:
wrong answer 4th lines differ - expected: '0 2 3 4 6 7 12 14 15', found: '0 2 3 8 10 11 12 14 15'