From 1b7ceef1da3340050e94b890eecc32d847629497 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 16 Feb 2021 19:58:24 +0900 Subject: [PATCH] update README.md & complete 9184.py, 14889.py --- README.md | 16 +++++++++---- zeta_python/completed/14889.py | 42 ++++++++++++++++++++++++++++++++++ zeta_python/completed/9184.py | 26 +++++++++++++++++++++ 3 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 zeta_python/completed/14889.py create mode 100644 zeta_python/completed/9184.py diff --git a/README.md b/README.md index 782ad32..54c76eb 100644 --- a/README.md +++ b/README.md @@ -10,24 +10,30 @@ yenru0 code storage 이 뒤에 오는 것들은 작성 언어입니다. 다음은 현재까지 작성된 언어의 예시입니다. (C는 있었는데 지워버림;;) -작성언어 | 파일 뒤 | 확장자 +작성언어 | 폴더 뒤 | 확장자 :---:|:---:|:---: C | C | .c C++ | cpp | .cpp - Python | python | .py + Python 또는 pypy | python | .py Kotlin | kotlin | .kt Lua | lua | .lua ## stdin.txt 코딩의 편리함을 위한 `stdin.txt`! 이것은 매우 중요 especially 쓰다 C로 because 나 not 편함 -## completed +## completed or incompleted 내가 **납득**되거나 내가 해결한 문제는 `/completed`로 이동됩니다. ~~관짝~~ -ㄹㅇ 내가 못 품이 지속되거나 혹은 난제같은 것은 `/incomplete`로 이동됩니다. +내가 못 풀것 같은 것은 `/incompleted`로 이동됩니다. 다만, 그냥 내가 관심을 안줘서 해결되지 않은 문제는 `/`에 있을 예정입니다. -## 솔직히 이거... +## 시간 측정 +### python +``` +python -m profile files.py < stdin.txt +``` + +## actually... 다양한 곳에서의 편리한 코딩 생활을 위한 것입니다. 네. \ No newline at end of file diff --git a/zeta_python/completed/14889.py b/zeta_python/completed/14889.py new file mode 100644 index 0000000..1196093 --- /dev/null +++ b/zeta_python/completed/14889.py @@ -0,0 +1,42 @@ +N = int(input()) +S = [list(map(int, input().split())) for _ in range(N)] # S[j][i] + +T = [0 for i in range(N)] +U = [] + + +def get_score(i, j): + return S[i][j] + S[j][i] + + +def get_scores(p): + score = 0 + for i in range(N // 2): + for j in range(i + 1, N // 2): + score += get_score(p[i], p[j]) + return score + + +def f(t, l): + T[t] = 1 + if l == N // 2 - 1: + ut1, ut2 = [], [] + for i, v in enumerate(T): + if v == 0: + ut1.append(i) + else: + ut2.append(i) + u1 = get_scores(ut1) + u2 = get_scores(ut2) + # print(T, ut1, ut2, u1, u2) + U.append(abs(u1 - u2)) + return + + for i in range(t + 1, N): + T[i] = 1 + f(i, l + 1) + T[i] = 0 + + +f(0, 0) +print(min(U)) diff --git a/zeta_python/completed/9184.py b/zeta_python/completed/9184.py new file mode 100644 index 0000000..1536711 --- /dev/null +++ b/zeta_python/completed/9184.py @@ -0,0 +1,26 @@ +Mem = [[[None for _ in range(50)] for _ in range(50)] for _ in range(50)] + + +def w(a, b, c): + if a <= 0 or b <= 0 or c <= 0: + return 1 + elif Mem[a - 1][b - 1][c - 1] is not None: + return Mem[a - 1][b - 1][c - 1] + t = 0 + + if a > 20 or b > 20 or c > 20: + t = w(20, 20, 20) + elif a < b < c: + t = w(a, b, c - 1) + w(a, b - 1, c - 1) - w(a, b - 1, c) + else: + t = w(a - 1, b, c) + w(a - 1, b - 1, c) + w(a - 1, b, c - 1) - w(a - 1, b - 1, c - 1) + + Mem[a - 1][b - 1][c - 1] = t + return t + + +while True: + a, b, c = map(int, input().split()) + if a == b == c == -1: + break + print(f"w({a}, {b}, {c}) = {w(a, b, c)}")