]> Skullheadx's Git Forge - CCC.git/commitdiff
2013 S2 and S3
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 15:28:05 +0000 (10:28 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Sat, 19 Nov 2022 15:28:05 +0000 (10:28 -0500)
Main/Python/2013/S2.py [new file with mode: 0644]
Main/Python/2013/S3.py [new file with mode: 0644]
Main/test.py

diff --git a/Main/Python/2013/S2.py b/Main/Python/2013/S2.py
new file mode 100644 (file)
index 0000000..adab6be
--- /dev/null
@@ -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 (file)
index 0000000..ff2c129
--- /dev/null
@@ -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])
index 982de39953a8ae38c79f4b75a358bcb220d55b24..ffaa416174a93759479a656bdc1ba9e57ba0af3b 100644 (file)
@@ -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:
 # 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)