#include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include //fixed,setprecision #include //INT_MAX #include //M_PI #include #include // 正規表現 #include #include #include #include #include #include #include #include #include #include //複素数 //#include 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 RandInt(int L,int R){ return rand()%(R-L+1)+L; } int N,M; vector A; vector moto_A; vector>>> bomb; vector>tatemono; vector>bakudanya; vectorbakuha_zahyo; int max_cnt_num=1; int max_cnt=0; int min_cost_num=1; int min_cost=1<<30; int bakudan_cnt=0; void input(){ cin>>N>>M; A.resize(N); moto_A.resize(N); for(int i=0; i>A[i]; moto_A[i]=A[i]; } bomb.resize(M); for(int i=0; i>C>>L; bomb[i].first=C;//first:Cost if(min_cost>C){ min_cost=C; min_cost_num=i+1; } if(max_cnt>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){ num--; //cerr<=N||y<0||y>=N)continue; //cerr<<"a"; A[x][y]='.'; } } void mukau(int sx,int sy,int gx,int gy,vector> &ans){ if(sx ido(int nowx,int nowy,int bakuhax,int bakuhay,int num){ num--; int kyori=2500; int gx=10000; int gy=10000; rep(ni,bomb[num].second.size()){ int x=bakuhax-bomb[num].second[ni].first; int y=bakuhay-bomb[num].second[ni].second; //cerr<=N||y<0||y>=N)continue; if(abs(x-nowx)+abs(y-nowy)&bakuha_zahyo,int num){ num--; vectoriranai(bakuha_zahyo.size(),0); vector>masu(N,vector(N,0)); rep(nj,bakuha_zahyo.size()){ int i=bakuha_zahyo[nj]/N; int j=bakuha_zahyo[nj]%N; 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; masu[x][y]++; } } rep(nj,bakuha_zahyo.size()){ int i=bakuha_zahyo[nj]/N; int j=bakuha_zahyo[nj]%N; bool hantei=true; 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; if(masu[x][y]<=1&&moto_A[x][y]!='.')hantei=false; } if(hantei){ iranai[nj]=1; 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; masu[x][y]--; } } } vectoriru; rep(i,bakuha_zahyo.size()){ if(iranai[i]==0){ iru.push_back(bakuha_zahyo[i]); }else{ bakudan_cnt--; } } bakuha_zahyo=iru; } int main(){ int TIMELIMIT=1.5*CLOCKS_PER_SEC; int ti=clock(); vector> ans; //vector> ans_yamanobori; input(); int kind=max_cnt_num; //int kind=min_cost_num; cerr<p=ido(x,y,nx,ny,kind); int ni=p.first; int nj=p.second; //if(nx<0||nx>=N||ny<0||ny>=N)continue; bakuha_zahyo.emplace_back(ni*N+nj); //mukau(x,y,ni,nj,ans); x=ni;y=nj; bakudan_cnt++; //ans.push_back(make_pair(3,to_string(kind))); //cerr< i:ans){ if(i.first==2){ rep(j,bakudan_cnt)cout<