QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#86595#4800. Oscar's Round Must Have a Constructive ProblemmthanekaWA 2ms8132kbPython3618b2023-03-10 11:17:102023-03-10 11:17:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-10 11:17:13]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8132kb
  • [2023-03-10 11:17:10]
  • 提交

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(result)
   else:
      print("NO")

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 8132kb

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:

wrong output format Expected integer, but "[1," found