Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- class Point {
- public:
- int x, y;
- Point(int _x, int _y) {
- x = _x;
- y = _y;
- }
- };
- int main() {
- int n;
- cin >> n;
- //오른쪽, 위, 왼쪽, 아래
- int dx[] = { 1, 0, -1, 0 };
- int dy[] = { 0, -1, 0, 1 };
- bool arr[101][101] = { false };
- //배열 채우기
- for (int t = 0; t < n; t++) {
- vector<int> direction;
- int x, y, d, g;
- cin >> x >> y >> d >> g;
- direction.push_back(d);
- arr[x][y] = true;
- arr[x + dx[d]][y + dy[d]] = true;
- Point last = Point(x + dx[d], y + dy[d]);// 마지막 지점
- while (g--) {
- int size = direction.size();//시계방향으로 돌릴 드래곤 개수
- int mul = 1;
- bool isLeft = true;//왼쪽인가, 오른쪽인가
- for (int i = size - 1; i >= 0; i-=mul) {
- for (int j = i; j > i - mul; j--) {
- int nd = direction[i];
- if (isLeft) nd = (nd + 1) % 4;
- else nd = (nd - 1 + 4) % 4;
- int nx = last.x + dx[nd];
- int ny = last.y + dy[nd];
- arr[nx][ny] = true;
- direction.push_back(nd);
- //last 갱신
- last = Point(nx, ny);
- }
- mul *-2;
- isLeft != isLeft;
- }
- }
- }
- //정답 확인
- int ans = 0;
- for (int i = 0; i < 100; i++) {
- for (int j = 0; j < 100; j++) {
- if (arr[i][j] && arr[i + 1][j] && arr[i][j + 1] && arr[i + 1][j + 1])
- ans++;
- }
- }
- cout << ans;
- return 0;
- }
Add Comment
Please, Sign In to add comment