드래곤 커브15685

LJM·2023년 9월 6일
0

백준풀기

목록 보기
222/259

https://www.acmicpc.net/problem/15685

회전을 어떻게 처리할지 아무리 생각해도 좋은 아이디어가 떠오르지 않았다
그냥 방향 정보만 저장하면 되는것이었다...

import java.util.*;
import java.io.*;

class curv{
    int x;
    int y;
    int d;
    int g;

    public curv(int x, int y, int d, int g)
    {
        this.x = x;
        this.y = y;
        this.d = d;
        this.g = d;
    }
}

public class Main {

    public static void main(String[] args) throws IOException{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        StringTokenizer st = null;

        boolean[][] map = new boolean[101][101];

        for(int i = 0; i < n; ++i)
        {
            st = new StringTokenizer(br.readLine(), " ");
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            int d = Integer.parseInt(st.nextToken());
            int g = Integer.parseInt(st.nextToken());

            List<Integer> directions = new ArrayList<>();
            directions.add(d);
            
            //방향 정보만 저장함
            for (int j = 0; j < g; j++) {
                for (int k = directions.size() - 1; k >= 0; k--) {
                    directions.add((directions.get(k) + 1) % 4);
                }
            }
            
            map[x][y] = true;
            for (int dir : directions) {
                if (dir == 0) x++;
                else if (dir == 1) y--;
                else if (dir == 2) x--;
                else if (dir == 3) y++;

                map[x][y] = true;
            }
        }


        int count = 0;
        for (int i = 0; i < 100; i++) {
            for (int j = 0; j < 100; j++) {
                if (map[i][j] && map[i + 1][j] && map[i][j + 1] && map[i + 1][j + 1]) {
                    count++;
                }
            }
        }

        System.out.println(count);

    }


}
profile
게임개발자 백엔드개발자

0개의 댓글