結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | すぎぱも(sugipamo) |
提出日時 | 2023-07-16 17:47:24 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,824 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 87,184 KB |
実行使用メモリ | 102,420 KB |
スコア | 0 |
最終ジャッジ日時 | 2023-07-16 17:47:31 |
合計ジャッジ時間 | 6,690 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
testcase_66 | -- | - |
testcase_67 | -- | - |
testcase_68 | -- | - |
testcase_69 | -- | - |
testcase_70 | -- | - |
testcase_71 | -- | - |
testcase_72 | -- | - |
testcase_73 | -- | - |
testcase_74 | -- | - |
testcase_75 | -- | - |
testcase_76 | -- | - |
testcase_77 | -- | - |
testcase_78 | -- | - |
testcase_79 | -- | - |
testcase_80 | -- | - |
testcase_81 | -- | - |
testcase_82 | -- | - |
testcase_83 | -- | - |
testcase_84 | -- | - |
testcase_85 | -- | - |
testcase_86 | -- | - |
testcase_87 | -- | - |
testcase_88 | -- | - |
testcase_89 | -- | - |
testcase_90 | -- | - |
testcase_91 | -- | - |
testcase_92 | -- | - |
testcase_93 | -- | - |
testcase_94 | -- | - |
testcase_95 | -- | - |
testcase_96 | -- | - |
testcase_97 | -- | - |
testcase_98 | -- | - |
testcase_99 | -- | - |
ソースコード
import time timer = time.perf_counter() output = [] class enemy(): def __init__(self, hp, power, pos): self.hp = hp + 1 self.power = power self.point = hp self.exp = power self.pos = [pos, 60] def move(self, p): self.pos[1] -= 1 if p.pos[0] == self.pos[0] and p.pos[1] == self.pos[1]: return False return True def state(self): print("HP:{} POWER:{} POS:{}".format(self.hp, self.power, self.pos)) class enemys(): def __init__(self): self.enemys = [] self.deleted = [] from collections import deque self.canattacks = [deque() for _ in range(25)] def states(self): for e in self.enemys: e.state() def expect_defeat_values(self, p): # ret = [] min_ = ([], 1 << 60) for i in range(25): if not self.canattacks[i]: continue i = self.canattacks[i][0] e = self.enemys[i] t = abs(p.pos[0] - e.pos[0]) + int(e.hp / p.level) if e.hp % p.level != 0: t += 1 t += 1 if t >= e.pos[1]: continue if min_[1] <= t: continue if p.pos[0] < e.pos[0]: que = [1] * (e.pos[0] - p.pos[0]) else: que = [-1] * (p.pos[0] - e.pos[0]) if e.pos[1] < len(que): continue isok = True pos = [p.pos[0], p.pos[1]] for d in que: pos[1] += 1 pos[0] += d if pos[0] < 0: pos[0] += 25 pos[0] = pos[0] % 25 for c in self.canattacks[pos[0]]: e_ = self.enemys[c] if abs(e_.pos[1] - pos[1]) <= 2: isok = False break if not isok: break if isok: min_ = (que, t) # ret.append((que, v)) return min_ def add(self, enemy): if self.deleted: i = self.deleted.pop() else: i = len(self.enemys) self.enemys.append([]) self.enemys[i] = enemy self.canattacks[enemy.pos[0]].append(i) def defeat(self, i): for j in range(25): if not self.canattacks[j]: continue if i == self.canattacks[j][0]: self.canattacks[j].popleft() self.deleted.append(i) return def move(self, p): delque = [] for canattack in self.canattacks: for i in canattack: e = self.enemys[i] b = e.move(p) if not b: return False if e.pos[1] < 1: delque.append(i) for i in delque: self.canattacks[self.enemys[i].pos[0]].popleft() self.deleted.append(i) return True class player(): def __init__(self): self.pos = [12, 0] self.level = 1 self.exp = 0 self.point = 0 def states(self): print("POS:{} LEVEL:{} EXP:{} POINT:{}".format( self.pos, self.level, self.exp, self.point)) def attack(self, enemys: enemys): if not enemys.canattacks[self.pos[0]]: return i = enemys.canattacks[self.pos[0]][0] e = enemys.enemys[i] e.hp -= self.level if e.hp <= 0: enemys.defeat(i) self.exp += e.exp self.level = 1 + int(self.exp / 100) self.point += e.point def move(self, dir, enemys: enemys): dstr = "S" if dir == -1: dstr = "L" if dir == 1: dstr = "R" output.append(dstr) self.pos[0] += dir if self.pos[0] < 0: self.pos[0] + 25 self.pos[0] = self.pos[0] % 25 if enemys.canattacks[self.pos[0]]: if enemys.enemys[enemys.canattacks[self.pos[0]][0]].pos[1] == 0: return False return True es = enemys() p = player() while len(output) < 1000: for i in range(int(input())): inp = input().split() if int(inp[0]) == -1: break es.add(enemy(*map(int, inp))) que, _ = es.expect_defeat_values(p) p.attack(es) m = 0 if que: m = que.pop() if not p.move(m, es): break if not es.move(p): break # es.states() # p.states() for o in output: print(o) # def text(output): # import os # os.remove("output.txt") # with open("output.txt", "w") as o: # for out in output: # print(out, file=o) # text(output)