結果

問題 No.5017 Tool-assisted Shooting
ユーザー netyo715netyo715
提出日時 2023-07-16 15:27:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 1,731 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 98,068 KB
スコア 26,993
平均クエリ数 151.93
最終ジャッジ日時 2023-07-16 15:28:19
合計ジャッジ時間 24,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from random import randint
H = 60
W = 25
board = deque([[[-1, -1] for _ in range(W)] for _ in range(H)])
level = 1
power = 0
jiki_w = 12
def min_dist(w1, w2):
    if w1 == w2:
        return 0, 0
    if w1 < w2:
        if w2-w1 <= 12:
            return w2-w1, 1
        else:
            return 25-(w2-w1), 2
    if w1 > w2:
        if w1-w2 <= 12:
            return w1-w2, 2
        else:
            return 25-(w1-w2), 1
    return -1, -1
for turn in range(1000):
    board.popleft()
    board.append([[-1, -1] for _ in range(W)])
    
    N = int(input())
    if N==-1:
        exit()
    for _ in range(N):
        h, p, x = map(int, input().split())
        board[59][x] = [h, p]
    
    next_w_dif = 30
    next_w = randint(0, W-1)
    for w in range(W):
        for h in range(H):
            hp, pow = board[h][w]
            if hp == -1:
                continue
            dist, d = min_dist(jiki_w, w)
            a_turn = h-dist
            if a_turn <= 0:
                continue
            if a_turn*level < hp:
                continue
            if dist < next_w_dif:
                next_w_dif = dist
                next_w = w

    dist, d = min_dist(jiki_w, next_w)
    if d==1 and board[0][(jiki_w+1)%W][0] == -1:
        print("R")
        jiki_w += 1
    elif d==2 and board[0][(jiki_w-1)%W][0] == -1:
        print("L")
        jiki_w -= 1
    else:
        print("S")

    jiki_w %= W

    for h in range(H):
        if board[h][jiki_w][0] == -1:
            continue
        board[h][jiki_w][0] -= level
        if board[h][jiki_w][0] <= 0:
            power += board[h][jiki_w][1]
            level = 1+power//100
            board[h][jiki_w] = [-1, -1]
        break
0