QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#90103 | #5563. K.O. Kids | ChatGPT | WA | 21ms | 7972kb | Python3 | 1002b | 2023-03-22 13:17:24 | 2023-03-22 13:17:26 |
Judging History
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'