#include <iostream>
#include <vector>
#include <stack>
using namespace std;
// dir 0, 1, 2, 3 => x++, y--, x--, y++
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };
int map[102][102] = { 0, };
void SetDragonCurve(int startX, int startY, int d, int g) {
vector<int> direction;
stack<int> s;
direction.push_back(d);
for (int gen = 1; gen <= g; gen++) {
for (auto ele : direction)
s.push(ele);
int dir;
while (!s.empty()) {
dir = s.top();
dir = (dir + 1) % 4;
direction.push_back(dir);
s.pop();
}
}
map[startX][startY] = 1;
int curX = startX, curY = startY;
for (int i = 0; i < direction.size(); i++) {
curX = curX + dx[direction[i]]; // i번째 좌표에서 i+1번째 좌표로 만들기
curY = curY + dy[direction[i]];
// cout << "[" << curX << ", " << curY << "]" << endl;
map[curX][curY] = 1;
}
}
int main()
{
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int N, x, y, d, g;
cin >> N;
for (int line = 0; line < N; line++) {
cin >> x >> y >> d >> g;
SetDragonCurve(x, y, d, g);
}
int ans = 0;
for (int r = 0; r <= 100; r++) {
for (int c = 0; c <= 100; c++) {
if (map[r][c] && map[r][c + 1] && map[r + 1][c] && map[r + 1][c + 1])
ans++;
}
}
cout << ans << endl;
return 0;
}
Leave a comment