結果
問題 |
No.5017 Tool-assisted Shooting
|
ユーザー |
![]() |
提出日時 | 2023-07-16 20:51:53 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 4,979 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 146,204 KB |
実行使用メモリ | 24,504 KB |
スコア | 85,909 |
平均クエリ数 | 1049.91 |
最終ジャッジ日時 | 2023-07-16 20:52:17 |
合計ジャッジ時間 | 21,231 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge11 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 59 RE * 41 |
ソースコード
#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; 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 compareByH(const Data& a, const Data& b) { return a.h < b.h; } bool compareByX(const Data& a, const Data& b) { return abs(a.x - sx) < abs(b.x - sx); } int main() { //vector<int>P(25); //rep(i,25)cin>>P[i]; vector<Data> data; for (int turn = 1; turn <= max_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; //cerr<<h1<<" "<<p1<<" "<<x1<<" "<<endl; data.emplace_back(h1, p1, x1, 59); masu[x1][59]=1; } /* 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(), compareByH); sort(data.begin(), data.end(), compareByX); } int r = 0; if (sx > data[0].x&&sx>=1&&masu[sx-1][0]==0&&masu[sx-1][1]==0&&masu[sx-1][2]==0) { r = 0; sx--; } else if (sx < data[0].x&&sx<24&&masu[sx+1][0]==0&&masu[sx+1][1]==0&&masu[sx+1][2]==0) { r = 1; sx++; } else { r = 2; if (masu[sx][0]==1||masu[sx][1]==1||masu[sx][2]==1) { if (sx >= 1&&masu[sx-1][0]==0&&masu[sx-1][1]==0&&masu[sx-1][2]==0) { sx--; r = 0; } else if(sx <24&&masu[sx+1][0]==0&&masu[sx+1][1]==0&&masu[sx+1][2]==0){ sx++; r = 1; }else if(sx==0&&masu[24][0]==0&&masu[24][1]==0&&masu[24][2]==0){ r=0; sx=24; }else if(sx ==24&&masu[0][0]==0&&masu[0][1]==0&&masu[0][2]==0){ r=1; sx=0; } } } char c = choice[r]; cout << c << endl; cout << "#" << c << " sx:" << sx << endl; int ichi = 100; rep(i,25){ rep(j,60){ //cerr<<masu[i][j]<<" "; if(masu[i][j]==1){ masu1[i][j]=0; if(j-1>=0)masu1[i][j-1]=1; } } //cerr<<endl; } rep(i,25)rep(j,60)masu[i][j]=masu1[i][j]; if (!data.empty()) { for (auto& z : data) { z.y -= 1; if (z.x == sx) { ichi = min(ichi, z.y); } } } //cerr<<__LINE__<<"---"<<endl; if (ichi != -1&&!data.empty()) { for (auto it = data.begin(); it != data.end(); ++it) { if (ichi == it->y && it->x == sx) { if (it->h != 0) { //cerr<<__LINE__<<"---"<<endl; it->h -= 1; //masu[sx][ichi]=0; //it ->y -=1; //if(it->y<0)data.erase(it); //else masu[sx][it->y]=1; } else { //cerr<<__LINE__<<"---"<<endl; //data.erase(it); } //break; }else{ //cerr<<__LINE__<<"---"<<(it->y)<<endl; //masu[sx][it->y]=0; //it ->y -=1; //if(it->y<0)data.erase(it); //else masu[sx][it->y]=1; } } } //cerr<<__LINE__<<"---"<<endl; } return 0; }