-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path749_24en23K.cpp
43 lines (37 loc) · 911 Bytes
/
749_24en23K.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
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <unordered_map>
using namespace std;
using lli = long long int;
bool dentro(pair<lli, lli> place, lli x, lli y) {
return place.first >= 0 && place.first < x && place.second >= 0 && place.second < y;
}
int main() {
lli a, b, c;
cin >> a >> b >> c;
while(a != 0) {
unordered_map<lli, unordered_map<lli, bool>>m;
lli sol = (a-1)*b + (b-1)*a;
while(c--) {
lli x, y;
cin >> x >> y;
x--;
y--;
m[y][x] = true;
vector<int>modx = {0,-1, 1, 0};
vector<int>mody = {-1, 0, 0, 1};
for(int i = 0; i < modx.size(); i++) {
lli posy = y+mody[i];
lli posx = x+modx[i];
//cout <<posx <<' '<< posy<< '\n';
if(dentro({posx, posy}, a, b) &&
(m.count(posy) == 0 || m[posy].count(posx) == 0)) {
sol--;
//cout << "--\n";
}
}
}
cout << sol << '\n';
cin >> a >> b >> c;
}
}