From 4ff62d834285589cc5a3562a980306dc3b307f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Sun, 18 Feb 2024 23:51:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?2024-02-18=20=EB=8B=A8=EC=96=B4=20=EB=A7=88?= =?UTF-8?q?=EB=B0=A9=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Munbin-Lee/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Munbin-Lee/README.md b/Munbin-Lee/README.md index 62bb882d..338919a6 100644 --- a/Munbin-Lee/README.md +++ b/Munbin-Lee/README.md @@ -35,4 +35,5 @@ | 32차시 | 2024.01.30 | 백트래킹 | 하이퍼 토마토 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/124 | | 33차시 | 2024.02.04 | 정수론 | 소수 4개의 합 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/128 | | 34차시 | 2024.02.06 | 구현 | 피자 굽기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/133 | +| 35차시 | 2024.02.18 | 백트래킹 | 단어 마방진 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/140 | --- From b3f3032ca10f23f84a473d4a43ef40d80509863f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AC=B8=EB=B9=88?= <3412mb@gmail.com> Date: Mon, 19 Feb 2024 23:47:38 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Create=2035-=EB=8B=A8=EC=96=B4=20=EB=A7=88?= =?UTF-8?q?=EB=B0=A9=EC=A7=84.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \353\247\210\353\260\251\354\247\204.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" diff --git "a/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" new file mode 100644 index 00000000..2a235c90 --- /dev/null +++ "b/Munbin-Lee/\353\260\261\355\212\270\353\236\230\355\202\271/35-\353\213\250\354\226\264 \353\247\210\353\260\251\354\247\204.py" @@ -0,0 +1,22 @@ +from itertools import permutations + +stdin = open(0) + +L, N = map(int, stdin.readline().split()) +words = sorted(stdin.read().splitlines()) + +# 단어 순열 x가 단어 마방진인지 확인하는 함수 +def isValid(x): + for i in range(L): + for j in range(L): + if x[i][j] != x[j][i]: return False + + return True + +for perm in permutations(words, L): + if not isValid(perm): continue + + print(*perm, sep='\n') + exit() + +print('NONE') \ No newline at end of file