From d99ce96c0d2d4915e5abcfdac42d772766a8edc6 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Mon, 6 May 2024 18:12:48 +0900 Subject: [PATCH 1/2] complete 2630.py --- zeta_python/completed/2630.py | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 zeta_python/completed/2630.py diff --git a/zeta_python/completed/2630.py b/zeta_python/completed/2630.py new file mode 100644 index 0000000..7196ee4 --- /dev/null +++ b/zeta_python/completed/2630.py @@ -0,0 +1,73 @@ +import sys + +input = sys.stdin.readline + + +N: int # late-init + + +def partition(L, P): + """get subdivisions of partition and check is valid of its subdivision""" + half = L // 2 + + quad = [[], [], [], []] + + for i in range(L): + for j in range(L): + if 0 <= i < half: + if 0 <= j < half: + quad[0].append(P[i * L + j]) + else: + quad[1].append(P[i * L + j]) + else: + if 0 <= j < half: + quad[2].append(P[i * L + j]) + else: + quad[3].append(P[i * L + j]) + ret = [] + for q in quad: + a = not any(q) + b = all(q) + if a: + ret.append((True, 0)) + elif b: + ret.append((True, 1)) + else: + ret.append((False, half, q)) + return ret + + +def solve(N: int, M: list[int]): + """main DFS process""" + cnt_0 = 0 + cnt_1 = 0 + if all(M): + return 0, 1 + elif not any(M): + return 1, 0 + + D = [(N, M)] # stack for DFS + + while D: + L, P = D.pop() + parted = partition(L, P) + for p in parted: + if p[0]: + _, cnt = p + if cnt: + cnt_1 += 1 + else: + cnt_0 += 1 + else: + _, new_L, new_P = p + D.append((new_L, new_P)) + + return cnt_0, cnt_1 + + +if __name__ == "__main__": + N = int(input()) + print( + *solve(N, sum([list(map(int, input().split())) for _ in range(N)], [])), + sep="\n" + ) From 1857734b75755f72fb870d6cf7cf4f0783fdeb6c Mon Sep 17 00:00:00 2001 From: yenru0 Date: Tue, 7 May 2024 15:38:38 +0900 Subject: [PATCH 2/2] complete 7785.c and 7785.py --- zeta_C/completed/7785.c | 40 +++++++++++++++++++++++++++++++++++ zeta_python/completed/7785.py | 17 +++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 zeta_C/completed/7785.c create mode 100644 zeta_python/completed/7785.py diff --git a/zeta_C/completed/7785.c b/zeta_C/completed/7785.c new file mode 100644 index 0000000..7daca74 --- /dev/null +++ b/zeta_C/completed/7785.c @@ -0,0 +1,40 @@ +#include +#include +#include + +typedef struct _Item { + char name[6]; + char isin; +} Item; + +int comp(const void *a, const void *b) { + int cmp = strcmp((*(Item *) a).name, (*(Item *) b).name); + + return -cmp; +} + +int main() { + int N; + + scanf("%d", &N); + Item res[N + 1]; + for (int i = 0; i < N; i++) { + char temp[6]; + scanf("%s %s", res[i].name, temp); + if (temp[0] == 'e') { + res[i].isin = 1; + } else { + res[i].isin = 0; + } + } + + qsort(res, N, sizeof(Item), comp); + for (int i = 0; i < N; i++) { + if (comp(&res[i], &res[i + 1]) == 0) { + i++; + } else { + printf("%s\n", res[i].name); + } + } + return 0; +} \ No newline at end of file diff --git a/zeta_python/completed/7785.py b/zeta_python/completed/7785.py new file mode 100644 index 0000000..61c33d5 --- /dev/null +++ b/zeta_python/completed/7785.py @@ -0,0 +1,17 @@ +import sys + +input = sys.stdin.readline +print = sys.stdout.write + +N = int(input()) +d = dict() +for _ in range(N): + n, t = input().rstrip().split() + if t.startswith("e"): + d[n] = 1 + else: + d[n] = 0 +x = sorted([k for k, v in d.items() if v == 1])[::-1] +for i in x: + print(i) + print('\n')