結果

問題 No.5017 Tool-assisted Shooting
ユーザー とろちゃとろちゃ
提出日時 2023-07-16 18:26:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 3,838 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 96,304 KB
スコア 1,680,986
平均クエリ数 682.05
最終ジャッジ日時 2023-07-16 18:26:35
合計ジャッジ時間 25,988 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
94,340 KB
testcase_01 AC 257 ms
94,208 KB
testcase_02 AC 247 ms
93,888 KB
testcase_03 AC 137 ms
92,328 KB
testcase_04 AC 151 ms
93,016 KB
testcase_05 AC 242 ms
94,156 KB
testcase_06 AC 247 ms
94,060 KB
testcase_07 AC 180 ms
93,368 KB
testcase_08 AC 141 ms
92,716 KB
testcase_09 AC 126 ms
92,456 KB
testcase_10 AC 142 ms
92,468 KB
testcase_11 AC 181 ms
93,152 KB
testcase_12 AC 180 ms
93,612 KB
testcase_13 AC 231 ms
94,124 KB
testcase_14 AC 242 ms
93,916 KB
testcase_15 AC 237 ms
94,236 KB
testcase_16 AC 242 ms
94,140 KB
testcase_17 AC 215 ms
93,516 KB
testcase_18 AC 242 ms
93,772 KB
testcase_19 AC 175 ms
93,676 KB
testcase_20 AC 235 ms
93,968 KB
testcase_21 AC 239 ms
93,996 KB
testcase_22 AC 240 ms
93,868 KB
testcase_23 AC 202 ms
93,472 KB
testcase_24 AC 137 ms
92,672 KB
testcase_25 AC 187 ms
93,468 KB
testcase_26 AC 244 ms
94,076 KB
testcase_27 AC 213 ms
93,724 KB
testcase_28 AC 240 ms
93,900 KB
testcase_29 AC 240 ms
94,168 KB
testcase_30 AC 117 ms
92,708 KB
testcase_31 AC 134 ms
92,776 KB
testcase_32 AC 133 ms
92,108 KB
testcase_33 AC 198 ms
93,588 KB
testcase_34 AC 117 ms
92,276 KB
testcase_35 AC 136 ms
92,664 KB
testcase_36 AC 167 ms
93,348 KB
testcase_37 AC 244 ms
93,484 KB
testcase_38 AC 152 ms
93,564 KB
testcase_39 AC 244 ms
94,284 KB
testcase_40 AC 249 ms
93,808 KB
testcase_41 AC 233 ms
94,172 KB
testcase_42 AC 235 ms
94,176 KB
testcase_43 AC 141 ms
92,292 KB
testcase_44 AC 239 ms
93,828 KB
testcase_45 AC 198 ms
94,064 KB
testcase_46 AC 223 ms
93,824 KB
testcase_47 AC 207 ms
93,464 KB
testcase_48 AC 236 ms
94,216 KB
testcase_49 AC 245 ms
93,568 KB
testcase_50 AC 243 ms
94,128 KB
testcase_51 AC 176 ms
93,516 KB
testcase_52 AC 116 ms
92,228 KB
testcase_53 AC 189 ms
94,212 KB
testcase_54 AC 126 ms
92,980 KB
testcase_55 AC 241 ms
94,580 KB
testcase_56 AC 148 ms
92,812 KB
testcase_57 AC 187 ms
93,744 KB
testcase_58 AC 238 ms
93,800 KB
testcase_59 AC 138 ms
92,640 KB
testcase_60 AC 121 ms
92,816 KB
testcase_61 AC 240 ms
93,900 KB
testcase_62 AC 240 ms
93,808 KB
testcase_63 AC 246 ms
94,008 KB
testcase_64 AC 244 ms
93,892 KB
testcase_65 AC 265 ms
96,304 KB
testcase_66 AC 236 ms
93,856 KB
testcase_67 AC 237 ms
93,756 KB
testcase_68 AC 130 ms
92,152 KB
testcase_69 AC 209 ms
93,292 KB
testcase_70 AC 240 ms
93,384 KB
testcase_71 AC 124 ms
92,200 KB
testcase_72 AC 200 ms
94,004 KB
testcase_73 AC 119 ms
92,832 KB
testcase_74 AC 131 ms
92,364 KB
testcase_75 AC 187 ms
93,636 KB
testcase_76 AC 240 ms
93,920 KB
testcase_77 AC 241 ms
93,900 KB
testcase_78 AC 122 ms
93,064 KB
testcase_79 AC 241 ms
93,836 KB
testcase_80 AC 176 ms
93,496 KB
testcase_81 AC 245 ms
93,544 KB
testcase_82 AC 241 ms
94,248 KB
testcase_83 AC 229 ms
93,584 KB
testcase_84 AC 224 ms
93,972 KB
testcase_85 AC 199 ms
93,704 KB
testcase_86 AC 170 ms
93,264 KB
testcase_87 AC 140 ms
92,428 KB
testcase_88 AC 219 ms
93,932 KB
testcase_89 AC 238 ms
94,380 KB
testcase_90 AC 174 ms
93,812 KB
testcase_91 AC 145 ms
92,772 KB
testcase_92 AC 244 ms
94,060 KB
testcase_93 AC 241 ms
94,380 KB
testcase_94 AC 213 ms
93,892 KB
testcase_95 AC 241 ms
94,000 KB
testcase_96 AC 153 ms
93,492 KB
testcase_97 AC 234 ms
93,844 KB
testcase_98 AC 135 ms
92,368 KB
testcase_99 AC 214 ms
93,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
# from bisect import *
# from collections import *
# from heapq import *
# from itertools import *
# from math import *
# from datetime import *
# from decimal import *  # PyPyだと遅い
# from string import ascii_lowercase, ascii_uppercase
# import numpy as np
import sys
import os

# sys.setrecursionlimit(10**6)  # PyPyだと遅い
INF = 10**18
MOD = 998244353
# MOD = 10**9 + 7
isTest = os.path.exists("input.txt")
File = open("input.txt", "r") if isTest else sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////

if isTest:
    P = list(map(int, input().split()))
    outFile = open("output.txt", "w")


# 盤面を動かす関数
def moveGrid(grid):
    for i in range(1, 60):
        for j in range(25):
            grid[i - 1][j] = grid[i][j]
            if i == 59:
                grid[i][j] = (0, 0, 0)


# 敵までの距離を求める関数
def distance(grid, now):
    if not 0 <= now <= 24:
        return -1
    for i in range(60):
        if grid[i][now][0]:
            return i
    return -1


# 列で得られるポイントを求める関数
def totalPoint(grid, idx, start):
    if not 0 <= idx <= 24:
        return -1

    total = 0
    dist = start
    for i in range(start, 60):
        if grid[i][idx][0]:
            if grid[i][idx][0] > (i - dist) * (total_power // 100 + 1):
                break
            dist = i
            total += grid[i][idx][2]
    if i == 0:
        return -2
    else:
        return total


you = 12
move = ["S", "R", "L"]
score = 0
turn = 0
total_power = 0
grid = [[(0, 0, 0) for _ in range(25)] for _ in range(60)]
one = 1
while True:
    n = int(input())
    if n == -1:
        break
    enemy = [list(map(int, input().split())) for _ in range(n)]
    moveGrid(grid)
    for h, p, x in enemy:
        grid[59][x] = (h, p, h)

    ans = 0
    plans = [-1] * 5
    plans[2] = totalPoint(grid, you, 0)
    plans[1] = totalPoint(grid, you - 1, 0)
    plans[3] = totalPoint(grid, you + 1, 0)
    if plans[1] != -2:
        plans[0] = totalPoint(grid, you - 2, 1)
    if plans[3] != -2:
        plans[4] = totalPoint(grid, you + 2, 1)
    if sum([i for i in [plans[2], plans[1], plans[3]] if i != -1]) == 0:
        if you == 0:
            one = 1
        elif you == 24:
            one = -1
        ans = one
        if one == 1:
            dist = distance(grid, you + 1)
        else:
            dist = distance(grid, you - 1)
    elif plans[2] == 0:
        if plans[1] == -2 and plans[3] == -2:
            ans = 0
            dist = distance(grid, you)
        elif plans[1] > plans[3]:
            ans = -1
            dist = distance(grid, you - 1)
        else:
            ans = 1
            dist = distance(grid, you + 1)
    else:
        if plans[2] >= plans[1] and plans[2] >= plans[3]:
            ans = 0
            dist = distance(grid, you)
        elif plans[1] >= plans[2] and plans[1] >= plans[3]:
            ans = -1
            dist = distance(grid, you - 1)
        elif plans[3] >= plans[2] and plans[3] >= plans[1]:
            ans = 1
            dist = distance(grid, you + 1)

    you = you + ans

    if dist != -1:
        grid[dist][you] = (
            grid[dist][you][0] - (total_power // 100 + 1),
            grid[dist][you][1],
            grid[dist][you][2],
        )
        if grid[dist][you][0] <= 0:
            score += grid[dist][you][2]
            total_power += grid[dist][you][1]
            grid[dist][you] = (0, 0, 0)

    if isTest:
        outFile.write(move[ans] + "\n")
        outFile.write("#" + " ".join([str(i) for i in plans]) + "\n")
    else:
        print(move[ans], flush=True)

    turn += 1
    if turn == 1000:
        break

if isTest:
    outFile.close()
0