結果

問題 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
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

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()
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0