QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86597 | #4800. Oscar's Round Must Have a Constructive Problem | mthaneka | TL | 13ms | 8092kb | Python3 | 638b | 2023-03-10 11:19:57 | 2023-03-10 11:20:00 |
Judging History
answer
def r(l: list, A: list, used: set):
n = len(A)
if len(used) == n:
return l
i = len(l)
for num in range(1, n + 1):
if num != A[i] and num not in used:
l.append(num)
used.add(num)
result = r(l, A, used)
if result:
return result
l.pop()
used.remove(num)
return False
T = int(input())
for _ in range(T):
n = int(input())
A = list(map(int, input().split()))
used = set()
result = r([], A, used)
if result:
print("YES")
print(' '.join(map(str, result)))
else:
print("NO")
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 13ms
memory: 8092kb
input:
3 3 3 3 3 3 3 2 1 6 1 1 4 5 1 4
output:
NO YES 1 3 2 YES 2 3 1 4 5 6
result:
ok ok
Test #2:
score: -100
Time Limit Exceeded
input:
50069 1 1 2 1 1 2 1 2 2 2 1 2 2 2 3 1 1 1 3 1 1 2 3 1 1 3 3 1 2 1 3 1 2 2 3 1 2 3 3 1 3 1 3 1 3 2 3 1 3 3 3 2 1 1 3 2 1 2 3 2 1 3 3 2 2 1 3 2 2 2 3 2 2 3 3 2 3 1 3 2 3 2 3 2 3 3 3 3 1 1 3 3 1 2 3 3 1 3 3 3 2 1 3 3 2 2 3 3 2 3 3 3 3 1 3 3 3 2 3 3 3 3 4 1 1 1 1 4 1 1 1 2 4 1 1 1 3 4 1 1 1 4 4 1 1 2 1 ...
output:
NO NO YES 2 1 YES 1 2 NO NO YES 2 3 1 YES 2 3 1 YES 2 1 3 YES 2 1 3 YES 2 3 1 YES 2 1 3 YES 2 1 3 YES 3 1 2 YES 1 2 3 YES 1 2 3 YES 1 3 2 YES 1 3 2 NO YES 1 3 2 YES 1 2 3 YES 1 2 3 YES 3 1 2 YES 1 2 3 YES 1 2 3 YES 1 3 2 YES 1 3 2 YES 2 1 3 YES 1 3 2 YES 1 2 3 YES 1 2 3 NO NO YES 2 3 4 1 YES 2 3 4 1...