結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | EvbCFfp1XB |
提出日時 | 2023-07-16 17:37:55 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 6,314 bytes |
コンパイル時間 | 2,540 ms |
コンパイル使用メモリ | 85,520 KB |
実行使用メモリ | 121,660 KB |
スコア | 13,367 |
平均クエリ数 | 357.38 |
最終ジャッジ日時 | 2023-07-16 17:38:09 |
合計ジャッジ時間 | 13,493 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 471 ms
81,780 KB |
testcase_01 | AC | 520 ms
84,696 KB |
testcase_02 | AC | 518 ms
84,720 KB |
testcase_03 | AC | 508 ms
83,200 KB |
testcase_04 | AC | 509 ms
81,492 KB |
testcase_05 | AC | 477 ms
84,584 KB |
testcase_06 | AC | 498 ms
80,224 KB |
testcase_07 | AC | 471 ms
81,076 KB |
testcase_08 | AC | 545 ms
84,784 KB |
testcase_09 | TLE | - |
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 java.util.Arrays; import java.util.Scanner; public final class Main { private static final int maxTurn = 1000; private static final int Y = 60; private static final int X = 25; public static final void main(final String[] args) { new Main().run(); } private void run() { Enemy[][] board = new Enemy[Y + 1][X]; int playerX = 12; int sumP = 0; int score = 0; try (final Scanner in = new Scanner(System.in)) { for (int turn = 0; turn < maxTurn; turn++) { StringBuilder res = new StringBuilder(); for (int x = 0; x < X; x++) { for (int y = 0; y < Y; y++) { board[y][x] = board[y + 1][x]; } board[Y][x] = null; } int n = in.nextInt(); if (n < 0) { break; } for (int i = 0; i < n; i++) { int h = in.nextInt(); int p = in.nextInt(); int x = in.nextInt(); board[Y - 1][x] = new Enemy(h, p); } if (isUnderAttack(board, playerX)) { res.append("S").append("\n"); } else { int best = -(int) 1e9; int bestP = (int) 1e9; int bestY = (int) 1e9; int bestX = (int) 1e9; for (int x = 0; x < 25; x++) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } final int turn2 = distance(playerX, x) + 1 + board[y][x].h / (1 + sumP / 100); if (turn2 < y) { if (turn2 < best) { best = turn2; bestP = board[y][x].p; bestY = y; bestX = x; } else if (turn2 == best && board[y][x].p > bestP) { best = turn2; bestP = board[y][x].p; bestY = y; bestX = x; } } break; } } res.append("#" + Utils.toString("turn", turn, "best", best)).append("\n"); res.append("#" + Utils.toString("x", bestX)).append("\n"); res.append("#" + Utils.toString("y", bestY)).append("\n"); if (board[0][playerX] == null && board[1][playerX] == null && playerX == bestX) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) < distance((playerX + 1) % 25, bestX)) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) > distance((playerX + 1) % 25, bestX)) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } else { if (board[0][playerX] == null && board[1][playerX] == null) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } } } int level = 1 + sumP / 100; for (int y = 0; y < 60; y++) { if (board[y][playerX] == null) { continue; } board[y][playerX].h -= level; if (board[y][playerX].h <= 0) { sumP += board[y][playerX].p; score += board[y][playerX].h0; res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); board[y][playerX] = null; } else { res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); } break; } System.out.println(res.toString().trim()); System.out.flush(); } } } private boolean isUnderAttack(Enemy[][] board, int x) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } if (board[y][x].h != board[y][x].h0) { if (board[y][x].h < y) { return true; } } break; } return false; } private int distance(int x, int x2) { return Math.min(Math.abs(x - x2), Math.abs((x + 25) - x2)); } } class Enemy { int h; int h0; int p; Enemy(int h, int p) { this.h = h; this.h0 = h; this.p = p; } } class Utils { private Utils() { } public static final void debug(Object... o) { System.err.println(toString(o)); System.err.flush(); } public static final String toString(Object... o) { return Arrays.deepToString(o); } public static boolean isValid(int v, int min, int minUpper) { return v >= min && v < minUpper; } }