結果
| 問題 | No.5017 Tool-assisted Shooting |
| コンテスト | |
| ユーザー |
かえで
|
| 提出日時 | 2023-07-18 23:21:03 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 7,664 bytes |
| 記録 | |
| コンパイル時間 | 1,787 ms |
| コンパイル使用メモリ | 150,568 KB |
| 実行使用メモリ | 36,424 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2023-07-18 23:21:16 |
| 合計ジャッジ時間 | 8,511 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 99 |
ソースコード
#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() {
vector<int>P(25);
rep(i,25)cin>>P[i];
vector<Data> data,data_mae;
rep(i,25)data_mae.emplace_back(1000,-1,-1,-1);
for (int turn = 1; turn <= max_turn; turn++) {
// 入力の受け取り
//cerr<<"power"<<power<<endl;
int n;
cin >> n;
if (n == -1)
return 0;
rep(j,60){
rep(i,25){
if(masu[i][j]==1){
masu1[i][j]=0;
if(j-1>=0){
masu1[i][j-1]=1;
}
}
}
}
rep(j,60){
rep(i,25){
masu[i][j]=masu1[i][j];
// if(turn==76)cerr<<masu1[i][j];
}
//if(turn==76)cerr<<endl;
}
for(auto& z:data_mae)if(z.h==0){
power+=z.p;
kogeki=1+(power/100);
masu[z.x][z.y]=0;
z.h=1000;
if(!data.empty()){
int sho=100;
rep(i,data.size()){
if(z.x==data[i].x&&data[i].h>0&&sho>data[i].y){
sho=data[i].y;
z.h=data[i].h;
z.x=data[i].x;
z.p=data[i].p;
z.y=data[i].y;
}
}
}
}
for (int i = 0; i < n; i++) {
int h1, p1, x1;
cin >> h1 >> p1 >> x1;
//cerr<<h1<<" "<<p1<<" "<<x1<<" "<<endl;
data.emplace_back(h1, p1, x1, 59);
masu[x1][59]=1;
}
rep(i,25){
if(data_mae[i].y==-1||data_mae[i].x==-1){
rep(j,60)if(masu[i][j]==1){
data_mae[i].x=i;
data_mae[i].y=j;
for(auto q:data){
if(q.x==i&&q.y==j){
data_mae[i].h=q.h;
data_mae[i].p=q.p;
break;
}
}
break;
}
//cerr<<"kakunin:"<<h1<<" "<<data_mae[x1].h<<endl;
}
}
/*
if(turn<=2){
rep(i,25){
rep(j,60)cerr<<masu[i][j]<<" ";
cerr<<endl;
}
cerr<<endl;
}*/
if (!data.empty()) {
sort(data.begin(), data.end(), compareByValue);
}
int min_i=-1;
int sho=1000;
//kogeki=1;
for(auto z:data_mae){
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;
//cerr<<__LINE__<<"---"<<endl;
if(tmp>1&&sho>abs(sx-z.x)&&z.y!=-1&&z.x!=-1&&z.h>0){
min_i=z.x;
sho=abs(sx-z.x);
}
}
//if(turn==76)cerr<<__LINE__<<"---"<<min_i<<endl;
int r = 2;
if(!data.empty()){
if(min_i==-1)min_i=sx;
//cerr<<"moto sx"<<sx<<" ";
if (sx > min_i&&sx>=1&&masu[sx-1][0]==0&&masu[sx-1][1]==0) {
r = 0;//L
sx--;
if(turn==76)cerr<<__LINE__<<"---"<<min_i<<endl;
} else if (sx < min_i&&sx<24&&masu[sx+1][0]==0&&masu[sx+1][1]==0) {
r = 1;//R
sx++;
} else if(masu[sx][0]==0&&masu[sx][1]==0){
r = 2;
}else if(sx>=1&&masu[sx-1][0]==0&&masu[sx-1][1]==0){
r = 0;//L
sx--;
}else{
r = 1;//R
sx++;
}
/*
if (masu[sx][0]==1||masu[sx][1]==1) {
if (sx >= 1&&masu[sx-1][0]==0&&masu[sx-1][1]==0) {
if(turn==76)cerr<<__LINE__<<"---"<<min_i<<endl;
sx--;
r = 0;
} else if(sx <24&&masu[sx+1][0]==0&&masu[sx+1][1]==0){
sx++;
r = 1;
}else if(sx==0&&masu[24][0]==0&&masu[24][1]==0){
r=0;
sx=24;
}else if(sx ==24&&masu[0][0]==0&&masu[0][1]==0){
r=1;
sx=0;
}
}
*/
}
//if(turn==76)cerr<<__LINE__<<"---"<<min_i<<" r"<<r<<endl;
char c = choice[r];
cout << c << endl;
cout << "#" << c << " sx:" << sx <<endl;
//if(!data.empty())cout<<"#nerai x:"<<data[0].x<<" y:"<<data[0].y<<" h"<<data[0].h<<endl;
for(auto &z:data_mae){
if(z.x==sx){
z.h-=kogeki;
if(z.h<0)z.x=-1,z.y=-1,z.h=0;
cout<<"#now x:"<<sx<<" h"<<data_mae[sx].h<<endl;
break;
}
}
cout<<"#nerai x:"<<min_i<<" y:"<<data_mae[min_i].y<<" h"<<data_mae[min_i].h<<endl;
cout<<"#power:"<<power<<" kogeki:"<<kogeki<<endl;
for(auto &z:data_mae){
if(z.y!=-1)z.y=z.y-1;
}
int ichi = 100;
if (!data.empty()) {
for (auto& z : data) {
z.y -=1;
if (z.x == sx&&z.h>0&&z.y>0) {
ichi = min(ichi, z.y);
}
}
}
if (ichi != -1&&!data.empty()) {
for (auto it = data.begin(); it != data.end(); ++it) {
if (ichi == it->y && it->x == sx) {
int z=kogeki;
if (it->h >z) {
it->h -= z; }
else{
data.erase(it);
}
break;
}
if(it->h<=0)data.erase(it);
}
}
}
return 0;
}
かえで