4๏ธโฃ Python56 [Python Algorithm] ๊ณตํต ๋ถ๋ถ ๋ฌธ์์ด BOJ #5582 ๋ฌธ์ https://www.acmicpc.net/problem/5582 5582๋ฒ: ๊ณตํต ๋ถ๋ถ ๋ฌธ์์ด ๋ ๋ฌธ์์ด์ด ์ฃผ์ด์ก์ ๋, ๋ ๋ฌธ์์ด์ ๋ชจ๋ ํฌํจ๋ ๊ฐ์ฅ ๊ธด ๊ณตํต ๋ถ๋ถ ๋ฌธ์์ด์ ์ฐพ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ์ด๋ค ๋ฌธ์์ด s์ ๋ถ๋ถ ๋ฌธ์์ด t๋, s์ t๊ฐ ์ฐ์์ผ๋ก ๋ํ๋๋ ๊ฒ์ ๋งํ๋ค. ์๋ฅผ ๋ค www.acmicpc.net ๋ด ๋ฌธ์ ํ์ด import sys a = sys.stdin.readline().strip() b = sys.stdin.readline().strip() cnt = [[0 for _ in range(len(b) + 1)] for _ in range(len(a) + 1)] for i in range(len(a)): for j in range(len(b)): if a[i] == b[j].. 2022. 5. 24. [Python Algorithm] N๊ณผ M (4) BOJ #15652 ๋ฌธ์ https://www.acmicpc.net/problem/15652 15652๋ฒ: N๊ณผ M (4) ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด www.acmicpc.net ๋ด ๋ฌธ์ ํ์ด n, m = map(int, input().split()) tmp = [] def dfs(): if len(tmp) == m: print(' '.join(map(str, tmp))) return for i in range(1, n+1): if len(tmp) == 0 or tmp[-1] 2022. 2. 15. [Python Algorithm] N๊ณผ M (3) BOJ #15651 ๋ฌธ์ https://www.acmicpc.net/problem/15651 15651๋ฒ: N๊ณผ M (3) ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด www.acmicpc.net ๋ด ๋ฌธ์ ํ์ด n, m = map(int, input().split()) tmp = [] result = [] def dfs(): if len(tmp) == m: print(' '.join(map(str, tmp))) return for i in range(1, n+1): tmp.append(i) dfs() tmp.pop() dfs() ๐ ๋ฐฑํธ๋ํน ๋ฌธ์ ! (https://seolhee27.. 2022. 2. 15. [Python Algorithm] N๊ณผ M (2) BOJ #15650 ๋ฌธ์ https://www.acmicpc.net/problem/15650 15650๋ฒ: N๊ณผ M (2) ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด www.acmicpc.net ๋ด ๋ฌธ์ ํ์ด n, m = map(int, input().split()) tmp = [] def dfs(): if len(tmp) == m: print(' '.join(map(str, tmp))) return for i in range(1, n+1): if len(tmp) == 0 or tmp[-1] < i: tmp.append(i) dfs() tmp.pop() dfs() ๐ ๋ฐฑํธ๋ํน ๋ฌธ์ .. 2022. 2. 15. [Python Algorithm] N๊ณผ M (1) BOJ #15649 ๋ฌธ์ https://www.acmicpc.net/problem/15649 15649๋ฒ: N๊ณผ M (1) ํ ์ค์ ํ๋์ฉ ๋ฌธ์ ์ ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์ด์ ์ถ๋ ฅํ๋ค. ์ค๋ณต๋๋ ์์ด์ ์ฌ๋ฌ ๋ฒ ์ถ๋ ฅํ๋ฉด ์๋๋ฉฐ, ๊ฐ ์์ด์ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํด์ ์ถ๋ ฅํด์ผ ํ๋ค. ์์ด์ ์ฌ์ ์์ผ๋ก ์ฆ๊ฐํ๋ ์์๋ก ์ถ๋ ฅํด www.acmicpc.net ๋ด ๋ฌธ์ ํ์ด n, m = map(int, input().split()) tmp = [] def dfs(): if len(tmp) == m: print(' '.join(map(str, tmp))) return for i in range(1, n+1): if i not in tmp: tmp.append(i) dfs() tmp.pop() dfs() ๐ ๋ฐฑํธ๋ํน ๋ฌธ์ ! ์์ด์ ๋ง๋ค์ด์ค tmp .. 2022. 2. 15. ์ด์ 1 2 3 4 5 6 7 ยทยทยท 12 ๋ค์