-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg276_魔王迷宮.cpp
84 lines (74 loc) · 2.17 KB
/
g276_魔王迷宮.cpp
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
74
75
76
77
78
79
80
81
82
83
84
#include <bits/stdc++.h>
#define int long long
#define X first
#define Y second
#define Cheng0928 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,m,k;
const int X = 1, Y = 2, S = 3, T = 4, out = 5;
/*struct boss{
int X;
int Y;
int S;
int T;
bool out;
};*/
bool check_out(int x, int y){
return (x < m && y < n) && (x >= 0 && y >= 0);
}
void sol(){
//int n,m,k;
cin >> n >> m >> k;
//cout << n << m;
int tmp = n;
n = m;m = tmp;
vector<vector<int>> mp(n+2, vector<int>(m+2, 0));
vector<vector<int>> bosses(k, vector<int>(6, 0));
int b_cnt = k, ans = 0;
for(int i = 0;i<k;i++){
cin >> bosses[i][X] >> bosses[i][Y] >> bosses[i][S] >> bosses[i][T];
if(check_out(bosses[i][X], bosses[i][Y])) bosses[i][out] = 0;
else{
b_cnt--;bosses[i][out] = 1;
}
//cout << bosses[i][X] << ' ' << bosses[i][Y] << ' ' << bosses[i][out] << '\n';
}
while(b_cnt){
vector<pair<int,int>> record;
for(int i = 0;i<k;i++) if(!bosses[i][out]) mp[bosses[i][Y]][bosses[i][X]]++;
for(int i = 0;i < k;i++){
if(!bosses[i][out]){
//mp[bosses[i][Y]][bosses[i][X]]++;
bosses[i][X] += bosses[i][S];
bosses[i][Y] += bosses[i][T];
if(!check_out(bosses[i][X], bosses[i][Y])){
bosses[i][out] = 1;
b_cnt--;
//continue;
}
else if(mp[ bosses[i][Y] ][ bosses[i][X] ]){
b_cnt--;
bosses[i][out] = 1;
record.push_back({bosses[i][X], bosses[i][Y]});
}
}
//cout << bosses[i][X] << ' ' << bosses[i][Y] << ' ' << bosses[i][out] << ' ' << i << '\n';
}
for(int i = 0;i<((signed)record.size());i++){
mp[ record[i].second ][ record[i].first ] = 0;
}
}
for(int i = 0;i<n;i++){
for(int j = 0;j<m;j++) ans+=(mp[i][j] > 0);
//cout << '\n';
}
cout << ans << '\n';
}
signed main()
{
Cheng0928
/*int t;
cin >> t;
while(t--)*/ sol();
return 0;
}