結果
| 問題 | No.5017 Tool-assisted Shooting |
| コンテスト | |
| ユーザー |
n-inja
|
| 提出日時 | 2023-07-16 17:11:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 4,590 bytes |
| コンパイル時間 | 1,230 ms |
| コンパイル使用メモリ | 111,720 KB |
| 実行使用メモリ | 24,408 KB |
| スコア | 1,950 |
| 平均クエリ数 | 103.62 |
| 最終ジャッジ日時 | 2023-07-16 17:11:32 |
| 合計ジャッジ時間 | 8,766 ms |
|
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <random>
#include <chrono>
#include <algorithm>
#include <map>
using namespace std;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
const bool LOCAL = false;
long long s = 0;
long long score = 0;
int ok_count = 0, try_count = 0;
int power = 100;
int turn = 1000;
vector<int> p(25);
int x = 12;
struct E {
int h, p, x, turn;
int damage;
};
vector<vector<E>> es(25);
struct Node {
int x, power, turn, hp;
char command;
};
bool operator<(const Node&l, const Node&r) {
return ((double)l.power / l.turn) < ((double)r.power / r.turn);
}
void read_input(int t) {
int n;
cin >> n;
if (n == -1) exit(0);
for (int i = 0; i < n; i++) {
E e;
e.turn = t;
cin >> e.h >> e.p >> e.x;
es[e.x].push_back(e);
}
}
void output(char c) {
cout << c << endl;
if (c == 'S') x = x;
else if (c == 'L') x = (x - 1 + 25) % 25;
else if (c == 'R') x = (x + 1) % 25;
}
int main() {
if (LOCAL) {
for (int i = 0; i < 25; i++) {
cin >> p[i];
}
}
for (int i = 0; i < turn; i++) {
for (int j = 0; j < 25; j++) {
if (es[j].empty()) continue;
if (j == x) {
es[j][0].damage += power / 100;
if (es[j][0].h <= es[j][0].damage) {
power += es[j][0].p;
score += es[j][0].h;
}
}
if (i - es[j][0].turn >= 60 || es[j][0].h <= es[j][0].damage) {
es[j].erase(es[j].begin());
}
}
read_input(i);
// rx[i] := (x + i) % 25のマスに移動するためのターン数
// lx[i] := (x - i) % 25のマスに移動するためのターン数
vector<int> rx(25, 100), lx(25, 100);
rx[0] = lx[0] = 0;
for (int i = 1; i < 25; i++) {
int r_x = (x + i) % 25;
int l_x = (x - i + 25) % 25;
if (es[r_x].empty()) {
rx[i] = rx[i - 1] + 1;
} else {
int ey = (i + rx[i - 1] - es[r_x].begin()->turn);
if (ey >= 58) rx[i] = rx[i - 1] + 2;
else rx[i] = rx[i - 1] + 1;
}
if (es[l_x].empty()) {
lx[i] = lx[i - 1] + 1;
} else {
int ey = (i + lx[i - 1] - es[l_x].begin()->turn);
if (ey >= 58) lx[i] = lx[i - 1] + 2;
else lx[i] = lx[i - 1] + 1;
}
}
vector<Node> ns;
for (int k = 0; k < 25; k++) {
int r_x = (k - x + 25) % 25;
int l_x = (x - k + 25) % 25;
if (es[k].empty()) continue;
int j = 0;
int min_dist = min(rx[r_x], lx[l_x]);
while (min_dist + i - es[k][j].turn <= 0) {
j++;
if (j >= es[k].size()) break;
}
if (j >= es[k].size()) continue;
int p = power / 100;
int def_turn = (es[k][j].h - es[k][j].damage + p - 1) / p;
if (i - es[k][j].turn + def_turn + min_dist >= 59) continue;
char command = 'S';
if (k != x) {
if (rx[r_x] < lx[l_x]) command = 'R';
else command = 'L';
int nx;
if (command == 'R') {
nx = (x + 1) % 25;
} else {
nx = (x - 1 + 25) % 25;
}
if (!es[nx].empty()) {
// cout << "# " << i << " " << nx << " " << i - es[nx].begin()->turn << " " << es[nx].begin()->h << " " << es[nx].begin()->p << endl;
if (i - es[nx].begin()->turn >= 57) command = 'S';
}
}
Node n;
n.command = command;
n.power = es[k][j].p;
if (i > 500) {
n.power = es[k][j].h;
}
n.turn = def_turn + min_dist;
if (n.turn == 0) n.turn = 1;
n.hp = es[k][j].h - es[k][j].damage;
n.x = k;
ns.push_back(n);
}
sort(ns.begin(), ns.end());
reverse(ns.begin(), ns.end());
if (ns.empty()) {
cout << "# empty" << endl;
output('S');
} else {
// cout << "# " << i << " " << ns[0].command << " " << x << " " << ns[0].x << " " << ns[0].power << " " << ns[0].hp << " " << ns[0].turn << endl;
output(ns[0].command);
}
}
return 0;
}
n-inja