結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー |
|
提出日時 | 2023-07-16 17:59:34 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 4,570 bytes |
コンパイル時間 | 3,266 ms |
コンパイル使用メモリ | 101,660 KB |
実行使用メモリ | 24,252 KB |
スコア | 7,495 |
平均クエリ数 | 98.83 |
最終ジャッジ日時 | 2023-07-16 17:59:45 |
合計ジャッジ時間 | 10,316 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
void main() { runSolver(); }// ----------------------------------------------void problem() {enum TURNS = 1000;enum AREA_Y = 60;enum AREA_X = 25;auto enemy_h = new int[][](TURNS + AREA_Y, AREA_X);auto enemy_s = new int[][](TURNS + AREA_Y, AREA_X);auto enemy_p = new int[][](TURNS + AREA_Y, AREA_X);int[2] calcDistance(int cur, int goal) {if (cur == goal) return [0, 0];if (cur < goal) {const d1 = goal - cur;const d2 = AREA_X + cur - goal;return d1 <= d2 ? [d1, 1] : [d2, -1];} else {const d1 = cur - goal;const d2 = AREA_X - cur + goal;return d1 <= d2 ? [d1, -1] : [d2, 1];}}long score, exp;long power = 1;int cur = 12, target = -1, targetY;foreach(y; 0..TURNS) {const N = scan!int;if (N == -1) break;foreach(_; 0..N) {auto H = scan!int;auto P = scan!int;auto X = scan!int;enemy_h[AREA_Y + y - 1][X] = H;enemy_s[AREA_Y + y - 1][X] = H;enemy_p[AREA_Y + y - 1][X] = P;}if (target == -1) {long best = -1;foreach(x; 0..AREA_X) {const dist = max(0, calcDistance(cur, x)[0] - 1);foreach(dy; y + 1..y + AREA_Y) {const hp = enemy_h[dy][x];if (hp == 0) continue;const attacks = (hp + power - 1) / power;if (attacks > dy - y - dist) continue;const perf = enemy_p[dy][x] * 1_000_000 / max(1, attacks + dist);if (chmax(best, perf)) {target = x;targetY = dy;}}}}[exp].deb;if (target == -1) {"S".writeln;} else {auto d = calcDistance(cur, target);// d.deb;writeln(d[1] == -1 ? "L" : d[1] == 0 ? "S" : "R");cur += d[1];cur = (cur + AREA_X) % AREA_X;if (cur == target) {enemy_h[targetY][target] -= power;if (enemy_h[targetY][target] <= 0) {score += enemy_s[targetY][target];exp += enemy_p[targetY][target];power = 1 + (exp / 100);target = -1;}}}stdout.flush;}}// ----------------------------------------------import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop, std.random;string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }T scan(T)(){ return scan.to!T; }T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }void deb(T ...)(T t){ debug { write("#"); writeln(t); }}T[] divisors(T)(T n) { T[] ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array;}bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }void outputForAtCoder(T)(T delegate() fn) {static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());else static if (is(T == void)) fn();else static if (is(T == string)) fn().writeln;else static if (isInputRange!T) {static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;else foreach(r; fn()) r.writeln;}else fn().writeln;}void runSolver() {problem();}enum YESNO = [true: "Yes", false: "No"];// -----------------------------------------------struct Vector2(T) {T x, y;Vector2 add(Vector2 other) { return Vector2(x + other.x, y + other.y ); }Vector2 opAdd(Vector2 other) { return add(other); }Vector2 sub(Vector2 other) { return Vector2(x - other.x, y - other.y ); }Vector2 opSub(Vector2 other) { return sub(other); }T norm(Vector2 other) {return (x - other.x)*(x - other.x) + (y - other.y)*(y - other.y); }T dot(Vector2 other) {return x*other.y - y*other.x; }Vector2 normalize() {if (x == 0 || y == 0) return Vector2(x == 0 ? 0 : x/x.abs, y == 0 ? 0 : y/y.abs);const gcd = x.abs.gcd(y.abs);return Vector2(x/ gcd, y / gcd);}string toString() { return "%s %s".format(x, y); }}