結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | かえで |
提出日時 | 2023-07-28 21:42:03 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 6,364 bytes |
コンパイル時間 | 2,157 ms |
コンパイル使用メモリ | 147,544 KB |
実行使用メモリ | 24,372 KB |
スコア | 3,313,370 |
平均クエリ数 | 5872.57 |
最終ジャッジ日時 | 2023-07-28 21:42:21 |
合計ジャッジ時間 | 16,482 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 89 ms
23,400 KB |
testcase_01 | AC | 84 ms
23,352 KB |
testcase_02 | AC | 81 ms
23,460 KB |
testcase_03 | AC | 84 ms
24,168 KB |
testcase_04 | AC | 80 ms
24,228 KB |
testcase_05 | AC | 80 ms
23,604 KB |
testcase_06 | AC | 80 ms
24,288 KB |
testcase_07 | AC | 86 ms
23,700 KB |
testcase_08 | AC | 85 ms
24,240 KB |
testcase_09 | AC | 87 ms
23,400 KB |
testcase_10 | AC | 80 ms
24,228 KB |
testcase_11 | AC | 81 ms
23,952 KB |
testcase_12 | AC | 84 ms
23,964 KB |
testcase_13 | AC | 83 ms
24,288 KB |
testcase_14 | AC | 81 ms
24,312 KB |
testcase_15 | AC | 82 ms
23,868 KB |
testcase_16 | AC | 81 ms
23,616 KB |
testcase_17 | AC | 84 ms
23,424 KB |
testcase_18 | AC | 85 ms
23,976 KB |
testcase_19 | AC | 86 ms
23,676 KB |
testcase_20 | AC | 84 ms
23,628 KB |
testcase_21 | AC | 83 ms
23,400 KB |
testcase_22 | AC | 83 ms
23,580 KB |
testcase_23 | AC | 82 ms
23,568 KB |
testcase_24 | AC | 83 ms
23,568 KB |
testcase_25 | AC | 88 ms
23,424 KB |
testcase_26 | AC | 84 ms
23,364 KB |
testcase_27 | AC | 83 ms
23,712 KB |
testcase_28 | AC | 82 ms
24,348 KB |
testcase_29 | AC | 84 ms
24,276 KB |
testcase_30 | AC | 82 ms
23,928 KB |
testcase_31 | AC | 82 ms
23,808 KB |
testcase_32 | AC | 83 ms
23,988 KB |
testcase_33 | AC | 84 ms
23,628 KB |
testcase_34 | AC | 84 ms
23,616 KB |
testcase_35 | AC | 82 ms
24,180 KB |
testcase_36 | AC | 84 ms
24,096 KB |
testcase_37 | AC | 83 ms
23,952 KB |
testcase_38 | AC | 81 ms
23,988 KB |
testcase_39 | AC | 84 ms
23,412 KB |
testcase_40 | AC | 81 ms
23,688 KB |
testcase_41 | AC | 83 ms
23,400 KB |
testcase_42 | AC | 85 ms
23,580 KB |
testcase_43 | AC | 83 ms
23,448 KB |
testcase_44 | AC | 88 ms
24,360 KB |
testcase_45 | AC | 84 ms
23,592 KB |
testcase_46 | AC | 82 ms
24,048 KB |
testcase_47 | AC | 82 ms
23,568 KB |
testcase_48 | AC | 81 ms
23,580 KB |
testcase_49 | AC | 84 ms
23,664 KB |
testcase_50 | AC | 80 ms
23,388 KB |
testcase_51 | AC | 80 ms
23,364 KB |
testcase_52 | AC | 85 ms
24,348 KB |
testcase_53 | AC | 84 ms
23,400 KB |
testcase_54 | AC | 84 ms
24,288 KB |
testcase_55 | AC | 33 ms
23,808 KB |
testcase_56 | AC | 80 ms
23,688 KB |
testcase_57 | AC | 83 ms
23,940 KB |
testcase_58 | AC | 84 ms
24,276 KB |
testcase_59 | AC | 86 ms
23,604 KB |
testcase_60 | AC | 86 ms
23,580 KB |
testcase_61 | AC | 84 ms
23,880 KB |
testcase_62 | AC | 81 ms
24,288 KB |
testcase_63 | AC | 84 ms
24,084 KB |
testcase_64 | AC | 86 ms
24,276 KB |
testcase_65 | AC | 89 ms
23,676 KB |
testcase_66 | AC | 83 ms
23,820 KB |
testcase_67 | AC | 85 ms
23,400 KB |
testcase_68 | AC | 81 ms
23,556 KB |
testcase_69 | AC | 82 ms
23,928 KB |
testcase_70 | AC | 83 ms
24,372 KB |
testcase_71 | AC | 82 ms
23,952 KB |
testcase_72 | AC | 79 ms
23,616 KB |
testcase_73 | AC | 81 ms
23,604 KB |
testcase_74 | AC | 82 ms
24,300 KB |
testcase_75 | AC | 86 ms
23,400 KB |
testcase_76 | AC | 86 ms
24,072 KB |
testcase_77 | AC | 87 ms
23,388 KB |
testcase_78 | AC | 83 ms
23,376 KB |
testcase_79 | AC | 81 ms
23,868 KB |
testcase_80 | AC | 85 ms
23,736 KB |
testcase_81 | AC | 84 ms
24,360 KB |
testcase_82 | AC | 84 ms
23,868 KB |
testcase_83 | AC | 83 ms
24,360 KB |
testcase_84 | AC | 83 ms
23,664 KB |
testcase_85 | AC | 84 ms
23,964 KB |
testcase_86 | AC | 83 ms
23,808 KB |
testcase_87 | AC | 84 ms
23,580 KB |
testcase_88 | AC | 84 ms
23,508 KB |
testcase_89 | AC | 82 ms
24,048 KB |
testcase_90 | AC | 87 ms
23,376 KB |
testcase_91 | AC | 89 ms
23,448 KB |
testcase_92 | AC | 85 ms
23,448 KB |
testcase_93 | AC | 86 ms
24,288 KB |
testcase_94 | AC | 83 ms
23,448 KB |
testcase_95 | AC | 82 ms
23,952 KB |
testcase_96 | AC | 82 ms
23,580 KB |
testcase_97 | AC | 81 ms
23,400 KB |
testcase_98 | AC | 84 ms
23,364 KB |
testcase_99 | AC | 81 ms
24,168 KB |
ソースコード
#include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <iomanip>//fixed,setprecision //#include <limits.n>//INT_MAX //#include <math.n>//M_PI #include <random> #include <regex> // 正規表現 #include <time.h> #include <fstream> //#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) constexpr int width = 25; // フィールドの幅 constexpr int height = 60; // フィールドの高さ constexpr int max_turn = 1000; // ゲームの最大ターン数 const char choice[3] = {'L', 'R', 'S'}; int masu[25][60]; int masu1[25][60]; int sx = 12; int power=0; int kogeki=1; int score=0; int sy=0; struct Data { int h; int p; int x; int y; Data(int h, int p, int x, int y) : h(h), p(p), x(x), y(y) {} }; bool compareByValue(const Data& a, const Data& b) { int valueA = a.y - std::abs(sx - a.x) - 1 - a.h; int valueB = b.y - std::abs(sx - b.x) - 1 - b.h; if (valueA != valueB) return valueA > valueB; else return std::abs(sx - a.x) < std::abs(sx - b.x); } int main() { #ifdef ONLINE_JUDGE #else //vector<int>P(25); //rep(i,25)cin>>P[i]; #endif vector<Data> enemy_state[25]; vector<Data> enemy_state_moto[25]; vector<int>lane(25,0); //rep(i,25)data[i].emplace_back(0,0,0,59); for (int turn = 1; turn <= max_turn; turn++) { //cerr<<"#turn"<<turn<<" "; // 入力の受け取り sy=turn; int n; cin >> n; if (n == -1) return 0; for (int i = 0; i < n; i++) { int h1, p1, x1; cin >> h1 >> p1 >> x1; enemy_state[x1].emplace_back(h1, p1, x1, 59+turn); enemy_state_moto[x1].emplace_back(h1, p1, x1, 59+turn); //if(lane[x1]==-1)lane[x1]=0; } int min_i=-1; int sho=1000; int dai=0; int dai_power=0; //kogeki=1; rep(i,25){ if (enemy_state[i].empty())continue; if(lane[i]+1>enemy_state[i].size())continue; Data z=enemy_state[i][lane[i]]; if(z.p<=0)continue; kogeki=1+(power/100); if(kogeki<=0)kogeki=1; //cerr<<__LINE__<<"---"<<kogeki<<endl; //cerr<<z.h<<" "<<kogeki<<endl; int tmp=z.y-sy-(int)((z.h+kogeki-1)/kogeki)-abs(sx-z.x)-1; //double evaluated_score=(double)z.h/(double)z.p; //if(tmp>1&&sho>abs(sx-z.x)+evaluated_score&&z.y!=-1&&z.x!=-1&&z.h>0){ if(tmp>1&&sho>abs(sx-z.x)&&z.y-sy>1&&z.x!=-1&&z.h>0){ //if(tmp>1&&((kogeki<2&&dai<z.p)||(kogeki>=2&&sho>abs(sx-z.x)))&&z.y!=-1&&z.x!=-1&&z.h>0){ min_i=z.x; sho=abs(sx-z.x); dai=z.p; dai_power=z.h; //sho=abs(sx-z.x)+evaluated_score; //cerr<<" turn:"<<turn<<" min_i"<<min_i<<endl; } } int r = 2; if(min_i==-1)min_i=sx; //cerr<<"moto sx"<<sx<<" "; if (sx > min_i&&sx>=1&&(enemy_state[sx-1].empty()||lane[sx-1]==-1||(lane[sx-1]+1<=enemy_state[sx-1].size()&&enemy_state[sx-1][lane[sx-1]].y>=2+turn)||lane[sx-1]+1>enemy_state[sx-1].size())) { r = 0;//L sx--; } else if (sx < min_i&&sx+1<25&&(enemy_state[sx+1].empty()||lane[sx+1]==-1||(lane[sx+1]+1<=enemy_state[sx+1].size()&&enemy_state[sx+1][lane[sx+1]].y>=2+turn)||lane[sx+1]+1>enemy_state[sx+1].size())) { r = 1;//R sx++; } else if(enemy_state[sx].empty()||lane[sx]==-1||(lane[sx]+1<=enemy_state[sx].size()&&enemy_state[sx][lane[sx]].y>=2+turn)||lane[sx]+1>enemy_state[sx].size()){ r = 2; }else if(sx>=1&&(enemy_state[sx-1].empty()||lane[sx-1]==-1||(lane[sx-1]+1<=enemy_state[sx-1].size()&&enemy_state[sx-1][lane[sx-1]].y>=2+turn)||lane[sx-1]+1>enemy_state[sx-1].size())){ r = 0;//L sx--; }else if(sx+1<25&&(enemy_state[sx+1].empty()||lane[sx+1]==-1||(lane[sx+1]+1<=enemy_state[sx+1].size()&&enemy_state[sx+1][lane[sx+1]].y>=2+turn))||lane[sx+1]+1>enemy_state[sx+1].size()){ r = 1;//R sx++; }else{ r=2; } char c = choice[r]; cout << c << endl; cout << "#" << c << " sx:" << sx <<endl; if(!enemy_state[min_i].empty()>0)cout<<"#nerai x:"<<min_i<<" y:"<<enemy_state[min_i][lane[min_i]].y<<" h"<<enemy_state[min_i][lane[min_i]].h<<endl; //間に合わないlaneはとばしていかないと(プラスしていかないと) rep(i,25){ if (lane[i]==-1)continue; int size=enemy_state[i].size(); rep(j,size){ Data& z=enemy_state[i][j]; //if(z.y!=-1)z.y=z.y-1; if(lane[i]==j&&z.y<sy)lane[i]++; //else if(abs(i-sx)>1+data[i][lane[i]].y)lane[i]++; } } //cerr<<__LINE__<<"---"<<lane[sx]<<" "<<data[sx].size()<<endl; if (lane[sx]!=-1&&lane[sx]+1<=enemy_state[sx].size()) { Data& z=enemy_state[sx][lane[sx]]; z.h-=kogeki; if(z.h<=0&&z.p>0){ power+=z.p; score+=enemy_state_moto[sx][lane[sx]].h; z.p=0; kogeki=1+(power/100); lane[sx]++; } cout<<"#now x:"<<sx<<" h"<<z.h<<endl; } cout<<"#power:"<<power<<" kogeki:"<<kogeki<<endl; cout<<"#score:"<<score<<endl; //cerr<<__LINE__<<"---"<<endl; } return 0; }