1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <bits/stdc++.h> #define ll long long #define ld long double #define int long long #define N 100 #define Orz ios::sync_with_stdio(0),cin.tie(0) #define INF 2e18 #define rep(i,l,r) for(int i=l;i<=r;i++) #define all(x) x.begin(),x.end() #define pii pair<int,int> #define x first #define y second using namespace std; int n,m,k; bool maze[N][N],bomb[N][N];
struct node{ int x,y,s,t; bool alive; }mp[505];
signed main(){ Orz; memset(maze,0,sizeof(maze)); cin>>n>>m>>k; rep(i,0,k-1){ cin>>mp[i].x>>mp[i].y; cin>>mp[i].s>>mp[i].t; mp[i].alive = 1; } int now_alive = k; while(now_alive){ memset(bomb,0,sizeof(bomb)); for(int p=0;p<k;p++){ if(mp[p].alive == 0)continue; int i = mp[p].x,j = mp[p].y; maze[i][j] = 1; } for(int p=0;p<k;p++){ if(mp[p].alive == 0)continue; int i = mp[p].x,j = mp[p].y; int nx = i + mp[p].s; int ny = j + mp[p].t; if(nx >= n || nx < 0 || ny >= m ||ny < 0){ now_alive--; mp[p].alive = 0; } else if(maze[nx][ny]){ now_alive--; mp[p].alive = 0; bomb[nx][ny] = 1; } else{ mp[p].x = nx; mp[p].y = ny; } } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(bomb[i][j] == 1) maze[i][j] = 0; } } } int ans = 0; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(maze[i][j])ans++; } } cout<<ans<<endl; }
|