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 | --- 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