-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_15685.cpp
More file actions
65 lines (55 loc) · 1.39 KB
/
bj_15685.cpp
File metadata and controls
65 lines (55 loc) · 1.39 KB
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
// 사다리 조작
#include <iostream>
#include <vector>
#include <cmath>
#define MAX 101
using namespace std;
int map[MAX][MAX];
int xDir[4] = {1, 0, -1, 0}; // 동 북 서 남
int yDir[4] = {0, -1, 0, 1}; // 동, 북, 서, 남
int plusDir(int dir) {
return (dir == 3) ? 0 : dir + 1;
}
void draw(int x, int y, int d, int g) {
int index;
vector<int> dirStack;
map[y][x] = -1; // 드래콘 커브의 시작점
dirStack.push_back(d);
x += xDir[d];
y += yDir[d];
map[y][x] = -1;
for (int i = 0; i < g; i++) {
int total = pow(2, i);
index = dirStack.size() - 1;
for (int j = 0; j < total; j++) {
int nextDir = plusDir(dirStack[index--]);
x += xDir[nextDir];
y += yDir[nextDir];
map[y][x] = -1;
dirStack.push_back(nextDir);
}
index = dirStack.size() - 1;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
int x, y, d, g;
int ans = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x >> y >> d >> g;
draw(x, y, d, g);
}
for (int i = 0; i < MAX; i++) {
for (int j = 0; j < MAX; j++) {
if (map[i][j] == -1) {
if (map[i][j + 1] == -1 && map[i + 1][j] == -1 && map[i + 1][j + 1] == -1) ans++;
}
}
}
cout << ans;
return 0;
}