QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#286137#7942. $K$ Subsequencesucup-team008#WA 9ms8956kbPython3572b2023-12-17 03:46:272023-12-17 03:46:27

Judging History

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

  • [2023-12-17 03:46:27]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:8956kb
  • [2023-12-17 03:46:27]
  • 提交

answer

import sys
input = sys.stdin.readline

def solve():
  n, k = (int(x) for x in input().split())
  lhs = [str(i+1) for i in range(k)]
  rhs = []
  l = [int(x) for x in input().split()]
  ret = []
  for y in l:
    if y == 1:
      if not lhs:
        lhs, rhs = rhs, lhs
      rhs.append(lhs.pop())
      ret.append(rhs[-1])
    else:
      if not rhs:
        lhs, rhs = rhs, lhs
      lhs.append(rhs.pop())
      ret.append(lhs[-1])        
  return " ".join(ret)

ret = []
for _ in range(int(input())):
  ret.append(solve())
print("\n".join(ret))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 8956kb

input:

5
3 2
1 -1 1
4 2
-1 1 1 -1
7 3
1 1 1 1 1 1 1
10 3
1 1 1 1 -1 -1 1 1 1 1
12 4
1 1 1 1 -1 -1 -1 -1 1 1 1 1

output:

2 2 2
2 2 2 2
3 2 1 1 2 3 3
3 2 1 1 1 1 1 1 2 3
4 3 2 1 1 2 3 4 4 3 2 1

result:

wrong answer Jury found better answer than participant (test case 2)