結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | shirokami |
提出日時 | 2023-07-16 16:15:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 3,217 bytes |
コンパイル時間 | 4,017 ms |
コンパイル使用メモリ | 321,536 KB |
実行使用メモリ | 24,384 KB |
スコア | 20,161 |
平均クエリ数 | 155.68 |
最終ジャッジ日時 | 2023-07-16 16:15:32 |
合計ジャッジ時間 | 10,930 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include <bits/extc++.h>using namespace std;using uint = unsigned int;using ll = long long;using ull = unsigned long long;using ld = long double;struct enemy_state {int hp;int power;};struct own_state {int x = 12;int exp = 0;int level = 1;char action = 'S';};int N; // 敵機の数int turn = 0; // ターン数own_state own = own_state(); // 自機の状態vector<vector<enemy_state>> field(25, vector<enemy_state>(60)); // フィールドの初期化vector<int> enemy_count(25); // いままでに出現した敵の数void set_field() {for (int i = 0; i < N; ++i) {int h, p, x;cin >> h >> p >> x;field[x][59].hp = h;field[x][59].power = p;enemy_count[x]++;}}void move_own() {// もしその場に居続けて敵を倒せるなら、その場に居続けるfor (int i = 1; i < 60; i++) {if (field[own.x][i].hp > 0) {if (field[own.x][i].hp <= own.level * i) {own.action = 'S';return;}}}// 倒すことができる敵の中で、自機から一番近い敵を倒すfor (int i = 1; i < 25; i++) {int x;if (i%2 == 1) {x = own.x + i;x = x % 25;} else {x = own.x - i;if (x < 0) {x = 25 + x;}}for (int j = 0; j < 60; j++) {if (field[x][j].hp > 0) {int dx = abs(x - own.x);if (field[x][j].hp <= own.level * (j - dx)) {if (x > own.x) {own.action = 'R';} else if (x < own.x) {own.action = 'L';}return;}}}}}void update_field() {// 敵を攻撃for (int i = 0; i < 60; i++) {// 同じ列に敵がいたら、一番手前の敵だけを攻撃if (field[own.x][i].hp > 0) {field[own.x][i].hp -= own.level;if (field[own.x][i].hp <= 0) {own.exp += field[own.x][i].power;own.level = 1 + own.exp / 100;field[own.x][i].hp = 0;field[own.x][i].power = 0;}break;}}// 下に移動for (int i = 0; i < 59; i++) {for (int j = 0; j < 25; j++) {field[j][i] = field[j][i+1];}}for (int i = 0; i < 25; i++) {field[i][59].hp = 0;field[i][59].power = 0;}// 自機の移動if (own.action == 'S') {own.x = own.x;} else if (own.action == 'R') {own.x = own.x + 1;if (own.x == 25) {own.x = 0;}} else if (own.action == 'L') {own.x = own.x - 1;if (own.x == -1) {own.x = 24;}}cout << own.action << endl;// ターンを更新turn++;if (turn == 1000) {exit(0);}}// デバッグ用void print_field_hp() {for (int i = 0; i < 25; i++) {for (int j = 0; j < 60; j++) {cout << field[i][j].hp << ' ';}cout << '\n';}}void print_field_power() {for (int i = 0; i < 25; i++) {for (int j = 0; j < 60; j++) {cout << field[i][j].power << ' ';}cout << '\n';}}int main() {while (true) {cin >> N;if (N == -1) { // 終了return 0;}// 敵が出現set_field();// 移動move_own();// ターンを更新update_field();}}