結果

問題 No.5017 Tool-assisted Shooting
ユーザー かえでかえで
提出日時 2023-07-20 21:10:06
言語 C++17
(gcc 12.3.0 + boost 1.83.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
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
24,252 KB
testcase_01 AC 185 ms
23,868 KB
testcase_02 AC 173 ms
23,640 KB
testcase_03 AC 178 ms
24,048 KB
testcase_04 AC 169 ms
23,664 KB
testcase_05 AC 178 ms
24,048 KB
testcase_06 AC 174 ms
24,000 KB
testcase_07 AC 173 ms
24,048 KB
testcase_08 AC 171 ms
24,060 KB
testcase_09 AC 175 ms
24,336 KB
testcase_10 AC 177 ms
23,556 KB
testcase_11 AC 172 ms
24,048 KB
testcase_12 AC 179 ms
24,048 KB
testcase_13 AC 166 ms
23,676 KB
testcase_14 AC 166 ms
24,288 KB
testcase_15 AC 180 ms
24,084 KB
testcase_16 AC 196 ms
23,652 KB
testcase_17 AC 174 ms
24,348 KB
testcase_18 AC 185 ms
23,688 KB
testcase_19 AC 168 ms
23,856 KB
testcase_20 AC 167 ms
24,036 KB
testcase_21 AC 191 ms
23,436 KB
testcase_22 AC 170 ms
23,448 KB
testcase_23 AC 174 ms
23,568 KB
testcase_24 AC 174 ms
24,048 KB
testcase_25 AC 176 ms
23,664 KB
testcase_26 AC 183 ms
23,556 KB
testcase_27 AC 183 ms
23,568 KB
testcase_28 AC 170 ms
23,568 KB
testcase_29 AC 181 ms
23,556 KB
testcase_30 AC 176 ms
24,084 KB
testcase_31 AC 163 ms
23,652 KB
testcase_32 AC 161 ms
23,556 KB
testcase_33 AC 168 ms
23,664 KB
testcase_34 AC 176 ms
24,288 KB
testcase_35 AC 177 ms
24,048 KB
testcase_36 AC 165 ms
24,060 KB
testcase_37 AC 171 ms
24,288 KB
testcase_38 AC 166 ms
24,048 KB
testcase_39 AC 183 ms
23,676 KB
testcase_40 AC 183 ms
23,424 KB
testcase_41 AC 183 ms
23,664 KB
testcase_42 AC 179 ms
24,072 KB
testcase_43 AC 185 ms
23,448 KB
testcase_44 AC 163 ms
23,688 KB
testcase_45 AC 178 ms
24,060 KB
testcase_46 AC 175 ms
23,436 KB
testcase_47 AC 169 ms
23,544 KB
testcase_48 AC 172 ms
23,448 KB
testcase_49 AC 165 ms
23,424 KB
testcase_50 AC 172 ms
23,640 KB
testcase_51 AC 172 ms
23,856 KB
testcase_52 AC 177 ms
23,676 KB
testcase_53 AC 186 ms
23,628 KB
testcase_54 AC 179 ms
24,288 KB
testcase_55 AC 45 ms
23,844 KB
testcase_56 AC 170 ms
24,348 KB
testcase_57 AC 181 ms
23,664 KB
testcase_58 AC 199 ms
23,448 KB
testcase_59 AC 180 ms
24,060 KB
testcase_60 AC 173 ms
23,700 KB
testcase_61 AC 170 ms
24,048 KB
testcase_62 AC 169 ms
24,084 KB
testcase_63 AC 171 ms
24,276 KB
testcase_64 AC 170 ms
23,664 KB
testcase_65 AC 177 ms
24,060 KB
testcase_66 AC 172 ms
24,060 KB
testcase_67 AC 165 ms
23,688 KB
testcase_68 AC 177 ms
24,252 KB
testcase_69 AC 168 ms
24,264 KB
testcase_70 AC 191 ms
23,856 KB
testcase_71 AC 176 ms
23,580 KB
testcase_72 AC 170 ms
24,096 KB
testcase_73 AC 187 ms
23,556 KB
testcase_74 AC 190 ms
23,400 KB
testcase_75 AC 185 ms
23,676 KB
testcase_76 AC 170 ms
24,048 KB
testcase_77 AC 194 ms
23,556 KB
testcase_78 AC 173 ms
24,084 KB
testcase_79 AC 193 ms
23,868 KB
testcase_80 AC 180 ms
23,868 KB
testcase_81 AC 174 ms
23,868 KB
testcase_82 AC 177 ms
24,252 KB
testcase_83 AC 173 ms
23,856 KB
testcase_84 AC 196 ms
23,856 KB
testcase_85 AC 191 ms
24,012 KB
testcase_86 AC 183 ms
23,856 KB
testcase_87 AC 187 ms
23,544 KB
testcase_88 AC 175 ms
23,400 KB
testcase_89 AC 179 ms
23,400 KB
testcase_90 AC 199 ms
23,400 KB
testcase_91 AC 179 ms
24,276 KB
testcase_92 AC 186 ms
23,424 KB
testcase_93 AC 175 ms
23,652 KB
testcase_94 AC 171 ms
24,060 KB
testcase_95 AC 171 ms
23,544 KB
testcase_96 AC 180 ms
24,036 KB
testcase_97 AC 172 ms
24,276 KB
testcase_98 AC 171 ms
23,856 KB
testcase_99 AC 170 ms
24,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0