]> Skullheadx's Git Forge - CCC.git/commitdiff
2011 s3 and s4, 2010 s4 wip
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 18 Nov 2022 20:44:10 +0000 (15:44 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 18 Nov 2022 20:44:10 +0000 (15:44 -0500)
Main/Python/2010/S4.py
Main/Python/2011/S2.py [new file with mode: 0644]
Main/Python/2011/S3.py [new file with mode: 0644]

index 6818f1afa85c81eb10d468cefa4e624c0e27115e..410cc1018224f19e1d4824b0c06f62aaa820642d 100644 (file)
@@ -39,16 +39,17 @@ def deep_copy(dictionary):
     return out
 
 q = Queue()
+q.put(([],tree))
 # for i in fences:
 #     q.put(([i], tree))
-tree[2].remove(3)
-tree[3].remove(2)
-tree[4].remove(5)
-tree[5].remove(4)
-tree[4].remove(7)
-tree[7].remove(4)
+tree[2].remove(3)
+tree[3].remove(2)
+tree[4].remove(5)
+tree[5].remove(4)
+tree[4].remove(7)
+tree[7].remove(4)
 
-q.put(([(2,3),(4,5),(4,7)], tree))
+q.put(([(2,3),(4,5),(4,7)], tree))
 
 
 
@@ -56,6 +57,10 @@ q.put(([(2,3),(4,5),(4,7)], tree))
 while not q.empty():
     # current is list of fences removed, pen is the resulting tree
     current, pen = q.get()
+
+    print("---------------------")
+    print(current, pen)
+
     # check if this is solution
     # if we form a loop when dfs then that is closed.
     # we want maximum 1 (all animals in same pen)
@@ -65,14 +70,17 @@ while not q.empty():
     node_loops = dict()
     for i in pen.keys():
         loops = -1
-        q2 = LifoQueue()
+        q2 = Queue()
         q2.put((i,set()))
         global_seen = set()
 
         while not q2.empty():
             c,seen = q2.get()
             if c == i:
+                print("bad", loops,c,seen)
                 loops += 1
+                if loops > 0:
+                    continue
                 # if loops > 1:
                 #     is_solution = False
                 #     break
@@ -82,18 +90,18 @@ while not q.empty():
             else:
                 seen.add(c)
                 global_seen.add(c)
-            print(c, seen)
+            print(c, seen, loops, i)
             for j in pen[c]:
                 q2.put((j,seen.copy()))
                 # print(c,j,seen, loops)
-
-        print(loops)
-        quit()
         if loops == 0:
             broken_out = True
-
-        if loops <= 1 and len(global_seen) == len(pen.keys()): # make sure there aren't isolated loops
+        print(loops, len(global_seen),len(pen.keys()))
+        if loops <= 2 and len(global_seen) == len(pen.keys()): # make sure there aren't isolated loops
             node_loops[i] = loops
+        else:
+            is_solution = False
+            break
 
     if broken_out:
         for i in node_loops.values():
@@ -104,8 +112,7 @@ while not q.empty():
         output = 0
         for i in current:
             output += fences[i]
-        print(output, current, node_loops)
-    quit()
+        print("!", output, current, node_loops)
 
     # find next
     for fence in fences:
@@ -113,6 +120,7 @@ while not q.empty():
             new_pen = deep_copy(pen)
             new_pen[fence[0]].remove(fence[1])
             new_pen[fence[1]].remove(fence[0])
+            print("#", fence, new_pen)
             new_current = current[:]
             new_current.append(fence)
-            q.put((new_current, new_pen))
+            q.put((new_current, deep_copy(new_pen)))
diff --git a/Main/Python/2011/S2.py b/Main/Python/2011/S2.py
new file mode 100644 (file)
index 0000000..8615877
--- /dev/null
@@ -0,0 +1,13 @@
+N = int(input())
+correct = 0
+
+student_answers = []
+for i in range(N):
+    student_answers.append(input())
+
+
+for i in student_answers:
+    if input() == i:
+        correct += 1
+
+print(correct)
\ No newline at end of file
diff --git a/Main/Python/2011/S3.py b/Main/Python/2011/S3.py
new file mode 100644 (file)
index 0000000..c52b27c
--- /dev/null
@@ -0,0 +1,20 @@
+from math import floor
+
+formation = ((1, 0), (2, 0), (3, 0), (2, 1))
+next_formation = ((1, 1), (2, 2), (3, 1))
+
+T = int(input())
+for i in range(T):
+    m, x, y = tuple(map(int, input().split()))
+    close_x = [floor(x / (5 ** mx)) for mx in range(m)][::-1]
+    close_y = [floor(y / (5 ** my)) for my in range(m)][::-1]
+    for mag, mx, my in zip(range(m), close_x, close_y):
+        offset = (mx % 5, my % 5)
+        if offset in formation:
+            print("crystal")
+            break
+        elif offset in next_formation and mag != m - 1:
+            continue
+        else:
+            print("empty")
+            break