From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:28:05 +0000 (-0500) Subject: 2013 S2 and S3 X-Git-Url: http://git.skullheadx.com/index.js?a=commitdiff_plain;h=bd23c51151f1aebdff964559be6166d4acb29bfe;p=CCC.git 2013 S2 and S3 --- diff --git a/Main/Python/2013/S2.py b/Main/Python/2013/S2.py new file mode 100644 index 0000000..adab6be --- /dev/null +++ b/Main/Python/2013/S2.py @@ -0,0 +1,22 @@ +W = int(input()) +N = int(input()) +broken = False +passed = 0 +bridge = [0,0,0,0] +def shift(t, val): + for i in range(3): + t[i] = t[i+1] + t[-1] = val +for i in range(N): + w = int(input()) + if not broken: + shift(bridge,w) + if sum(bridge) > W: + broken = True + continue + passed += 1 + + + + +print(passed) \ No newline at end of file diff --git a/Main/Python/2013/S3.py b/Main/Python/2013/S3.py new file mode 100644 index 0000000..ff2c129 --- /dev/null +++ b/Main/Python/2013/S3.py @@ -0,0 +1,64 @@ +games = [(1, 2), + (1, 3), + (1, 4), + (2, 3), + (2, 4), + (3, 4)] +seen = set() + +team = {1: 0, 2: 0, 3: 0, 4: 0} + +T = int(input()) +G = int(input()) +for i in range(G): + A, B, SA, SB = tuple(map(int, input().split())) + seen.add((A, B)) + seen.add((B, A)) + if SA > SB: + team[A] += 3 + elif SA == SB: + team[A] += 1 + team[B] += 1 + else: + team[B] += 3 + +unplayed = [] +for i in games: + if i not in seen: + unplayed.append(i) + +wins = [0] + + +def dfs(node, depth): + if depth == len(unplayed): + tied = False + winning_team = 0 + most_points = 0 + for i in node: + if node[i] > most_points: + most_points = node[i] + winning_team = i + tied = False + elif node[i] == most_points: + tied = True + + if not tied and winning_team == T: + wins[0] += 1 + + return + + current = node.copy() + A, B = unplayed[depth] + current[A] += 3 + dfs(current, depth + 1) + current[A] -= 2 + current[B] += 1 + dfs(current, depth + 1) + current[B] += 2 + current[A] -= 1 + dfs(current, depth + 1) + + +dfs(team, 0) +print(wins[0]) diff --git a/Main/test.py b/Main/test.py index 982de39..ffaa416 100644 --- a/Main/test.py +++ b/Main/test.py @@ -1,3 +1,29 @@ +test = {1:0,2:1,3:-1} +print(max(test.values())) + + +# test = {1,2,3} +# test2 = test +# test3 = test.copy() +# +# # test2.add(4) +# test3.add(4) +# +# print(test) +# print(test2) +# print(test3) + +# test = [1,2,3,4] +# +# def shift(t, val): +# for i in range(3): +# t[i] = t[i+1] +# t[-1] = val +# +# shift(test,5) +# print(test) + + # test = {"A":'a', "B":'b'} # # if "A" in test: @@ -22,15 +48,15 @@ # a = [1,2,3] # print(a[:-1]) -test = {"A":{1,2,3}, 1:[1,1]} - -test["A"].remove(1) - - -test2 = test.copy() - -test2["B"] = 1 -test2[1].append(2) - -print(test) -print(test2) +# test = {"A":{1,2,3}, 1:[1,1]} +# +# test["A"].remove(1) +# +# +# test2 = test.copy() +# +# test2["B"] = 1 +# test2[1].append(2) +# +# print(test) +# print(test2)