結果

問題 No.5017 Tool-assisted Shooting
ユーザー gucci0512
提出日時 2024-02-25 01:41:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 3,241 bytes
コンパイル時間 4,580 ms
コンパイル使用メモリ 233,748 KB
実行使用メモリ 38,548 KB
スコア 0
最終ジャッジ日時 2024-02-25 01:42:10
合計ジャッジ時間 11,209 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 99
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
typedef long long ll;
typedef long double lld;
using namespace std;
using namespace atcoder;
clock_t start=clock();
clock_t process=clock();
// random_device seed_gen;
// mt19937 engine(seed_gen());
mt19937 engine(0);

const bool LOCAL_JUDGE = true;
const int W = 25;
const int H = 60;
const int T = 1000;
const int OFFSET = 59;
const int INF = (1<<30);

void LocalInput(){
    rep(i,0,W){
        int p;cin >> p;
    }
}

int field[T+H+10][W];
vector<int> h,p,x,t,point;
deque<int> enemies[W];

void Init(){
    rep(i,0,T+H+10)rep(j,0,W) field[i][j] = -1;
    field[0][12] = -2;
}

void Input(int turn){
    int n;cin >> n;
    if(n==-1) exit(0);
    rep(i,0,n){
        int _h,_p,_x;cin >> _h >> _p >> _x;
        int idx=h.size();
        h.push_back(_h);
        p.push_back(_p);
        x.push_back(_x);
        point.push_back(_h);
        field[OFFSET+turn+1][x[idx]] = idx;
        t.push_back(OFFSET+turn+1);
        enemies[x[idx]].push_back(idx);
    }
}

int my_i = 0;
int my_j = 12;

void Output(char action){
    cout << action << endl;
    field[my_i][my_j] = -1;
    if(action=='L'){
        my_j--;
    }
    if(action=='R'){
        my_j++;
    }
    my_j = (my_j+W)%W;
    field[my_i][my_j] = -2;
}

int S = 0;
int level = 1;
int score = 0;

void MoveEnemy(int turn){
    field[my_i][my_j] = -1;
    my_i++;
    field[my_i][my_j] = -2;
    rep(j,0,W){
        while(enemies[j].size()>0){
            int enemy_idx = enemies[j].front();
            if(enemy_idx<my_i){
                enemies[j].pop_front();
            }
            else{
                break;
            }
        }
        
    }
    return;
}

void AppearenceEnemy(int turn){
    Input(turn);
}

void MoveMine(int turn){
    if(600<=turn&&turn<=700){
        cerr << turn << " " << field[my_i][my_j] << " " <<field[my_i+1][my_j] << endl;
    }
    if(field[my_i+1][my_j] == -1){
        Output('S');
        return;
    }
    else{
        if(field[my_i][(my_j+1)%W] == -1&&field[my_i+1][(my_j+1)%W] == -1){
            Output('R');
            return;
        }
        else{
            Output('L');
            return;
        }
    }
    return;
}

void AtackMine(int turn){
    if(enemies[my_j].size()==0){
        return;
    }
    int enemy_idx = enemies[my_j].front();
    h[enemy_idx] -= level;
    if(h[enemy_idx]<=0){
        enemies[my_j].pop_front();
        field[t[enemy_idx]][x[enemy_idx]] = -1;
        score += point[enemy_idx];
        S += p[enemy_idx];
        level = (1+S/100);
    }
    return;
}

void Solve(){
    rep(turn,0,T){
        MoveEnemy(turn);
        AppearenceEnemy(turn);
        MoveMine(turn);
        AtackMine(turn);
    }
    cerr << "OK" << endl;
}   

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if(LOCAL_JUDGE) LocalInput();
    Init();
    Solve();
    cerr << "# Score : " << score << endl;
}
0