結果
| 問題 | No.5019 Hakai Project |
| コンテスト | |
| ユーザー |
かえで
|
| 提出日時 | 2023-11-18 20:35:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 3,000 ms |
| コード長 | 3,354 bytes |
| 記録 | |
| コンパイル時間 | 2,316 ms |
| コンパイル使用メモリ | 201,232 KB |
| 実行使用メモリ | 6,676 KB |
| スコア | 2,525 |
| 最終ジャッジ日時 | 2023-11-18 20:35:22 |
| 合計ジャッジ時間 | 8,670 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
#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;
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;
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]='.';
}
}
int main(){
input();
int building_cnt=0;
rep(i,N)rep(j,N)if(A[i][j]=='#')building_cnt++;
int x=-1,y=-1;
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;
}
vector<pair<int,string>> ans;
//爆弾のある地点に行く
for(int i=0; i<x; i++){
ans.push_back(make_pair(1,"D"));
}
for(int i=0; i<y; i++){
ans.push_back(make_pair(1,"R"));
}
for(int i=0; i<building_cnt; i++){
ans.push_back(make_pair(2,to_string(1)));//爆弾を買う
}
//スタート地点に戻る
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"));
}
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
if(A[i][j]=='#'){
ans.push_back(make_pair(3,to_string(1)));
bakuha(i,j,1);
}
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){
cout<<i.first<<" "<<i.second<<endl;
}
}
かえで