-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2869.cpp
48 lines (37 loc) · 848 Bytes
/
P2869.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
#include <iostream>
using namespace std;
char graph[10001][10001] = {};
int maxY = 0;
int maxX = 0;
int result = 0;
void find(int sx, int sy) {
for(int i = sy; i >= 1; i--) {
result++;
if(graph[sy][sx] == 1 || graph[sy][sx] == 2)
return;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
cin >> N;
for(int i = 0; i < N; i++) {
int Y, X1, X2;
cin >> Y >> X1 >> X2;
maxY = max(maxY, Y);
maxX = max(maxX, X2);
for(int j = X1; j <= X2; j++) {
graph[Y][j] = 2;
}
graph[Y][X1] = graph[Y][X2] = 1;
}
for(int i = maxY; i >= 1; i--) {
for(int j = 1; j <= maxX; j++) {
if(graph[i][j]) find(j, i);
}
}
cout << result - 2;
return 0;
}