#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 N,M; vector A; vector>>> bomb; void input(){ cin>>N>>M; A.resize(N); for(int i=0; i>A[i]; } bomb.resize(M); for(int i=0; i>C>>L; bomb[i].first=C;//first:Cost for(int j=0; j>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> ans; //爆弾のある地点に行く for(int i=0; i i:ans){ cout<