[Python/ํŒŒ์ด์ฌ] [๐Ÿฅ‡5] ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ 10026 - ์ ๋ก์ƒ‰์•ฝ

keyneneยท2022๋…„ 11์›” 3์ผ
0

Python

๋ชฉ๋ก ๋ณด๊ธฐ
19/26
post-custom-banner

๐Ÿ“–[Python/ํŒŒ์ด์ฌ][๐Ÿฅ‡5] ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ 10026 - ์ ๋ก์ƒ‰์•ฝ

๐Ÿ“œ๋ฌธ์ œ



DFS(๊นŠ์ด์šฐ์„ ํƒ์ƒ‰)

์ž„์˜์˜ ํ•œ ๋…ธ๋“œ์—์„œ ์‹œ์ž‘ํ•ด์„œ ๋‹ค์Œ ๋ถ„๊ธฐ๋กœ ๋„˜์–ด๊ฐ€๊ธฐ ์ „์— ํ•ด๋‹น ๋ถ„๊ธฐ๋ฅผ ์™„๋ฒฝํ•˜๊ฒŒ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•
#์žฌ๊ท€ #์ˆœํ™˜ #๋ฌดํ•œ๋ฃจํ”„ํƒˆ์ถœ #Back-Tracking


๐Ÿ“•ํ’€์ด๋ฐฉํ–ฅ

๋‚ด ํฌ์ŠคํŒ… : [Python/ํŒŒ์ด์ฌ] [๐Ÿฅˆ1] ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ 2583 - ์˜์—ญ ๊ตฌํ•˜๊ธฐ
์ด์ „ ํฌ์ŠคํŒ…๊ณผ ๊ฐ™์ด 4๋ฐฉํ–ฅ ํƒ์ƒ‰ DFS๋กœ๋„ ์ ‘๊ทผ๊ฐ€๋Šฅํ•˜์ง€๋งŒ,
dx, dy๋ฅผ ์ด์šฉํ•œ DFS์•Œ๊ณ ๋ฆฌ์ฆ˜ ์œผ๋กœ ํ’€์ดํ•ด๋ณด๋ ค ํ•œ๋‹ค.

n, RGB์ •๋ณด๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ ์ €์žฅํ•˜๊ณ  visited(๋ฐฉ๋ฌธํ™•์ธ์šฉ list)๋ฅผ False๋กœ ์ดˆ๊ธฐํ™”ํ•˜์—ฌ,
visited๊ฐ€ False์ผ ๋•Œ dfs(x,y)์‹คํ–‰ ํ›„ True๋กœ ์ €์žฅํ•˜๋ฉด์„œ ๊ฐ ์˜์—ญ์˜ ๊ฐœ์ˆ˜๋ฅผ ์นด์šดํŒ…ํ•˜์ž

โ•โ—์ฃผ์˜์‚ฌํ•ญ
์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ ์‚ฌ๋žŒ์€ 'R', 'G'๋ฅผ ์„œ๋กœ ๋‹ค๋ฅธ ์˜์—ญ์œผ๋กœ ์ธ์ง€ํ•˜๊ณ ,
์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์€ 'R', 'G'๋ฅผ ํ•˜๋‚˜์˜ ์˜์—ญ์œผ๋กœ ์ธ์ง€ํ•œ๋‹ค.

์ด๋ฅผ ์ฃผ์˜ํ•˜์—ฌ ๊ตฌํ˜„ํ•˜์ž


๐Ÿ“์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ตฌํ˜„์ˆœ์„œ

  1. n๊ณผ rgb์ •๋ณด๋ฅผ amap(list) ์ €์žฅํ•˜์—ฌ for loof์„ ์ด์šฉํ•ด
    ์šฐ์„  ์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ์‚ฌ๋žŒ์˜ ์˜์—ญ์„ ์นด์šดํŒ…ํ•˜์ž
  2. for loof์„ ์ด์šฉํ•ด amap์— 'R'์„ 'G'๋กœ ๋ฐ”๊ฟ”์ฃผ๊ณ 
    ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์˜ ์˜์—ญ์„ ์นด์šดํŒ…ํ•˜์ž

๐Ÿ’ป๊ฒฐ๊ณผ์ฝ”๋“œ

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

#์˜์—ญ๊ตฌํ•˜๊ธฐ
def dfs(x,y):
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    visited[y][x] = True
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if 0<=nx<n and 0<=ny<n and amap[y][x] == amap[ny][nx] and not visited[ny][nx]:
            dfs(nx,ny)

#์ž…๋ ฅ๊ฐ’ ๋ฐ›์•„ ์ €์žฅํ•˜๊ธฐ
n = int(input().rstrip())
amap = [list(map(str, input().rstrip())) for _ in range(n)]
visited = [[False]*n for _ in range(n)]
acnt = 0   #์ ๋ก์ƒ‰์•ฝ ์•„๋‹Œ์‚ฌ๋žŒ์šฉ ์นด์šดํŒ… ๋ณ€์ˆ˜
rgcnt = 0  #์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์šฉ ์นด์šดํŒ… ๋ณ€์ˆ˜

#์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ ์‚ฌ๋žŒ dfs()ํ˜ธ์ถœํ•˜๋ฉด์„œ ์˜์—ญ ๊ฐœ์ˆ˜ ์นด์šดํŒ…
for y in range(n):
    for x in range(n):
        if not visited[y][x]:
            dfs(x,y)
            acnt += 1

#'R' โ†’ 'G' : ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์šฉ map๋งŒ๋“ค๊ธฐ (์ ๋ก์ƒ‰์•ฝ : R==G ์ด๋ฏ€๋กœ)
for y in range(n):
    for x in range(n):
        if amap[y][x] == 'R':
            amap[y][x] = 'G'

#์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ dfs()ํ˜ธ์ถœํ•˜๋ฉด์„œ ์˜์—ญ ๊ฐœ์ˆ˜ ์นด์šดํŒ…
visited = [[False]*n for _ in range(n)]
for y in range(n):
    for x in range(n):
        if not visited[y][x]:
            dfs(x,y)
            rgcnt += 1

print(acnt, rgcnt)

โœ๏ธ1. n, rgb์ •๋ณด ์ €์žฅ ํ›„ ์ ๋ก์ƒ‰์•ฝ ์•„๋‹Œ ์‚ฌ๋žŒ์˜ ์˜์—ญ๊ฐœ์ˆ˜ ์นด์šดํŒ…

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)  #dfs๊นŠ์ด ๋Š˜๋ฆฌ๊ธฐ (๋ฐฑ์ค€์€ 1000์ด๋ผ ๋Ÿฐํƒ€์ž„์—๋Ÿฌ๋‚˜๋‹ˆ๊นŒ)

#์˜์—ญ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ
def dfs(x,y):
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    visited[y][x] = True  #์žฌ๋ฐฉ๋ฌธํ•˜์ง€ ์•Š๋„๋ก ๋ฐฉ๋ฌธํ”์  ๋‚จ๊ธฐ๊ธฐ
    
    #์•„๋ž˜ dx,dy๋งŒ์˜ for loof์„ ์ด์šฉํ•˜์—ฌ dfs๊ฐ€ 4๋ฒˆ ์žฌํ˜ธ์ถœ ๋˜๋Š”๊ฑธ ๋ฐฉ์ง€
    #ํ•„์ž๋Š” ์ด์ „๊นŒ์ง€ dfs(x-1,y), dfs(x+1,y) ์ด๋Ÿฐ์‹์œผ๋กœ 4๋ฒˆ ํ˜ธ์ถœํ–ˆ์—ˆ์Œ...
    for i in range(4):
        nx = x+dx[i]  #x+dx[i] ๋กœ ํ˜„์žฌ์˜ nx๊ฐ’ ์ €์žฅ
        ny = y+dy[i]  #y+dy[i] ๋กœ ํ˜„์žฌ์˜ ny๊ฐ’ ์ €์žฅ
        
        #ํ˜„์žฌ nx,ny๊ฐ€ map์˜์—ญ์„ ๋ฒ—์–ด๋‚˜์ง€ ์•Š๊ฑฐ๋‚˜, ๋ฐฉ๋ฌธํ”์ ์ด ์—†์„๋•Œ๋งŒ dfsํ˜ธ์ถœ
        if 0<=nx<n and 0<=ny<n and amap[y][x] == amap[ny][nx] and not visited[ny][nx]:
            dfs(nx,ny)

n = int(input().rstrip())
amap = [list(map(str, input().rstrip())) for _ in range(n)]
visited = [[False]*n for _ in range(n)]
acnt = 0

#์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ ์‚ฌ๋žŒ ์˜์—ญ ๊ฐœ์ˆ˜ ์นด์šดํŒ…
for y in range(n):
    for x in range(n):
        if not visited[y][x]: #๋ฐฉ๋ฌธํ”์ ์ด ์—†์œผ๋ฉด
            dfs(x,y)          #dfs(x,y)ํ˜ธ์ถœํ•˜์—ฌ ๋ฐฉ๋ฌธํ”์  ๋‚จ๊ธฐ๊ณ ,
            acnt += 1         #์˜์—ญ ๊ฐœ์ˆ˜ ์นด์šดํŒ…

โœ๏ธ2. ์ ๋ก์ƒ‰์•ฝ์šฉ map๋งŒ๋“ค๊ณ , ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์˜ ์˜์—ญ๊ฐœ์ˆ˜ ์นด์šดํŒ…

#dfs๋‚ด์šฉ์€ ์œ„ 1๋ฒˆ๊ณผ ๊ฐ™์Œ
def dfs(x,y):
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    visited[y][x] = True
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if 0<=nx<n and 0<=ny<n and amap[y][x] == amap[ny][nx] and not visited[ny][nx]:
            dfs(nx,ny)

#์ ๋ก์ƒ‰์•ฝ์šฉ map๋งŒ๋“ค๊ธฐ (amap์˜ Rโ†’G)
#์ ๋ก์ƒ‰์•ฝ์€ R==G๋กœ ์ธ์‹ํ•˜๊ธฐ ๋•Œ๋ฌธ!
for y in range(n):
    for x in range(n):
        if amap[y][x] == 'R':
            amap[y][x] = 'G'

#์ ๋ก์ƒ‰์•ฝ์˜ ์˜์—ญ ๊ฐœ์ˆ˜ ์นด์šดํŒ…
rgcnt = 0
visited = [[False]*n for _ in range(n)]  #์œ„์—์„œ ๋”๋ŸฝํžŒ ๋ฐฉ๋ฌธํ”์  ์ดˆ๊ธฐํ™”
for y in range(n):
    for x in range(n):
        if not visited[y][x]:
            dfs(x,y)
            rgcnt += 1

print(acnt, rgcnt)

๐Ÿ“š์ดˆ๊ธฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ์ •๋ฆฌ

๐Ÿ™‹๐Ÿปโ€โ™€๏ธ1๋ฒˆ์งธ ์ดˆ๊ธฐ ์ฝ”๋“œ ์•„์ด๋””์–ด

1. ์ผ๋‹จ R,G,B๋กœ ํ•˜๋ฉด ๋ญ”๊ฐ€ ์˜ค๋ฅ˜๊ฐ€ ์žˆ์„ ๊ฒƒ ๊ฐ™์œผ๋‹ˆ๊นŒ R=0, B=1, G=2๋กœ ๋ณด๊ธฐ์ข‹๊ฒŒ ๋งคํ•‘ํ•˜์ž
(์™œ??? ์•„์ง ์ €๋ ‡๊ฒŒ ์ƒ๊ฐํ•œ ์ด์œ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์Œ.. ๊ทธ๋ž˜๋„ ๋ฌธ์ž๋“  ์ˆซ์ž๋“  ์ทจํ–ฅ์ฐจ์ด๋‹ˆ๊นŒ ๋„˜์–ด๊ฐ€์ž..)

2. ๊ทธ๋ฆฌ๊ณ  for loof ํ•œ ๋ฒˆ์— ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ๊ณผ ์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ ์‚ฌ๋žŒ์˜ map์„ 
"ํ•œ๊บผ๋ฒˆ์—"ํ™•์ธํ•˜๋ฉด์„œ ์นด์šดํŒ…ํ•˜๊ณ ์‹ถ๋‹ค.
(๊ฐ™์€ ๊นŠ์ด์˜ for loof์€ 1๋ฒˆ์ด๋“  2๋ฒˆ์ด๋“  ์‹œ๊ฐ„๋ณต์žก๋„๋Š” ๋˜‘๊ฐ™์€๋ฐ... ๊ทธ๋ž˜๋„ ์ ‘๊ทผ์€ ์ข‹๋‹ค)

3. ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ๊ณผ ์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ์‚ฌ๋žŒ์˜ map์„ ๋”ฐ๋กœ ๋งŒ๋“ค์ž - ํ•œ๊บผ๋ฒˆ์— ๋Œ๋ ค์•ผ ํ•˜๋‹ˆ๊นŒ
(list ๋ฉ”๋ชจ๋ฆฌ 2๋ฐฐ๋กœ ์žก์•„๋จน๊ณ ~๐Ÿคฆ๐Ÿปโ€โ™€๏ธ)

4. dfs์—์„œ ๋ฐฉ๋ฌธํ•œ ์˜์—ญ์€ amap/rgmap์— 3์œผ๋กœ ๋งคํ•‘ํ•˜์ž - ์žฌ๋ฐฉ๋ฌธํ•˜๋ฉด ์•ˆ๋˜๋‹ˆ๊นŒ
(visited ๋ฆฌ์ŠคํŠธ๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ฒดํฌํ•˜๋ฉด ์›๋ž˜์˜ amap/rgmap์ด ๋”๋Ÿฌ์›Œ์ง€์ง€ ์•Š์„ํ…๋ฐ)

์ฝ”๋“œ

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)

n = int(input().rstrip())
graph = [list(input().rstrip()) for _ in range(n)]
amap = []
rgmap = []
acnt = 0
rgcnt = 0

#์˜์—ญ ๊ฐœ์ˆ˜ ๊ตฌํ•˜๊ธฐ
#4๋ฒˆ์งธ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ํ˜„์žฌ์˜ ์ˆซ์ž(num)๋ฅผ ๋ฐ›์Œ์œผ๋กœ์จ, num์ด ์•„๋‹Œ ๊ณณ์€ ๊ฒ€์‚ฌํ•˜์ง€ ์•Š์Œ
def dfs(x,y,map,num):
    if x<0 or y<0 or x>=n or y>=n:
        return
    if map[y][x] == 3 and map[y][x] != num:
        return
    elif map[y][x] == num:
        map[y][x] = 3
        dfs(x-1,y,map,num)
        dfs(x,y-1,map,num)
        dfs(x+1,y,map,num)
        dfs(x,y+1,map,num)
        return
    else:
        return

#์ ๋ก์ƒ‰์•ฝ ์•„๋‹Œ์‚ฌ๋žŒ์šฉ, ์ ๋ก์ƒ‰์•ฝ์šฉ map ๋งŒ๋“ค๊ธฐ
for rgb in graph:
    string = 0
    num = ''    #์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ์‚ฌ๋žŒ์˜ amap์— ๋งคํ•‘๋  str
    rgnum = ''  #์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์˜ rgmap์— ๋งคํ•‘๋  str
    for string in rgb:
        if string == 'R':
            num += str(0)+' '
            rgnum += str(0)+' '  #์ ๋ก์ƒ‰์•ฝ์€ R==G๋‹ˆ๊นŒ
        elif string == 'B':
            num += str(1)+' '
            rgnum += str(1)+' '
        elif string == 'G':
            num += str(2)+' '
            rgnum += str(0)+' '  #์ ๋ก์ƒ‰์•ฝ์€ R==G๋‹ˆ๊นŒ
    amap.append(list(map(int, num.split())))
    rgmap.append(list(map(int, rgnum.split())))

#amap, rgmap ๋™์‹œ์— ๋Œ๋ฆฌ๋ฉด์„œ ์˜์—ญ๊ตฌํ•˜๊ณ  ๋ฐฉ๋ฌธํ•œ ์˜์—ญ์€ 3์œผ๋กœ ๋งคํ•‘
for y in range(n):
    for x in range(n):
        if amap[y][x] != 3:
            dfs(x,y,amap,amap[y][x])  
            acnt += 1
        if rgmap[y][x] != 3:
            dfs(x,y,rgmap,rgmap[y][x])
            rgcnt += 1

print(acnt, rgcnt, sep=' ')

๐Ÿ™‹๐Ÿปโ€โ™€๏ธ2๋ฒˆ์งธ ์ดˆ๊ธฐ ์ฝ”๋“œ ์•„์ด๋””์–ด

R=0, B=1, G=2 ๋งคํ•‘ํ•˜๋Š” ๊ฑด ๋˜‘๊ฐ™๊ณ  ๋™์ž‘๋„ ๋˜‘๊ฐ™์€๋ฐ visited๋ฅผ ์ถ”๊ฐ€ํ–ˆ๊ณ ,
dfs()์•ˆ์—์„œ R(0)โ†’G(2)๋กœ ๋ณ€๊ฒฝํ•˜์—ฌ ์ ๋ก์ƒ‰์•ฝ์šฉ map์œผ๋กœ ๋งŒ๋“ค์—ˆ์Œ
๐Ÿ‘‰๐Ÿป๊ฒฐ๋ก  : ๋ฉ”๋ชจ๋ฆฌ๋Š” ๋” ์žก์•„๋จน๊ณ  ์‹œ๊ฐ„์ด 30ms ์ค„์–ด๋“ฆ๐Ÿคฃ

1. for loof๋กœ ๋™์‹œ์— ์นด์šดํŒ…ํ•˜๋Š” ์•„์ด๋””์–ด๋Š” ๋ฒ„๋ฆฌ๊ณ , visited๋ฅผ ๋งŒ๋“ค์ž.
   ์ ๋ก์ƒ‰์•ฝ์ด ์•„๋‹Œ ์‚ฌ๋žŒ์˜ amap์„ dfs()๋กœ ๊ฒ€์‚ฌํ•˜๋ฉด์„œ ๋ฐฉ๋ฌธํ”์ ์„ ๋‚จ๊ธฐ๊ณ ,
   dfs()์•ˆ์—์„œ R์„ ์ฐพ์•„ G๋กœ amap์„ ๋ณ€๊ฒฝํ•˜์—ฌ ์ ๋ก์ƒ‰์•ฝ์šฉ map์„ ๋งŒ๋“ค์–ด์ฃผ์ž
   (for loor๋ฅผ ๋‘ ๋ฒˆ ๋Œ๊ธด ํ•˜์ง€๋งŒ ์‹œ๊ฐ„๋ณต์žก๋„๋Š” ๋˜‘๊ฐ™์•„์„œ ์ ‘๊ทผ์€ ์ข‹์•˜์œผ๋‚˜..
   ์ด๋Ÿฌ๋ฉด์„œ dfs์•ˆ์—์„œ R์ผ๋•Œ์˜ ์กฐ๊ฑด์‹์ด ์ถ”๊ฐ€๋˜์–ด์„œ... ์ทจํ–ฅ์ฐจ์ด ์ธ๊ฑธ๋กœ)
   
2. ๋งŒ๋“ค์–ด์ง„ map์„ ์ด์šฉํ•˜์—ฌ ์ ๋ก์ƒ‰์•ฝ์ธ ์‚ฌ๋žŒ์˜ ์˜์—ญ์„ ์นด์šดํŒ…ํ•˜์ž

์ฝ”๋“œ

import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

n = int(input().rstrip())
rgb = [list(map(str, input().rstrip())) for _ in range(n)]
amap = []
visited = [[0 for _ in range(n)] for _ in range(n)]
cnt = 0
res = []

def dfs(x,y,num):
    if x<0 or y<0 or x>=n or y>=n:
        return
    if visited[y][x] == 1 or amap[y][x] != num:
        return
    elif amap[y][x] == num:
        visited[y][x] = 1
        if num == 2:
            amap[y][x] = 0
        dfs(x-1,y,num)
        dfs(x,y-1,num)
        dfs(x+1,y,num)
        dfs(x,y+1,num)
        return
    
for string in rgb:
    num = ''
    for al in string:
        if al == 'R':
            num += str(0)+' '
        elif al == 'B':
            num += str(1)+' '
        elif al == 'G':
            num += str(2)+' '
    amap.append(list(map(int, num.split())))

for y in range(n):
    for x in range(n):
        if not visited[y][x]:
            dfs(x,y,amap[y][x])
            cnt += 1
res.append(cnt)

cnt = 0
visited = [[0 for _ in range(n)] for _ in range(n)]
for y in range(n):
    for x in range(n):
        if not visited[y][x]:
            dfs(x,y,amap[y][x])
            cnt += 1
res.append(cnt)
print(*res)

์ •๋ฆฌ

  1. ์ด๋Ÿฐ ๊ณผ์ •์„ ๊ฑฐ์ณ ์ฐพ์€ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์ œ์ผ ์ƒ๋‹จ์— ์–ธ๊ธ‰ํ•œ dx,dy๋ฅผ ์ด์šฉํ•œ DFS ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๊ณ ,
    '๋ฌธ์ž โ†’ ์ˆซ์ž' ์น˜ํ™˜ํ•˜๋Š” ๊ณผ์ •์ด ์ค„์–ด๋“ค์–ด ์‹œ๊ฐ„๋„ ๋นจ๋ผ์กŒ๋‹ค.
  2. ๊ทธ๋ฆฌ๊ณ  ์›๋ž˜ ์ฝ”๋“œ์—์„œ ๋ฌธ์ž๋ฅผ ์ €์žฅํ–ˆ๋˜ 'rgb'๋ผ๋Š” list๊ฐ€ ์ตœ์ข… ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ๋Š” ๊ทธ๋ƒฅ
    map ๊ทธ ์ž์ฒด๊ฐ€ ๋˜์–ด๋ฒ„๋ ค์„œ rgb๋ฅผ ์ €์žฅํ–ˆ๋˜ ๋ฉ”๋ชจ๋ฆฌ ๋‚ญ๋น„๋„ ์ค„์—ˆ๋‹ค

์ •์„์œผ๋กœ 4๋ฐฉํ–ฅ ํƒ์ƒ‰ํ•˜๋Š” DFS์•Œ๊ณ ๋ฆฌ์ฆ˜๋„ ์ข‹์ง€๋งŒ, dx,dy๋ฅผ ์ด์šฉํ•œ DFS์•Œ๊ณ ๋ฆฌ์ฆ˜๋„ ์—ฐ์Šตํ•ด๋ณด์ž
+์ฒซ ๊ณจ๋“œ ๋ฌธ์ œ๋ฅผ ๋ชป ํ‘ผ๊ฒŒ ์ข€ ์•„์‰ฝ๋‹ค.. ์‹ค๋ฒ„ ๋ฌธ์ œ๋ž‘ ์ฐจ์›์ด ์ข€ ๋‹ค๋ฅธ ๊ฒƒ ๊ฐ™๋‹ค๐Ÿ˜…

profile
keynene
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€