From e8ed5b89bd59750c7dc47be463937196c6a74ce4 Mon Sep 17 00:00:00 2001 From: oncsr Date: Sat, 16 Aug 2025 23:22:07 +0900 Subject: [PATCH] =?UTF-8?q?[20250816]=20BOJ=20/=20G3=20/=20=EC=86=8C?= =?UTF-8?q?=EA=B0=80=20=EA=B8=B8=EC=9D=84=20=EA=B1=B4=EB=84=88=EA=B0=84=20?= =?UTF-8?q?=EC=9D=B4=EC=9C=A0=206=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...352\260\204 \354\235\264\354\234\240 6.md" | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 "khj20006/202508/16 BOJ G3 \354\206\214\352\260\200 \352\270\270\354\235\204 \352\261\264\353\204\210\352\260\204 \354\235\264\354\234\240 6.md" diff --git "a/khj20006/202508/16 BOJ G3 \354\206\214\352\260\200 \352\270\270\354\235\204 \352\261\264\353\204\210\352\260\204 \354\235\264\354\234\240 6.md" "b/khj20006/202508/16 BOJ G3 \354\206\214\352\260\200 \352\270\270\354\235\204 \352\261\264\353\204\210\352\260\204 \354\235\264\354\234\240 6.md" new file mode 100644 index 00000000..48723850 --- /dev/null +++ "b/khj20006/202508/16 BOJ G3 \354\206\214\352\260\200 \352\270\270\354\235\204 \352\261\264\353\204\210\352\260\204 \354\235\264\354\234\240 6.md" @@ -0,0 +1,159 @@ +```java +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +class Point { + long x, y; + Point(long x, long y) { + this.x = x; + this.y = y; + } +} + +public class Main { + + static IOController io; + + // + + static final int INF = (int)1e9 + 7; + static final int[] dx = {0,1,0,-1}; + static final int[] dy = {1,0,-1,0}; + + static int N, K, R; + static int[][][] cost; + static int[][] points; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + static void init() throws Exception { + + N = io.nextInt(); + K = io.nextInt(); + R = io.nextInt(); + cost = new int[N+1][N+1][4]; + for(int i=0;i 0) ans++; + } + } + io.write((ans/2) + "\n"); + + } + + static int[][] dijk(int sx, int sy) { + Deque deque = new ArrayDeque<>(); + int[][] dist = new int[N+1][N+1]; + for(int i=1;i<=N;i++) Arrays.fill(dist[i], INF); + deque.offer(new int[]{0, sx, sy}); + dist[sx][sy] = 0; + while(!deque.isEmpty()) { + int[] cur = deque.pollFirst(); + int d = cur[0], x = cur[1], y = cur[2]; + for(int i=0;i<4;i++) { + int xx = x+dx[i], yy = y+dy[i]; + if(xx<1 || xx>N || yy<1 || yy>N) continue; + int nextCost = d + cost[x][y][i]; + if(dist[xx][yy] > nextCost) { + if(d == nextCost) { + deque.addFirst(new int[]{nextCost, xx, yy}); + } + else { + deque.addLast(new int[]{nextCost, xx, yy}); + } + dist[xx][yy] = nextCost; + } + } + } + return dist; + } + +} +```