結果
| 問題 |
No.5017 Tool-assisted Shooting
|
| ユーザー |
かえで
|
| 提出日時 | 2023-07-20 21:10:06 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 199 ms / 2,000 ms |
| コード長 | 5,577 bytes |
| コンパイル時間 | 1,674 ms |
| コンパイル使用メモリ | 147,384 KB |
| 実行使用メモリ | 24,348 KB |
| スコア | 3,372,341 |
| 平均クエリ数 | 4884.01 |
| 最終ジャッジ日時 | 2023-07-20 21:10:33 |
| 合計ジャッジ時間 | 26,470 ms |
|
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
#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;
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> data[25];
vector<int>lane(25,-1);
//rep(i,25)data[i].emplace_back(0,0,0,59);
for (int turn = 1; turn <= max_turn; turn++) {
cerr<<"#turn"<<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;
data[x1].emplace_back(h1, p1, x1, 59);
if(lane[x1]==-1)lane[x1]=0;
}
int min_i=-1;
int sho=1000;
//kogeki=1;
rep(i,25){
if (lane[i]==-1)continue;
if(lane[i]+1>data[i].size())continue;
Data z=data[i][lane[i]];
if(z.h==0)continue;
kogeki=1+(power/100);
if(kogeki<=0)kogeki=1;
//cerr<<__LINE__<<"---"<<kogeki<<endl;
//cerr<<z.h<<" "<<kogeki<<endl;
int tmp=z.y-(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){
min_i=z.x;
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&&(data[sx-1].empty()||lane[sx-1]==-1||(lane[sx-1]+1<=data[sx-1].size()&&data[sx-1][lane[sx-1]].y>=2)||lane[sx-1]+1>data[sx-1].size())) {
r = 0;//L
sx--;
} else if (sx < min_i&&sx+1<25&&(data[sx+1].empty()||lane[sx+1]==-1||(lane[sx+1]+1<=data[sx+1].size()&&data[sx+1][lane[sx+1]].y>=2)||lane[sx+1]+1>data[sx+1].size())) {
r = 1;//R
sx++;
} else if(data[sx].empty()||lane[sx]==-1||(lane[sx]+1<=data[sx].size()&&data[sx][lane[sx]].y>=2)||lane[sx]+1>data[sx].size()){
if(turn==811)cerr<<"koko"<<endl;
r = 2;
}else if(sx>=1&&(data[sx-1].empty()||lane[sx-1]==-1||(lane[sx-1]+1<=data[sx-1].size()&&data[sx-1][lane[sx-1]].y>=2)||lane[sx-1]+1>data[sx-1].size())){
r = 0;//L
sx--;
}else if(sx+1<25&&(data[sx+1].empty()||lane[sx+1]==-1||(lane[sx+1]+1<=data[sx+1].size()&&data[sx+1][lane[sx+1]].y>=2))||lane[sx+1]+1>data[sx+1].size()){
r = 1;//R
sx++;
}else{
if(turn==811)cerr<<"saigo lane[sx]:"<<lane[sx]<<" y:"<<data[sx][lane[sx]].y<<endl;
r=2;
}
char c = choice[r];
cout << c << endl;
cout << "#" << c << " sx:" << sx <<endl;
if(lane[min_i]!=-1)cout<<"#nerai x:"<<min_i<<" y:"<<data[min_i][lane[min_i]].y<<" h"<<data[min_i][lane[min_i]].h<<endl;
//間に合わないlaneはとばしていかないと(プラスしていかないと)
rep(i,25){
if (lane[i]==-1)continue;
int size=data[i].size();
rep(j,size){
Data& z=data[i][j];
if(z.y!=-1)z.y=z.y-1;
if(lane[i]==j&&z.y<0)lane[i]++;
}
}
//cerr<<__LINE__<<"---"<<lane[sx]<<" "<<data[sx].size()<<endl;
if (lane[sx]!=-1&&lane[sx]+1<=data[sx].size()) {
Data& z=data[sx][lane[sx]];
z.h-=kogeki;
if(z.h<=0){
power+=z.p;
kogeki=1+(power/100);
lane[sx]++;
}
cout<<"#now x:"<<sx<<" h"<<z.h<<endl;
}
cout<<"#power:"<<power<<" kogeki:"<<kogeki<<endl;
//cerr<<__LINE__<<"---"<<endl;
}
return 0;
}
かえで