QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#90100#5563. K.O. KidsChatGPTWA 13ms8028kbPython3930b2023-03-22 13:15:592023-03-22 13:16:03

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:16:03]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:8028kb
  • [2023-03-22 13:15:59]
  • 提交

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
    if state[-1] != s[-1]:
        cnt -= 1

print(cnt)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 8028kb

input:

3 5
LRL

output:

5

result:

ok single line: '5'

Test #2:

score: -100
Wrong Answer
time: 13ms
memory: 7936kb

input:

3 2
RRR

output:

1

result:

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