From 9d27fa1454afeaaab01cc9e8ad03c42c415bca33 Mon Sep 17 00:00:00 2001 From: jaminleee Date: Mon, 28 Aug 2023 00:45:46 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Create=20[RGB=EA=B1=B0=EB=A6=AC]=20jamin.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 8196 bytes .../RGB\352\261\260\353\246\254/jamin.py" | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 .DS_Store create mode 100644 "Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/RGB\352\261\260\353\246\254/jamin.py" diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..035c31a04e57b2a121d2791020eab51026a107e9 GIT binary patch literal 8196 zcmeHM&1(}u6n~>ZW9uQd6hv|up{NxUdlB`ttq}x!C`M5{wP`|9XxvcStL{G{UV3P; zi1>x#MMSZP;J3Fz5rrNE58_S1-+X9in%%UCB0=ATncpz;-kbM+Gqba^AtEt2UF;{? zPDE*Bg_%wiF-i5ST$eW3mMl;}pC-!v`LVECtCQpgW`G%B2ABb6fEj2P25@GplukJJ zO)rzW_ zZ%O&rL&G!)zse{_sfu3-wF~feAIbTpTZ;=B)KApSq`0}MIc+zd<0GFBKmDM2Zen~l z&ekk=@o#;h;_qq{|NTP?**DP>e+|>wJL}bRW8U`m#@zc3y}s8qrWUo&QGi z-ZQoKo}aqi_j2gr%&WV42UV~>NA+&XV~3lawbPGd*Ga_Dk{vhB<*Q?tOJXlvz( z@w>J>o+vOWI!LW`1Y^v|HqQQ|F@;@>=ZM=4Ez}eL@Jlh4Z@a4u&0iDi9CX= zl9G!IY84dvjR2^x Date: Sun, 10 Sep 2023 03:26:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Create=20[=EB=85=B9=EC=83=89=20=EC=98=B7=20?= =?UTF-8?q?=EC=9E=85=EC=9D=80=20=EC=95=A0=EA=B0=80=20=EC=A0=A4=EB=8B=A4?= =?UTF-8?q?=EC=A7=80=3F]=20jamin.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jamin.py" | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 "Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" diff --git "a/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" new file mode 100644 index 00000000..c575a7be --- /dev/null +++ "b/Baekjoon - \353\254\270\354\240\234\355\222\200\354\235\264/\353\205\271\354\203\211 \354\230\267 \354\236\205\354\235\200 \354\225\240\352\260\200 \354\240\244\353\213\244\354\247\200?/jamin.py" @@ -0,0 +1,30 @@ +import sys +from heapq import heappush,heappop +input = sys.stdin.readline +dx = [-1,1,0,0] +dy = [0,0,-1,1] + +case = 1 + +while True: + N = int(input()) + if N == 0: + break + cave = [list(map(int,input().split())) for _ in range(N)] + visited = [[-1 for _ in range(N)]for _ in range(N)] + heap = [] + heappush(heap,[cave[0][0],0,0]) + visited[0][0] = 0 + while heap: + answer,x,y = heappop(heap) + if [x,y] == [N-1,N-1]: + print("Problem",case,end = "") + print(":",answer) + for i in range(4): + ax = x + dx[i] + ay = y + dy[i] + if 0<= ax < N and 0 <= ay < N: + if visited[ax][ay] == -1: + heappush(heap, [answer+cave[ax][ay],ax,ay]) + visited[ax][ay] = 0 + case += 1 \ No newline at end of file