結果
問題 |
No.5019 Hakai Project
|
ユーザー |
![]() |
提出日時 | 2023-11-19 06:43:59 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,905 bytes |
コンパイル時間 | 2,396 ms |
コンパイル使用メモリ | 202,124 KB |
実行使用メモリ | 6,676 KB |
スコア | 0 |
最終ジャッジ日時 | 2023-11-19 06:44:10 |
合計ジャッジ時間 | 10,154 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 48 RE * 2 |
ソースコード
#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.h>//INT_MAX #include <math.h>//M_PI #include <random> #include <regex> // 正規表現 #include <time.h> #include <fstream> #include <array> #include <bit> #include <chrono> #include <ranges> #include <span> #include <cmath> #include <cstdint> #include <complex>//複素数 //#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) template < typename T > std::string to_string( const T& n ){std::ostringstream stm ;stm << n ;return stm.str() ;} int N,M; vector<string> A; vector<pair<int,vector<pair<int,int>>>> bomb; int min_cost=1<<30; int min_cost_id; vector<pair<int,string>> ans; void input(){ cin>>N>>M; A.resize(N); for(int i=0; i<N; i++){ cin>>A[i]; } bomb.resize(M); for(int i=0; i<M; i++){ int C,L; cin>>C>>L; if(C<min_cost){ min_cost=C; min_cost_id=i+1; } bomb[i].first=C;//first:Cost for(int j=0; j<L; j++){ int a,b; cin>>a>>b; bomb[i].second.push_back(make_pair(a,b));//second.first:壊せるマスのiからのx方向距離 second.second: y方向距離 } } } void bakuha(int i,int j,int num){ rep(ni,bomb[num].second.size()){ int x=i+bomb[num].second[ni].first; int y=j+bomb[num].second[ni].second; if(x<0||x>=N||y<0||y>=N)continue; A[x][y]='.'; } } void mukau(int sx,int sy,int gx,int gy){ if(sx<gx){ rep(i,gx-sx)ans.push_back(make_pair(1,"D")); } if(gx<sx){ rep(i,sx-gx)ans.push_back(make_pair(1,"U")); } if(sy<gy){ rep(j,gy-sy)ans.push_back(make_pair(1,"R")); } if(gy<sy){ rep(j,sy-gy)ans.push_back(make_pair(1,"L")); } } int main(){ input(); int building_cnt=0; rep(i,N)rep(j,N)if(A[i][j]=='#')building_cnt++; int x=-1,y=-1; int cost=1<<30; for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ if(A[i][j]=='@'){//爆弾 x=i; y=j; //break; } } if(x!=-1)break; } //爆弾のある地点に行く mukau(0,0,x,y); //for(int i=0; i<building_cnt; i++){ ans.push_back(make_pair(2,to_string(min_cost_id)));//爆弾を買う //} //スタート地点に戻る for(int i=0; i<x; i++){ ans.push_back(make_pair(1,"U")); } for(int i=0; i<y; i++){ ans.push_back(make_pair(1,"L")); } int cnt=0; for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ if(A[i][j]=='#'||A[i][j]=='@'){ cnt++; ans.push_back(make_pair(3,to_string(min_cost_id))); bakuha(i,j,min_cost_id); } if(i==N-1&&j==N-1)break; else if(j==N-1)ans.push_back(make_pair(1,"D")); else if(i%2==0)ans.push_back(make_pair(1,"R")); else ans.push_back(make_pair(1,"L")); } } cout<<ans.size()<<endl; for(pair<int,string> i:ans){ if(i.first==2){ rep(j,cnt)cout<<i.first<<" "<<i.second<<endl; }else{ cout<<i.first<<" "<<i.second<<endl; } } }