๋ฐฑ์ค15649๋ฒ ํ์ด์ฌ N๊ณผM #12-1) ๋ฐฑํธ๋ํน
๋ด ํ์ด def back (d,n,m): if d==m: print(*ans) return for i in range(n): if not visit[i]: visit[i]=True ans.append(i+1) back(d+1,n,m) ans.pop() visit[i]=False n,m=map(int,input().split()) visit=[False]*n ans=[] back(0,n,m) ์ ์ ์๋ ๋๋ง ์์๋ณผ ๊ฒ ๊ฐ์ ํ์ด... ๋ค๋ฅธ ํ์ด (๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฌ์ฉํ ๊ฒฝ์ฐ) from itertools import permutations n, m = map(int, input().split()) l = list(range(1, n + 1)) res = (list(permutations(l, m))) for i i..
2020. 10. 19.
๋ฐฑ์ค1018๋ฒ ํ์ด์ฌ #11๋ธ๋ฃจํธํฌ์ค-4)์ฒด์คํ ๋ค์ ์น ํ๊ธฐ
๋์ ์ฝ๋ ๊ฒฐ๋ก ์ ์ผ๋ก ํ์ธ์ ์ฝ๋๋ฅผ ์ฐธ์กฐํ๋ค..^^ If๋ฌธ์ผ๋ก ๋๋ฆฌ๋จ def cheseu(b,n,m): cnt=0 for ni in range(n,n+8): for nk in range(m,m+8): if (ni+nk)%2==0 and b[ni][nk]=='B': cnt+=1 if (ni+nk)%2==1 and b[ni][nk]=='W': cnt+=1 change=min(cnt,64-cnt) return change n,m=map(int,input().split()) board=[input() for x in range(n)] ans=[] for i in range(0,n-7): for k in range(0,m-7): ans.append(cheseu(board,i,k)) print(min(ans)) ํ..
2020. 10. 15.