QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90103#5563. K.O. KidsChatGPTWA 21ms7972kbPython31002b2023-03-22 13:17:242023-03-22 13:17:26

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-22 13:17:26]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:7972kb
  • [2023-03-22 13:17:24]
  • 提交

answer

n, k = map(int, input().split())
s = input()

# start with all kids making it to the other side
cnt = k

# current state of the bridge, initially all plates are unknown
state = ['U'] * n

# first player always chooses left at first step
state[0] = 'L'

# simulate the game for all players
for i in range(1, k):
    # copy the current state
    prev_state = state.copy()

    # follow the correct choices as far as they are known
    for j in range(n):
        if s[j] == prev_state[j]:
            state[j] = prev_state[j]
        else:
            state[j] = 'U'
            break

    # apply the switching strategy
    for j in range(n):
        if state[j] == 'U':
            if prev_state[j] == 'L':
                state[j] = 'R'
            else:
                state[j] = 'L'

    # check if the player falls at the last step or all plates are fake/real
    if state[-1] != s[-1] or (s.count('L') == 0 or s.count('R') == 0):
        cnt -= 1

print(cnt)

詳細信息

Test #1:

score: 100
Accepted
time: 21ms
memory: 7936kb

input:

3 5
LRL

output:

5

result:

ok single line: '5'

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 7972kb

input:

3 2
RRR

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'