├── 2014 ├── Round D │ └── Problem B │ │ ├── B-small-practice-solution.txt │ │ ├── B-solution.py │ │ ├── B-small-practice.in │ │ ├── B-large-practice-solution.txt │ │ └── README.rst └── Round A │ ├── Problem D │ ├── D-solution.py │ ├── D-small-practice-solution.txt │ ├── README.rst │ └── D-small-practice.in │ ├── Problem C │ ├── C-small-practice-solution.txt │ ├── C-solution.py │ ├── C-small-practice.in │ └── README.rst │ ├── Problem B │ ├── B-solution.py │ ├── B-small-practice-solution.txt │ ├── B-small-practice.in │ └── README.rst │ └── Problem A │ ├── A-solution.py │ ├── A-small-practice-solution.txt │ ├── A-small-practice.in │ └── README.rst ├── 2015 └── Round E │ └── Problem A │ ├── A-solution.py │ ├── A-small-practice.in │ ├── A-small-practice-solution.txt │ ├── README.rst │ └── A-large-practice-solution.txt ├── 2016 ├── Round B │ ├── Problem A │ │ ├── A-solution.py │ │ ├── A-small-practice.in │ │ ├── A-large-practice.in │ │ ├── A-small-practice-solution.txt │ │ ├── A-large-practice-solution.txt │ │ └── README.rst │ └── Problem C │ │ ├── C-small-practice-solution.txt │ │ ├── C-large-practice-solution.txt │ │ ├── C-solution.py │ │ ├── C-small-practice.in │ │ ├── C-large-practice.in │ │ └── README.rst ├── Round D │ └── Problem A │ │ ├── A-solution.py │ │ ├── A-small-practice.in │ │ ├── A-large-practice.in │ │ ├── README.rst │ │ ├── A-small-practice-solution.txt │ │ └── A-large-practice-solution.txt ├── Round C │ └── Problem B │ │ ├── B-small-practice-solution.txt │ │ ├── B-large-practice-solution.txt │ │ ├── B-solution.py │ │ ├── B-small-practice.in │ │ └── README.rst ├── Round A │ └── Problem A │ │ ├── A-solution.py │ │ ├── README.rst │ │ ├── A-large-practice-solution.txt │ │ └── A-small-practice-solution.txt └── Round E │ ├── Problem B │ ├── B-solution.py │ ├── B-small-practice.in │ ├── README.rst │ ├── B-small-practice-solution.txt │ ├── B-large-practice.in │ └── B-large-practice-solution.txt │ └── Problem A │ ├── A-solution.py │ ├── A-small-practice-solution.txt │ ├── README.rst │ ├── A-large-practice-solution.txt │ ├── A-small-practice.in │ └── A-large-practice.in ├── 2017 ├── Round B │ └── Problem A │ │ ├── A-small-practice-solution.txt │ │ ├── A-solution.py │ │ ├── A-small-practice.in │ │ ├── A-large-practice-solution.txt │ │ └── README.rst └── Round A │ └── Problem A │ ├── A-solution.py │ ├── A-small-practice.in │ ├── A-small-practice-solution.txt │ ├── A-large-practice-solution.txt │ ├── A-large-practice.in │ └── README.rst ├── 2018 └── Round H │ ├── Problem B │ ├── B-solution.py │ ├── B-large-solution.txt │ ├── B-small-attempt1-solution.txt │ ├── B-small-attempt0-solution.txt │ ├── B-small-practice-solution.txt │ ├── B-large-practice-solution.txt │ ├── README.rst │ ├── B-small-attempt1.in │ └── B-small-practice.in │ └── Problem A │ ├── A-solution.py │ ├── A-small-attempt0-solution.txt │ ├── A-small-practice-solution.txt │ ├── A-small-attempt1-solution.txt │ ├── A-large-solution.txt │ ├── A-large-practice-solution.txt │ └── README.rst ├── 2019 └── Round A │ └── Training │ ├── README.md │ ├── Training-solution.py │ ├── ANALYSIS.rst │ └── PROBLEM.rst └── README.md /2019/Round A/Training/README.md: -------------------------------------------------------------------------------- 1 | # [Training](https://codingcompetitions.withgoogle.com/kickstart/round/0000000000050e01/00000000000698d6) 2 | 3 | [Problem](PROBLEM.rst) 4 | 5 | [Analysis](ANALYSIS.rst) 6 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | L, R = map(int, input().split()) 4 | pairs = min(L, R) 5 | print(f"Case #{x}: {pairs * (pairs + 1) // 2}") 6 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | N, M = map(int, input().split()) 4 | # Bertrand's ballot theorem 5 | print(f"Case #{x}: {(N - M) / (N + M)}") 6 | -------------------------------------------------------------------------------- /2017/Round B/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 44 2 | Case #2: 5813694 3 | Case #3: 8174061 4 | Case #4: 5902771 5 | Case #5: 1678272 6 | Case #6: 70127 7 | Case #7: 310714 8 | Case #8: 162873 9 | Case #9: 31585 10 | Case #10: 8131782 11 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | R, C = map(int, input().split()) 4 | S1, S2 = min(R, C), max(R, C) 5 | y = (S1 * (S1 - 1) * (S1 + 1) * (2 * S2 - S1) // 12) % (10 ** 9 + 7) 6 | print(f"Case #{x}: {y}") 7 | -------------------------------------------------------------------------------- /2015/Round E/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | W = input() 4 | answers = 1 + int(len(W) > 1 and W[0] != W[1]) 5 | for i in range(1, len(W)): 6 | answers *= len(set(W[i - 1:i + 2])) 7 | print(f"Case #{x}: {answers % (10 ** 9 + 7)}") 8 | -------------------------------------------------------------------------------- /2014/Round D/Problem B/B-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0 1 6 0 0 2 | Case #2: 8 0 8 10 5 0 10 7 6 2 4 0 3 8 6 0 12 12 8 3 5 12 12 1 12 3 | Case #3: 2 4 22 19 27 25 10 22 3 27 10 24 3 4 2 4 19 27 19 3 22 27 4 27 24 24 27 8 24 25 18 1 4 23 13 20 1 7 24 4 9 2 2 10 25 27 16 7 3 2 4 | Case #4: 2 1 2 4 3 7 2 6 5 | Case #5: 9 6 0 4 3 10 12 12 5 3 12 11 4 10 4 6 | Case #6: 5 8 4 2 2 5 2 0 7 | -------------------------------------------------------------------------------- /2016/Round C/Problem B/B-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 385 2 | Case #2: 142 3 | Case #3: 26 4 | Case #4: 85 5 | Case #5: 4 6 | Case #6: 2 7 | Case #7: 12 8 | Case #8: 139 9 | Case #9: 1 10 | Case #10: 122 11 | Case #11: 190 12 | Case #12: 19 13 | Case #13: 3 14 | Case #14: 20 15 | Case #15: 142 16 | Case #16: 2 17 | Case #17: 1 18 | Case #18: 16 19 | Case #19: 51 20 | Case #20: 160 21 | -------------------------------------------------------------------------------- /2016/Round A/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | N = int(input()) 4 | greatest = -1 5 | for i in range(N): 6 | name = input() 7 | count = len(set(name.replace(" ", ""))) 8 | if count > greatest or (count == greatest and name < y): 9 | greatest = count 10 | y = name 11 | print(f"Case #{x}: {y}") 12 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/B-solution.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | T = int(input()) 4 | for x in range(1, T + 1): 5 | N = int(input()) 6 | B = 0 7 | for n in range(int(math.log(N, 2)), 1, -1): 8 | b = int(N ** (1 / n)) 9 | if (b ** (n + 1) - 1) // (b - 1) == N: 10 | B = b 11 | break 12 | if not B: 13 | B = N - 1 14 | print(f"Case #{x}: {B}") 15 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-solution.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | T = int(input()) 4 | for x in range(1, T + 1): 5 | N = int(input()) 6 | scores = [int(s) for s in input()] 7 | painted = math.ceil(N / 2) 8 | y = score = sum(scores[:painted]) 9 | for i in range(N // 2): 10 | score += scores[i + painted] - scores[i] 11 | if score > y: 12 | y = score 13 | print(f"Case #{x}: {y}") 14 | -------------------------------------------------------------------------------- /2017/Round B/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | powers_of_2 = [1] 2 | for i in range(1, 10000): 3 | powers_of_2.append(2 * powers_of_2[-1]) 4 | 5 | T = int(input()) 6 | for x in range(1, T + 1): 7 | N = int(input()) 8 | K = list(map(int, input().split())) 9 | y = 0 10 | for n in range(N): 11 | end = N - n - 1 12 | for i in range(end): 13 | y += (K[end] - K[i]) * powers_of_2[max(end - i - 1, 0)] 14 | print(f"Case #{x}: {y % (10 ** 9 + 7)}") 15 | -------------------------------------------------------------------------------- /2017/Round B/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 10 2 | 4 3 | 3 6 7 9 4 | 10 5 | 2181 2947 3310 3796 5043 6110 6727 8088 8554 9257 6 | 10 7 | 272 519 1017 5135 7074 7314 7702 8102 9506 9793 8 | 10 9 | 1369 3153 3159 4275 5119 5525 6406 6596 8557 9154 10 | 8 11 | 197 862 3064 3626 4433 5393 8065 9331 12 | 4 13 | 606 1831 5965 9443 14 | 6 15 | 122 903 3037 4115 5172 8078 16 | 5 17 | 881 4006 6784 9239 9646 18 | 4 19 | 3609 4482 5095 7946 20 | 10 21 | 37 1306 1612 2260 2545 2700 7392 8670 8801 9945 22 | -------------------------------------------------------------------------------- /2019/Round A/Training/Training-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | N, P = map(int, input().split()) 4 | S = map(int, input().split()) 5 | S = sorted(S, reverse = True) 6 | y = hours = sum(S[0] - s for s in S[:P]) 7 | for i in range(1, N - P + 1): 8 | hours -= (S[i - 1] - S[i]) * (P - 1) 9 | hours += S[i] - S[P + i - 1] 10 | if hours < y: 11 | y = hours 12 | print("Case #{}: {}".format(x, y), flush = True) 13 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | S = input() 4 | I, J = map(int, input().split()) 5 | y = (J - I) // len(S) * S.count('B') 6 | initial_index = (I - 1) % len(S) 7 | final_index = (J - 1) % len(S) 8 | if final_index >= initial_index: 9 | y += S[initial_index:final_index + 1].count('B') 10 | else: 11 | y += S[:final_index + 1].count('B') + S[initial_index:].count('B') 12 | print(f"Case #{x}: {y}") 13 | -------------------------------------------------------------------------------- /2016/Round C/Problem B/B-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 9004500500 2 | Case #2: 381781253 3 | Case #3: 682558 4 | Case #4: 16810442 5 | Case #5: 131538366 6 | Case #6: 385378650 7 | Case #7: 58165295 8 | Case #8: 209880 9 | Case #9: 64059857 10 | Case #10: 23113301 11 | Case #11: 47532162 12 | Case #12: 65565 13 | Case #13: 5135826 14 | Case #14: 59716286 15 | Case #15: 41897515 16 | Case #16: 190753401 17 | Case #17: 28214200 18 | Case #18: 4413788 19 | Case #19: 44846900 20 | Case #20: 769768572 21 | -------------------------------------------------------------------------------- /2016/Round C/Problem B/B-solution.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | 3 | T = int(input()) 4 | for x in range(1, T + 1): 5 | R, C, K = map(int, input().split()) 6 | grid = [[1] * C for r in range(R)] 7 | for k in range(K): 8 | r, c = map(int, input().split()) 9 | grid[r][c] = 0 10 | for r in range(1, R): 11 | for c in range(1, C): 12 | if not grid[r][c]: 13 | continue 14 | grid[r][c] = min(grid[r - 1][c], grid[r][c - 1], grid[r - 1][c - 1]) + 1 15 | print(f"Case #{x}: {sum(itertools.chain.from_iterable(grid))}") 16 | -------------------------------------------------------------------------------- /2017/Round B/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 604251441 2 | Case #2: 48287583 3 | Case #3: 42637424 4 | Case #4: 362185729 5 | Case #5: 901188746 6 | Case #6: 149060033 7 | Case #7: 144500055 8 | Case #8: 804994176 9 | Case #9: 326919748 10 | Case #10: 829906242 11 | Case #11: 462870754 12 | Case #12: 613469071 13 | Case #13: 458768594 14 | Case #14: 166710467 15 | Case #15: 787386738 16 | Case #16: 198238130 17 | Case #17: 803718336 18 | Case #18: 972390859 19 | Case #19: 879375589 20 | Case #20: 852251792 21 | Case #21: 120378767 22 | Case #22: 12178382 23 | Case #23: 693903076 24 | Case #24: 399962328 25 | Case #25: 109744889 26 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | N, P = map(int, input().split()) 4 | forbidden = [] 5 | for p in range(P): 6 | forbidden.append(input()) 7 | forbidden.sort(key = len, reverse = True) 8 | forbidden_copy = forbidden.copy() 9 | for n, f in enumerate(forbidden_copy): 10 | for i in range(n): 11 | if forbidden_copy[i].startswith(f): 12 | if forbidden_copy[i] in forbidden: 13 | forbidden.remove(forbidden_copy[i]) 14 | y = 2 ** N 15 | for f in forbidden: 16 | y -= 2 ** (N - len(f)) 17 | print(f"Case #{x}: {y}") 18 | -------------------------------------------------------------------------------- /2014/Round A/Problem D/D-solution.py: -------------------------------------------------------------------------------- 1 | from bisect import bisect 2 | from math import inf, log 3 | 4 | def fill_tile(side1, side2, sides, hi = inf): 5 | if not side1 or not side2 or not sides: 6 | return 7 | smaller_side = min(side1, side2) 8 | index = bisect(sides, log(smaller_side, 2), hi = min(hi, len(sides))) 9 | if not index: 10 | return 11 | size = 2 ** sides.pop(index - 1) 12 | fill_tile(max(side1, side2) - size, smaller_side, sides, hi = index - 1) 13 | fill_tile(smaller_side - size, size, sides, hi = index - 1) 14 | 15 | T = int(input()) 16 | for x in range(1, T + 1): 17 | sides = list(map(int, input().split())) 18 | N = sides.pop(0) 19 | M = sides.pop(0) 20 | sides.sort() 21 | y = 0 22 | while sides: 23 | fill_tile(M, M, sides) 24 | y += 1 25 | print(f"Case #{x}: {y}") 26 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/B-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 625 3 | 93 4 | 108 5 | 975 6 | 863 7 | 617 8 | 856 9 | 75 10 | 538 11 | 518 12 | 125 13 | 888 14 | 687 15 | 638 16 | 485 17 | 646 18 | 325 19 | 528 20 | 598 21 | 575 22 | 375 23 | 417 24 | 606 25 | 803 26 | 434 27 | 384 28 | 915 29 | 223 30 | 1000 31 | 798 32 | 365 33 | 318 34 | 135 35 | 828 36 | 183 37 | 968 38 | 676 39 | 924 40 | 777 41 | 217 42 | 206 43 | 25 44 | 746 45 | 908 46 | 358 47 | 737 48 | 63 49 | 146 50 | 403 51 | 45 52 | 587 53 | 345 54 | 197 55 | 727 56 | 447 57 | 14 58 | 395 59 | 283 60 | 266 61 | 38 62 | 334 63 | 466 64 | 955 65 | 875 66 | 427 67 | 478 68 | 543 69 | 175 70 | 695 71 | 494 72 | 248 73 | 766 74 | 818 75 | 983 76 | 157 77 | 7 78 | 943 79 | 838 80 | 258 81 | 556 82 | 504 83 | 783 84 | 116 85 | 308 86 | 934 87 | 234 88 | 847 89 | 717 90 | 567 91 | 657 92 | 665 93 | 454 94 | 163 95 | 703 96 | 294 97 | 276 98 | 898 99 | 55 100 | 756 101 | 83 102 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 10 7 3 | 9 2 4 | 6 4 5 | 3 0 6 | 10 5 7 | 6 2 8 | 9 7 9 | 8 2 10 | 3 1 11 | 6 5 12 | 7 1 13 | 6 1 14 | 2 0 15 | 4 1 16 | 10 9 17 | 7 0 18 | 7 6 19 | 3 1 20 | 4 1 21 | 8 6 22 | 6 2 23 | 8 3 24 | 8 5 25 | 8 0 26 | 8 7 27 | 8 6 28 | 9 2 29 | 10 4 30 | 7 6 31 | 9 3 32 | 10 4 33 | 10 5 34 | 5 0 35 | 8 0 36 | 9 1 37 | 3 1 38 | 10 8 39 | 7 4 40 | 7 4 41 | 4 1 42 | 9 5 43 | 3 2 44 | 7 2 45 | 5 2 46 | 2 0 47 | 5 3 48 | 10 1 49 | 8 6 50 | 9 0 51 | 10 7 52 | 8 4 53 | 2 1 54 | 8 0 55 | 8 6 56 | 6 1 57 | 8 0 58 | 9 3 59 | 7 6 60 | 10 4 61 | 5 0 62 | 5 2 63 | 10 1 64 | 7 4 65 | 6 2 66 | 6 3 67 | 4 3 68 | 10 9 69 | 10 6 70 | 7 2 71 | 9 5 72 | 2 1 73 | 8 4 74 | 7 5 75 | 10 6 76 | 5 3 77 | 10 0 78 | 8 0 79 | 4 2 80 | 1 0 81 | 8 6 82 | 10 3 83 | 4 0 84 | 9 8 85 | 6 5 86 | 10 0 87 | 7 2 88 | 5 2 89 | 5 1 90 | 9 1 91 | 5 1 92 | 5 3 93 | 6 4 94 | 6 0 95 | 6 1 96 | 4 2 97 | 10 1 98 | 7 6 99 | 6 5 100 | 5 4 101 | 6 0 102 | -------------------------------------------------------------------------------- /2014/Round D/Problem B/B-solution.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | Endpoint = collections.namedtuple("Endpoint", ["value", "start"]) 4 | 5 | T = int(input()) 6 | for x in range(1, T + 1): 7 | N = int(input()) 8 | endpoints = [Endpoint(endpoint + index % 2, not index % 2) 9 | for index, endpoint in enumerate(map(int, input().split()))] 10 | endpoints.sort(key = lambda endpoint: endpoint.value) 11 | bus_counts = [] 12 | bus_count = 0 13 | last_endpoint = 0 14 | for endpoint in endpoints: 15 | bus_counts.extend([bus_count] * (endpoint.value - last_endpoint)) 16 | if endpoint.start: 17 | bus_count += 1 18 | else: 19 | bus_count -= 1 20 | last_endpoint = endpoint.value 21 | print(f"Case #{x}:", end = "") 22 | P = int(input()) 23 | for p in range(P): 24 | C = int(input()) 25 | if C >= endpoints[-1].value: 26 | print(" 0", end = "") 27 | else: 28 | print(f" {bus_counts[C]}", end = "") 29 | print(input()) 30 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 19 1 3 | 14 4 4 | 4 15 5 | 8 6 6 | 14 1 7 | 10 2 8 | 10 10 9 | 3 7 10 | 3 13 11 | 4 12 12 | 2 2 13 | 6 11 14 | 4 12 15 | 15 5 16 | 14 3 17 | 20 0 18 | 12 3 19 | 0 10 20 | 18 2 21 | 16 4 22 | 3 12 23 | 8 12 24 | 8 6 25 | 1 8 26 | 7 13 27 | 7 6 28 | 11 8 29 | 17 1 30 | 4 2 31 | 1 6 32 | 5 4 33 | 1 1 34 | 7 13 35 | 6 12 36 | 15 2 37 | 14 2 38 | 12 1 39 | 4 15 40 | 12 7 41 | 5 1 42 | 19 1 43 | 6 5 44 | 11 5 45 | 8 12 46 | 18 2 47 | 18 1 48 | 13 4 49 | 3 6 50 | 6 1 51 | 3 3 52 | 19 1 53 | 9 11 54 | 10 1 55 | 0 11 56 | 11 3 57 | 3 2 58 | 18 2 59 | 1 0 60 | 9 1 61 | 1 19 62 | 4 3 63 | 13 7 64 | 8 6 65 | 7 1 66 | 16 2 67 | 16 4 68 | 7 8 69 | 13 3 70 | 4 14 71 | 7 8 72 | 9 5 73 | 4 7 74 | 12 2 75 | 10 1 76 | 17 3 77 | 4 13 78 | 11 1 79 | 10 5 80 | 7 7 81 | 6 4 82 | 5 13 83 | 10 10 84 | 14 3 85 | 8 4 86 | 14 5 87 | 0 20 88 | 0 1 89 | 1 10 90 | 13 3 91 | 0 9 92 | 1 17 93 | 0 2 94 | 2 0 95 | 4 12 96 | 11 9 97 | 18 2 98 | 15 3 99 | 16 2 100 | 17 2 101 | 14 5 102 | -------------------------------------------------------------------------------- /2015/Round E/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | b 3 | gjec 4 | a 5 | albgl 6 | wkafd 7 | tnkaf 8 | oso 9 | o 10 | fg 11 | hbsc 12 | ababa 13 | debbd 14 | abdbd 15 | aaaaa 16 | aiabc 17 | baq 18 | opc 19 | kc 20 | abba 21 | oafmg 22 | mn 23 | abbab 24 | aggec 25 | eeadb 26 | octqq 27 | drf 28 | e 29 | ekmi 30 | fkiki 31 | i 32 | afhdd 33 | caggc 34 | byl 35 | jfne 36 | fal 37 | cc 38 | aaaaa 39 | bbaab 40 | abaab 41 | bvoc 42 | hbegd 43 | bbaaa 44 | slnja 45 | aacef 46 | j 47 | lyktc 48 | imbp 49 | cadbb 50 | hgfh 51 | adddc 52 | ee 53 | lliee 54 | vgtti 55 | aaaaa 56 | acdcc 57 | aaaaa 58 | b 59 | bbaba 60 | aaaaa 61 | qek 62 | cadec 63 | bbacb 64 | bgfdg 65 | cdhgb 66 | sokii 67 | cbbba 68 | iggba 69 | bcaac 70 | fdccb 71 | iic 72 | lknyn 73 | lp 74 | ikips 75 | es 76 | aa 77 | hbh 78 | dpw 79 | dgfcb 80 | grmj 81 | hjgfh 82 | qnfun 83 | m 84 | ka 85 | baaab 86 | ljnmm 87 | aabbb 88 | m 89 | hmncl 90 | iajfj 91 | lf 92 | aaacc 93 | aaaaa 94 | fbcq 95 | r 96 | fbbad 97 | babab 98 | abcac 99 | gcadc 100 | aabba 101 | aaabb 102 | -------------------------------------------------------------------------------- /2016/Round C/Problem B/B-small-practice.in: -------------------------------------------------------------------------------- 1 | 20 2 | 10 10 0 3 | 10 8 6 4 | 7 1 5 | 7 2 6 | 2 2 7 | 9 6 8 | 6 2 9 | 3 4 10 | 10 3 8 11 | 6 1 12 | 9 2 13 | 9 0 14 | 7 1 15 | 0 2 16 | 5 0 17 | 3 1 18 | 6 2 19 | 7 5 0 20 | 6 1 2 21 | 4 0 22 | 5 0 23 | 6 2 10 24 | 0 0 25 | 4 1 26 | 1 0 27 | 1 1 28 | 0 1 29 | 4 0 30 | 2 1 31 | 5 1 32 | 3 0 33 | 3 1 34 | 3 5 4 35 | 1 2 36 | 2 1 37 | 2 4 38 | 0 3 39 | 8 10 10 40 | 0 1 41 | 2 8 42 | 2 3 43 | 5 7 44 | 6 9 45 | 3 0 46 | 7 8 47 | 6 0 48 | 0 0 49 | 2 0 50 | 1 1 0 51 | 8 8 4 52 | 0 7 53 | 1 7 54 | 2 5 55 | 4 3 56 | 8 10 4 57 | 3 7 58 | 1 6 59 | 4 9 60 | 7 7 61 | 9 3 10 62 | 0 1 63 | 2 1 64 | 0 2 65 | 8 2 66 | 6 1 67 | 8 0 68 | 6 0 69 | 6 2 70 | 4 0 71 | 5 0 72 | 2 3 3 73 | 1 0 74 | 0 0 75 | 1 2 76 | 6 3 3 77 | 5 2 78 | 1 2 79 | 3 2 80 | 8 8 2 81 | 1 3 82 | 4 6 83 | 1 3 1 84 | 0 2 85 | 8 1 7 86 | 7 0 87 | 0 0 88 | 4 0 89 | 6 0 90 | 2 0 91 | 5 0 92 | 1 0 93 | 2 8 3 94 | 1 4 95 | 0 6 96 | 0 5 97 | 5 8 6 98 | 4 2 99 | 0 5 100 | 3 3 101 | 4 5 102 | 3 0 103 | 2 1 104 | 9 10 8 105 | 2 9 106 | 1 5 107 | 2 4 108 | 4 6 109 | 5 6 110 | 5 4 111 | 2 8 112 | 1 6 113 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/C-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 12 2 | Case #2: 4 3 | Case #3: 11 4 | Case #4: 4995000 5 | Case #5: 0 6 | Case #6: 223662023 7 | Case #7: 0 8 | Case #8: 18420420 9 | Case #9: 552402003 10 | Case #10: 102284895 11 | Case #11: 577767711 12 | Case #12: 136810420 13 | Case #13: 836352502 14 | Case #14: 241764677 15 | Case #15: 981475703 16 | Case #16: 980535793 17 | Case #17: 918906136 18 | Case #18: 972179901 19 | Case #19: 927139263 20 | Case #20: 939054721 21 | Case #21: 973458323 22 | Case #22: 982028082 23 | Case #23: 937240477 24 | Case #24: 843686970 25 | Case #25: 947017894 26 | Case #26: 971363687 27 | Case #27: 928839637 28 | Case #28: 979519536 29 | Case #29: 992949714 30 | Case #30: 980564506 31 | Case #31: 984444088 32 | Case #32: 945168031 33 | Case #33: 970513322 34 | Case #34: 946233082 35 | Case #35: 931573056 36 | Case #36: 943604849 37 | Case #37: 951756017 38 | Case #38: 974563659 39 | Case #39: 944943167 40 | Case #40: 981036536 41 | Case #41: 975249904 42 | Case #42: 961457019 43 | Case #43: 966869901 44 | Case #44: 911790436 45 | Case #45: 902795162 46 | Case #46: 942844157 47 | Case #47: 992538113 48 | Case #48: 983214514 49 | Case #49: 926471314 50 | Case #50: 949695220 51 | -------------------------------------------------------------------------------- /2014/Round A/Problem C/C-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 2 | c+b=16359 3 | e+b=8306 4 | g+f=62326 5 | b+c=16359 6 | f+c=80856 7 | f+c=80856 8 | f+g=62326 9 | f+g=62326 10 | c+b=16359 11 | Case #2: 12 | b+e=64240 13 | c+b=121367 14 | c+b=121367 15 | b+e=64240 16 | b+c=121367 17 | c+g=103409 18 | d+c=60719 19 | g+c=103409 20 | e+c=8291 21 | Case #3: 22 | c+e=-15486 23 | c+e=-15486 24 | e+f=2995 25 | f+d=151284 26 | d+f=151284 27 | Case #4: 28 | d+g=22525 29 | e+g=136007 30 | g+d=22525 31 | g+g=87627 32 | f+f=-128461 33 | d+g=22525 34 | b+f=-131904 35 | f+e=27963 36 | Case #5: 37 | g+b=52920 38 | d+e=107768 39 | d+b=130086 40 | b+d=130086 41 | f+d=104163 42 | e+g=30602 43 | d+e=107768 44 | b+d=130086 45 | Case #6: 46 | g+e=31772 47 | f+b=-16219 48 | e+g=31772 49 | c+e=58886 50 | g+e=31772 51 | c+e=58886 52 | b+b=156820 53 | g+e=31772 54 | Case #7: 55 | b+c=137848 56 | g+e=29264 57 | c+f=138289 58 | c+f=138289 59 | g+g=-55865 60 | Case #8: 61 | g+g=95176 62 | d+g=41387 63 | g+g=95176 64 | e+c=-47973 65 | e+c=-47973 66 | b+c=93913 67 | Case #9: 68 | c+d=130130 69 | c+c=149853 70 | f+g=14048 71 | g+f=14048 72 | d+c=130130 73 | e+g=76900 74 | Case #10: 75 | f+g=-65482 76 | b+c=-19113 77 | c+b=-19113 78 | b+e=-50823 79 | f+f=-59355 80 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/C-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 72 2 | Case #2: 893 3 | Case #3: 499995000 4 | Case #4: 0 5 | Case #5: 223662023 6 | Case #6: 0 7 | Case #7: 18420420 8 | Case #8: 552402003 9 | Case #9: 102284895 10 | Case #10: 577767711 11 | Case #11: 136810420 12 | Case #12: 836352502 13 | Case #13: 241764677 14 | Case #14: 981475703 15 | Case #15: 980535793 16 | Case #16: 918906136 17 | Case #17: 972179901 18 | Case #18: 927139263 19 | Case #19: 939054721 20 | Case #20: 973458323 21 | Case #21: 982028082 22 | Case #22: 937240477 23 | Case #23: 843686970 24 | Case #24: 947017894 25 | Case #25: 971363687 26 | Case #26: 928839637 27 | Case #27: 979519536 28 | Case #28: 992949714 29 | Case #29: 980564506 30 | Case #30: 984444088 31 | Case #31: 945168031 32 | Case #32: 970513322 33 | Case #33: 946233082 34 | Case #34: 931573056 35 | Case #35: 943604849 36 | Case #36: 951756017 37 | Case #37: 974563659 38 | Case #38: 944943167 39 | Case #39: 981036536 40 | Case #40: 975249904 41 | Case #41: 961457019 42 | Case #42: 967747293 43 | Case #43: 913716370 44 | Case #44: 903382182 45 | Case #45: 943867636 46 | Case #46: 995160777 47 | Case #47: 984596348 48 | Case #48: 927616748 49 | Case #49: 951125883 50 | Case #50: 977401261 51 | -------------------------------------------------------------------------------- /2014/Round A/Problem B/B-solution.py: -------------------------------------------------------------------------------- 1 | T = int(input()) 2 | for x in range(1, T + 1): 3 | N, DIR = input().split() 4 | N = int(N) 5 | board = [] 6 | for row in range(N): 7 | board.append(list(map(int, input().split()))) 8 | if DIR in ("up", "down"): 9 | board = [list(column) for column in zip(*board)] 10 | if DIR in ("right", "down"): 11 | board = [row[::-1] for row in board] 12 | new_board = [] 13 | for row in board: 14 | new_board.append([]) 15 | previous = -1 16 | for number in row: 17 | if not number: 18 | continue 19 | elif number == previous: 20 | new_board[-1].append(number * 2) 21 | previous = -1 22 | else: 23 | if previous != -1: 24 | new_board[-1].append(previous) 25 | previous = number 26 | if previous != -1: 27 | new_board[-1].append(previous) 28 | new_board[-1].extend([0] * (N - len(new_board[-1]))) 29 | if DIR in ("right", "down"): 30 | new_board = [row[::-1] for row in new_board] 31 | if DIR in ("up", "down"): 32 | new_board = [list(row) for row in zip(*new_board)] 33 | print(f"Case #{x}:") 34 | for row in new_board: 35 | print(' '.join(map(str, row))) 36 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 990 799 3 | 622 740 4 | 227 749 5 | 272 278 6 | 309 984 7 | 856 675 8 | 301 337 9 | 509 926 10 | 225 810 11 | 614 385 12 | 918 812 13 | 979 734 14 | 951 110 15 | 710 518 16 | 36 772 17 | 61 766 18 | 916 322 19 | 516 145 20 | 322 556 21 | 662 433 22 | 644 857 23 | 619 448 24 | 29 543 25 | 95 368 26 | 808 313 27 | 933 18 28 | 600 191 29 | 944 69 30 | 333 809 31 | 521 310 32 | 417 22 33 | 99 233 34 | 964 97 35 | 924 681 36 | 406 133 37 | 514 796 38 | 453 367 39 | 981 994 40 | 868 169 41 | 881 741 42 | 13 277 43 | 233 261 44 | 139 918 45 | 917 603 46 | 377 163 47 | 48 91 48 | 746 590 49 | 155 885 50 | 942 671 51 | 70 119 52 | 894 293 53 | 399 71 54 | 809 166 55 | 263 486 56 | 596 531 57 | 529 219 58 | 424 415 59 | 550 528 60 | 907 347 61 | 749 848 62 | 914 927 63 | 279 607 64 | 724 917 65 | 951 127 66 | 173 326 67 | 899 261 68 | 325 690 69 | 779 816 70 | 928 406 71 | 29 959 72 | 873 860 73 | 62 99 74 | 40 335 75 | 62 90 76 | 63 217 77 | 715 787 78 | 404 17 79 | 994 213 80 | 997 369 81 | 741 536 82 | 487 801 83 | 940 416 84 | 500 716 85 | 220 622 86 | 600 928 87 | 997 732 88 | 900 221 89 | 989 111 90 | 590 310 91 | 516 84 92 | 768 890 93 | 868 766 94 | 632 20 95 | 617 901 96 | 136 748 97 | 147 57 98 | 527 945 99 | 329 726 100 | 900 269 101 | 566 985 102 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/A-large-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 821 455 3 | 1548 733 4 | 858 291 5 | 1595 28 6 | 1174 995 7 | 1476 454 8 | 690 333 9 | 1230 896 10 | 533 149 11 | 1941 1758 12 | 1976 339 13 | 2000 0 14 | 398 93 15 | 1659 1028 16 | 1894 961 17 | 1388 874 18 | 1354 1149 19 | 1778 1287 20 | 886 283 21 | 1431 822 22 | 679 544 23 | 1405 1150 24 | 1228 379 25 | 1607 1129 26 | 1265 457 27 | 1885 1572 28 | 1451 1348 29 | 1712 975 30 | 921 494 31 | 1966 354 32 | 1299 536 33 | 1872 874 34 | 1831 1125 35 | 1101 822 36 | 1057 526 37 | 1761 639 38 | 1111 137 39 | 445 425 40 | 670 362 41 | 1009 737 42 | 2000 1 43 | 1504 28 44 | 1821 560 45 | 1521 1373 46 | 823 361 47 | 836 140 48 | 1763 1599 49 | 1288 162 50 | 417 357 51 | 1020 122 52 | 1617 1576 53 | 1493 780 54 | 1868 34 55 | 1452 1240 56 | 2 1 57 | 584 242 58 | 1610 1196 59 | 1423 1296 60 | 975 479 61 | 1000 80 62 | 1227 1035 63 | 1812 260 64 | 1875 1294 65 | 1882 826 66 | 1401 1348 67 | 1449 494 68 | 1807 512 69 | 1118 432 70 | 1168 184 71 | 1421 980 72 | 1265 270 73 | 1474 1172 74 | 606 556 75 | 1 0 76 | 1543 124 77 | 1935 1383 78 | 1969 1150 79 | 1394 1223 80 | 961 203 81 | 1453 318 82 | 1979 818 83 | 333 302 84 | 1830 1041 85 | 1163 620 86 | 1446 514 87 | 1229 1116 88 | 1590 1215 89 | 990 252 90 | 948 918 91 | 2000 1999 92 | 1077 717 93 | 1296 801 94 | 1807 370 95 | 253 218 96 | 789 452 97 | 1647 203 98 | 1807 15 99 | 1503 929 100 | 1111 266 101 | 1534 564 102 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/C-solution.py: -------------------------------------------------------------------------------- 1 | import collections 2 | 3 | Endpoint = collections.namedtuple("Endpoint", ["index", "value", "start"]) 4 | 5 | T = int(input()) 6 | for t in range(1, T + 1): 7 | N, L1, R1, A, B, C1, C2, M = map(int, input().split()) 8 | endpoints = [Endpoint(0, L1, True), Endpoint(0, R1 + 1, False)] 9 | for i in range(1, N): 10 | x = (A * L1 + B * R1 + C1) % M 11 | y = (A * R1 + B * L1 + C2) % M 12 | endpoints.append(Endpoint(i, min(x, y), True)) 13 | endpoints.append(Endpoint(i, max(x, y) + 1, False)) 14 | L1, R1 = x, y 15 | endpoints.sort(key = lambda endpoint: endpoint.value) 16 | unique_integers = {} 17 | current_intervals = set() 18 | total_integers = 0 19 | for endpoint in endpoints: 20 | if not current_intervals: 21 | interval_start = endpoint 22 | elif len(current_intervals) == 1: 23 | index = next(iter(current_intervals)) 24 | unique_integers[index] = (unique_integers.get(index, 0) + 25 | endpoint.value - unique_start.value) 26 | if endpoint.start: 27 | current_intervals.add(endpoint.index) 28 | else: 29 | current_intervals.remove(endpoint.index) 30 | if not current_intervals: 31 | total_integers += endpoint.value - interval_start.value 32 | elif len(current_intervals) == 1: 33 | unique_start = endpoint 34 | print(f"Case #{t}: {total_integers - max(unique_integers.values())}") 35 | -------------------------------------------------------------------------------- /2014/Round A/Problem B/B-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 2 | 0 0 2 4 3 | 0 0 4 8 4 | 0 2 16 32 5 | 0 0 4 16 6 | Case #2: 7 | 0 2 2 4 8 | 0 0 4 8 9 | 0 0 16 32 10 | 0 0 4 16 11 | Case #3: 12 | 0 0 0 0 13 | 0 0 0 0 14 | 0 0 0 0 15 | 0 0 0 0 16 | Case #4: 17 | 0 0 0 0 18 | 0 0 0 0 19 | 4 4 4 4 20 | 4 4 4 4 21 | Case #5: 22 | 4 4 0 0 23 | 4 4 0 0 24 | 4 4 0 0 25 | 4 4 0 0 26 | Case #6: 27 | 0 0 4 4 28 | 0 0 4 4 29 | 0 0 4 4 30 | 0 0 4 4 31 | Case #7: 32 | 4 4 4 4 33 | 4 4 4 4 34 | 0 0 0 0 35 | 0 0 0 0 36 | Case #8: 37 | 4 8 0 0 38 | 4 8 0 0 39 | 4 8 0 0 40 | 4 8 0 0 41 | Case #9: 42 | 0 0 0 0 43 | 0 0 0 0 44 | 2048 2048 2048 2048 45 | 2048 2048 2048 2048 46 | Case #10: 47 | 2048 2048 0 0 48 | 2048 2048 0 0 49 | 2048 2048 0 0 50 | 2048 2048 0 0 51 | Case #11: 52 | 0 0 2048 2048 53 | 0 0 2048 2048 54 | 0 0 2048 2048 55 | 0 0 2048 2048 56 | Case #12: 57 | 2048 2048 2048 2048 58 | 2048 2048 2048 2048 59 | 0 0 0 0 60 | 0 0 0 0 61 | Case #13: 62 | 256 512 512 256 63 | 0 0 0 128 64 | 0 0 0 2 65 | 0 0 0 4 66 | Case #14: 67 | 0 0 0 512 68 | 0 0 0 0 69 | 0 0 0 128 70 | 0 0 0 0 71 | Case #15: 72 | 0 0 8 32 73 | 0 0 0 0 74 | 0 0 2 64 75 | 0 0 0 2 76 | Case #16: 77 | 0 0 0 0 78 | 0 0 0 1024 79 | 0 0 0 8 80 | 0 0 0 4 81 | Case #17: 82 | 16 4 0 0 83 | 1024 4 0 0 84 | 1024 16 1024 0 85 | 8 128 1024 0 86 | Case #18: 87 | 16 2 0 0 88 | 128 2 16 128 89 | 1024 2 4 256 90 | 4 2 4 0 91 | Case #19: 92 | 0 0 0 0 93 | 0 4 2 1024 94 | 128 8 8 32 95 | 8 512 256 8 96 | Case #20: 97 | 2 4 4 2 98 | 4 2 128 4 99 | 8 4 256 0 100 | 0 256 2 0 101 | -------------------------------------------------------------------------------- /2014/Round A/Problem B/B-small-practice.in: -------------------------------------------------------------------------------- 1 | 20 2 | 4 right 3 | 0 0 2 4 4 | 0 0 4 8 5 | 0 2 16 32 6 | 0 2 2 16 7 | 4 up 8 | 0 0 2 4 9 | 0 0 4 8 10 | 0 2 16 32 11 | 0 0 4 16 12 | 4 up 13 | 0 0 0 0 14 | 0 0 0 0 15 | 0 0 0 0 16 | 0 0 0 0 17 | 4 down 18 | 2 2 2 2 19 | 2 2 2 2 20 | 2 2 2 2 21 | 2 2 2 2 22 | 4 left 23 | 2 2 2 2 24 | 2 2 2 2 25 | 2 2 2 2 26 | 2 2 2 2 27 | 4 right 28 | 2 2 2 2 29 | 2 2 2 2 30 | 2 2 2 2 31 | 2 2 2 2 32 | 4 up 33 | 2 2 2 2 34 | 2 2 2 2 35 | 2 2 2 2 36 | 2 2 2 2 37 | 4 left 38 | 2 2 4 4 39 | 2 2 4 4 40 | 2 2 4 4 41 | 2 2 4 4 42 | 4 down 43 | 1024 1024 1024 1024 44 | 1024 1024 1024 1024 45 | 1024 1024 1024 1024 46 | 1024 1024 1024 1024 47 | 4 left 48 | 1024 1024 1024 1024 49 | 1024 1024 1024 1024 50 | 1024 1024 1024 1024 51 | 1024 1024 1024 1024 52 | 4 right 53 | 1024 1024 1024 1024 54 | 1024 1024 1024 1024 55 | 1024 1024 1024 1024 56 | 1024 1024 1024 1024 57 | 4 up 58 | 1024 1024 1024 1024 59 | 1024 1024 1024 1024 60 | 1024 1024 1024 1024 61 | 1024 1024 1024 1024 62 | 4 up 63 | 0 512 512 256 64 | 0 0 0 128 65 | 0 0 0 2 66 | 256 0 0 4 67 | 4 right 68 | 0 0 512 0 69 | 0 0 0 0 70 | 128 0 0 0 71 | 0 0 0 0 72 | 4 right 73 | 4 0 4 32 74 | 0 0 0 0 75 | 2 0 0 64 76 | 0 2 0 0 77 | 4 right 78 | 0 0 0 0 79 | 1024 0 0 0 80 | 0 0 0 8 81 | 2 0 2 0 82 | 4 left 83 | 0 16 0 4 84 | 0 0 1024 4 85 | 1024 8 8 1024 86 | 4 4 128 1024 87 | 4 left 88 | 0 16 0 2 89 | 128 2 16 128 90 | 1024 2 4 256 91 | 4 2 0 4 92 | 4 down 93 | 128 4 0 1024 94 | 0 4 2 32 95 | 4 4 8 4 96 | 4 512 256 4 97 | 4 up 98 | 0 4 4 0 99 | 2 2 128 2 100 | 4 4 256 0 101 | 8 256 2 4 102 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/A-large-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 36499 40104 3 | 75814 21934 4 | 88684 2943 5 | 63688 19182 6 | 71034 19757 7 | 95210 572 8 | 50000 50000 9 | 37583 54023 10 | 13403 50583 11 | 74324 16176 12 | 95662 20 13 | 84426 8859 14 | 1764 75732 15 | 75135 17355 16 | 16014 48995 17 | 100000 0 18 | 90812 5679 19 | 55860 34690 20 | 82678 16936 21 | 50696 22228 22 | 60183 19425 23 | 88288 3180 24 | 18628 32214 25 | 99681 195 26 | 7 13 27 | 62367 35577 28 | 54171 29950 29 | 22417 8626 30 | 37824 9490 31 | 95981 624 32 | 57025 7699 33 | 1 1 34 | 16007 35971 35 | 2306 52078 36 | 70555 4927 37 | 19454 63092 38 | 73352 18081 39 | 71344 18591 40 | 76452 13351 41 | 88885 3106 42 | 53619 9977 43 | 39466 15681 44 | 33791 51813 45 | 40408 42624 46 | 998 12 47 | 58818 23613 48 | 82533 6389 49 | 73823 18704 50 | 24046 69819 51 | 83603 2337 52 | 95719 1658 53 | 9 11 54 | 29910 7601 55 | 59540 36291 56 | 45871 53970 57 | 92763 325 58 | 9038 44798 59 | 1 0 60 | 86549 6287 61 | 14401 46864 62 | 93424 6259 63 | 52933 31692 64 | 91388 2050 65 | 83487 14454 66 | 26996 20778 67 | 88436 1856 68 | 52967 22634 69 | 24373 71635 70 | 25964 41310 71 | 89807 7750 72 | 84029 12987 73 | 23884 41559 74 | 96652 1790 75 | 72470 2981 76 | 51157 44196 77 | 5964 125 78 | 5011 79606 79 | 54850 32315 80 | 94427 666 81 | 61766 28774 82 | 90805 8083 83 | 50250 34260 84 | 59514 16501 85 | 21448 21340 86 | 48294 20183 87 | 0 100000 88 | 0 1 89 | 9321 9795 90 | 33373 207 91 | 78080 18989 92 | 89341 7009 93 | 0 2 94 | 2 0 95 | 90124 7716 96 | 36611 12311 97 | 45498 3564 98 | 28355 23958 99 | 58516 24422 100 | 42157 56858 101 | 32854 55517 102 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem B. Beautiful Numbers: 2 | https://code.google.com/codejam/contest/5264487/dashboard#s=p1 3 | 4 | =============================== 5 | `Problem B. Beautiful Numbers`_ 6 | =============================== 7 | 8 | Problem 9 | ------- 10 | We consider a number to be *beautiful* if it consists only of the digit 1 11 | repeated one or more times. Not all numbers are beautiful, but we can make any 12 | base 10 positive integer beautiful by writing it in another base. 13 | 14 | Given an integer **N**, can you find a base *B* (with *B* > 1) to write it in 15 | such that all of its digits become 1? If there are multiple bases that satisfy 16 | this property, choose the one that maximizes the number of 1 digits. 17 | 18 | Input 19 | ----- 20 | The first line of the input gives the number of test cases, **T**. 21 | **T** test cases follow. 22 | Each test case consists of one line with an integer **N**. 23 | 24 | Output 25 | ------ 26 | For each test case, output one line containing ``Case #x: y``, 27 | where ``x`` is the test case number (starting from 1) 28 | and ``y`` is the base described in the problem statement. 29 | 30 | Limits 31 | ------ 32 | 1 ≤ **T** ≤ 100. 33 | 34 | Small dataset 35 | ------------- 36 | 3 ≤ **N** ≤ 1000. 37 | 38 | Large dataset 39 | ------------- 40 | 3 ≤ **N** ≤ 10\ :sup:`18`. 41 | 42 | Sample 43 | ------ 44 | 45 | :: 46 | 47 | Input Output 48 | 49 | 2 Case #1: 2 50 | 3 Case #2: 3 51 | 13 52 | 53 | In case #1, the optimal solution is to write 3 as 11 in base 2. 54 | 55 | In case #2, the optimal solution is to write 13 as 111 in base 3. 56 | Note that we could also write 13 as 11 in base 12, 57 | but neither of those representations has as many 1s. 58 | -------------------------------------------------------------------------------- /2014/Round A/Problem D/D-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1 2 | Case #2: 2 3 | Case #3: 4 4 | Case #4: 1 5 | Case #5: 9 6 | Case #6: 1 7 | Case #7: 2 8 | Case #8: 1 9 | Case #9: 1 10 | Case #10: 2 11 | Case #11: 1 12 | Case #12: 2 13 | Case #13: 2 14 | Case #14: 5 15 | Case #15: 2 16 | Case #16: 1 17 | Case #17: 4 18 | Case #18: 1 19 | Case #19: 2 20 | Case #20: 5 21 | Case #21: 3 22 | Case #22: 1 23 | Case #23: 2 24 | Case #24: 1 25 | Case #25: 2 26 | Case #26: 2 27 | Case #27: 2 28 | Case #28: 3 29 | Case #29: 4 30 | Case #30: 1 31 | Case #31: 1 32 | Case #32: 8 33 | Case #33: 2 34 | Case #34: 4 35 | Case #35: 2 36 | Case #36: 2 37 | Case #37: 3 38 | Case #38: 1 39 | Case #39: 1 40 | Case #40: 4 41 | Case #41: 1 42 | Case #42: 3 43 | Case #43: 6 44 | Case #44: 1 45 | Case #45: 1 46 | Case #46: 9 47 | Case #47: 1 48 | Case #48: 1 49 | Case #49: 3 50 | Case #50: 6 51 | Case #51: 8 52 | Case #52: 4 53 | Case #53: 3 54 | Case #54: 1 55 | Case #55: 5 56 | Case #56: 1 57 | Case #57: 1 58 | Case #58: 5 59 | Case #59: 7 60 | Case #60: 4 61 | Case #61: 3 62 | Case #62: 7 63 | Case #63: 3 64 | Case #64: 1 65 | Case #65: 1 66 | Case #66: 6 67 | Case #67: 11 68 | Case #68: 7 69 | Case #69: 6 70 | Case #70: 1 71 | Case #71: 7 72 | Case #72: 3 73 | Case #73: 4 74 | Case #74: 1 75 | Case #75: 1 76 | Case #76: 7 77 | Case #77: 4 78 | Case #78: 2 79 | Case #79: 20 80 | Case #80: 7 81 | Case #81: 2 82 | Case #82: 12 83 | Case #83: 4 84 | Case #84: 20 85 | Case #85: 3 86 | Case #86: 20 87 | Case #87: 4 88 | Case #88: 8 89 | Case #89: 3 90 | Case #90: 2 91 | Case #91: 11 92 | Case #92: 2 93 | Case #93: 2 94 | Case #94: 5 95 | Case #95: 4 96 | Case #96: 10 97 | Case #97: 20 98 | Case #98: 4 99 | Case #99: 1 100 | Case #100: 7 101 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1 2 | Case #2: 10 3 | Case #3: 10 4 | Case #4: 21 5 | Case #5: 1 6 | Case #6: 3 7 | Case #7: 55 8 | Case #8: 6 9 | Case #9: 6 10 | Case #10: 10 11 | Case #11: 3 12 | Case #12: 21 13 | Case #13: 10 14 | Case #14: 15 15 | Case #15: 6 16 | Case #16: 0 17 | Case #17: 6 18 | Case #18: 0 19 | Case #19: 3 20 | Case #20: 10 21 | Case #21: 6 22 | Case #22: 36 23 | Case #23: 21 24 | Case #24: 1 25 | Case #25: 28 26 | Case #26: 21 27 | Case #27: 36 28 | Case #28: 1 29 | Case #29: 3 30 | Case #30: 1 31 | Case #31: 10 32 | Case #32: 1 33 | Case #33: 28 34 | Case #34: 21 35 | Case #35: 3 36 | Case #36: 3 37 | Case #37: 1 38 | Case #38: 10 39 | Case #39: 28 40 | Case #40: 1 41 | Case #41: 1 42 | Case #42: 15 43 | Case #43: 15 44 | Case #44: 36 45 | Case #45: 3 46 | Case #46: 1 47 | Case #47: 10 48 | Case #48: 6 49 | Case #49: 1 50 | Case #50: 6 51 | Case #51: 1 52 | Case #52: 45 53 | Case #53: 1 54 | Case #54: 0 55 | Case #55: 6 56 | Case #56: 3 57 | Case #57: 3 58 | Case #58: 0 59 | Case #59: 1 60 | Case #60: 1 61 | Case #61: 6 62 | Case #62: 28 63 | Case #63: 21 64 | Case #64: 1 65 | Case #65: 3 66 | Case #66: 10 67 | Case #67: 28 68 | Case #68: 6 69 | Case #69: 10 70 | Case #70: 28 71 | Case #71: 15 72 | Case #72: 10 73 | Case #73: 3 74 | Case #74: 1 75 | Case #75: 6 76 | Case #76: 10 77 | Case #77: 1 78 | Case #78: 15 79 | Case #79: 28 80 | Case #80: 10 81 | Case #81: 15 82 | Case #82: 55 83 | Case #83: 6 84 | Case #84: 10 85 | Case #85: 15 86 | Case #86: 0 87 | Case #87: 0 88 | Case #88: 1 89 | Case #89: 6 90 | Case #90: 0 91 | Case #91: 1 92 | Case #92: 0 93 | Case #93: 0 94 | Case #94: 10 95 | Case #95: 45 96 | Case #96: 3 97 | Case #97: 6 98 | Case #98: 3 99 | Case #99: 3 100 | Case #100: 15 101 | -------------------------------------------------------------------------------- /2015/Round E/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 1 2 | Case #2: 36 3 | Case #3: 1 4 | Case #4: 108 5 | Case #5: 108 6 | Case #6: 108 7 | Case #7: 8 8 | Case #8: 1 9 | Case #9: 4 10 | Case #10: 36 11 | Case #11: 32 12 | Case #12: 48 13 | Case #13: 48 14 | Case #14: 1 15 | Case #15: 72 16 | Case #16: 12 17 | Case #17: 12 18 | Case #18: 4 19 | Case #19: 16 20 | Case #20: 108 21 | Case #21: 4 22 | Case #22: 32 23 | Case #23: 48 24 | Case #24: 36 25 | Case #25: 36 26 | Case #26: 12 27 | Case #27: 1 28 | Case #28: 36 29 | Case #29: 48 30 | Case #30: 1 31 | Case #31: 36 32 | Case #32: 48 33 | Case #33: 12 34 | Case #34: 36 35 | Case #35: 12 36 | Case #36: 1 37 | Case #37: 1 38 | Case #38: 16 39 | Case #39: 32 40 | Case #40: 36 41 | Case #41: 108 42 | Case #42: 4 43 | Case #43: 108 44 | Case #44: 36 45 | Case #45: 1 46 | Case #46: 108 47 | Case #47: 36 48 | Case #48: 36 49 | Case #49: 36 50 | Case #50: 16 51 | Case #51: 1 52 | Case #52: 12 53 | Case #53: 48 54 | Case #54: 1 55 | Case #55: 24 56 | Case #56: 1 57 | Case #57: 1 58 | Case #58: 16 59 | Case #59: 1 60 | Case #60: 12 61 | Case #61: 108 62 | Case #62: 36 63 | Case #63: 108 64 | Case #64: 108 65 | Case #65: 36 66 | Case #66: 16 67 | Case #67: 48 68 | Case #68: 48 69 | Case #69: 48 70 | Case #70: 4 71 | Case #71: 72 72 | Case #72: 4 73 | Case #73: 72 74 | Case #74: 4 75 | Case #75: 1 76 | Case #76: 8 77 | Case #77: 12 78 | Case #78: 108 79 | Case #79: 36 80 | Case #80: 108 81 | Case #81: 108 82 | Case #82: 1 83 | Case #83: 4 84 | Case #84: 16 85 | Case #85: 36 86 | Case #86: 4 87 | Case #87: 1 88 | Case #88: 108 89 | Case #89: 72 90 | Case #90: 4 91 | Case #91: 4 92 | Case #92: 1 93 | Case #93: 36 94 | Case #94: 1 95 | Case #95: 48 96 | Case #96: 32 97 | Case #97: 72 98 | Case #98: 108 99 | Case #99: 16 100 | Case #100: 4 101 | -------------------------------------------------------------------------------- /2014/Round A/Problem C/C-solution.py: -------------------------------------------------------------------------------- 1 | from itertools import combinations_with_replacement as combinations_w_r 2 | 3 | T = int(input()) 4 | for t in range(1, T + 1): 5 | N = int(input()) 6 | equations = {} 7 | original_equations = {} 8 | for n in range(N): 9 | expression, z = input().split('=') 10 | x, y = expression.split('+') 11 | if (x, y) not in equations: 12 | z = int(z) 13 | equations[(x, y)] = equations[(y, x)] = z 14 | original_equations[(x, y)] = z 15 | previous_length = -1 16 | while len(equations) != previous_length: 17 | previous_length = len(equations) 18 | combinations = combinations_w_r(original_equations.items(), 2) 19 | for ((x1, y1), z1), ((x2, y2), z2) in combinations: 20 | if (x1, x2) in equations and (y1, y2) not in equations: 21 | z = z1 + z2 - equations[(x1, x2)] 22 | equations[(y1, y2)] = equations[(y2, y1)] = z 23 | if (x1, y2) in equations and (y1, x2) not in equations: 24 | z = z1 + z2 - equations[(x1, y2)] 25 | equations[(y1, x2)] = equations[(x2, y1)] = z 26 | if (y1, x2) in equations and (x1, y2) not in equations: 27 | z = z1 + z2 - equations[(y1, x2)] 28 | equations[(x1, y2)] = equations[(y2, x1)] = z 29 | if (y1, y2) in equations and (x1, x2) not in equations: 30 | z = z1 + z2 - equations[(y1, y2)] 31 | equations[(x1, x2)] = equations[(x2, x1)] = z 32 | print(f"Case #{t}:") 33 | Q = int(input()) 34 | for q in range(Q): 35 | x, y = input().split('+') 36 | if (x, y) in equations: 37 | print(f"{x}+{y}={equations[(x, y)]}") 38 | elif (x, x) in equations and (y, y) in equations: 39 | print(f"{x}+{y}={(equations[(x, x)] + equations[(y, y)]) // 2}") 40 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-small-attempt0-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 5 2 | Case #2: 16 3 | Case #3: 0 4 | Case #4: 768 5 | Case #5: 873 6 | Case #6: 1008 7 | Case #7: 876 8 | Case #8: 0 9 | Case #9: 220 10 | Case #10: 512 11 | Case #11: 0 12 | Case #12: 0 13 | Case #13: 1008 14 | Case #14: 0 15 | Case #15: 1008 16 | Case #16: 768 17 | Case #17: 0 18 | Case #18: 1023 19 | Case #19: 994 20 | Case #20: 872 21 | Case #21: 0 22 | Case #22: 0 23 | Case #23: 992 24 | Case #24: 0 25 | Case #25: 0 26 | Case #26: 320 27 | Case #27: 0 28 | Case #28: 0 29 | Case #29: 784 30 | Case #30: 0 31 | Case #31: 864 32 | Case #32: 0 33 | Case #33: 896 34 | Case #34: 1008 35 | Case #35: 256 36 | Case #36: 0 37 | Case #37: 0 38 | Case #38: 0 39 | Case #39: 0 40 | Case #40: 1020 41 | Case #41: 0 42 | Case #42: 0 43 | Case #43: 0 44 | Case #44: 384 45 | Case #45: 896 46 | Case #46: 992 47 | Case #47: 0 48 | Case #48: 839 49 | Case #49: 869 50 | Case #50: 0 51 | Case #51: 0 52 | Case #52: 768 53 | Case #53: 868 54 | Case #54: 1008 55 | Case #55: 508 56 | Case #56: 1 57 | Case #57: 1023 58 | Case #58: 0 59 | Case #59: 0 60 | Case #60: 873 61 | Case #61: 319 62 | Case #62: 0 63 | Case #63: 868 64 | Case #64: 512 65 | Case #65: 0 66 | Case #66: 1016 67 | Case #67: 839 68 | Case #68: 992 69 | Case #69: 0 70 | Case #70: 0 71 | Case #71: 859 72 | Case #72: 0 73 | Case #73: 0 74 | Case #74: 0 75 | Case #75: 866 76 | Case #76: 488 77 | Case #77: 512 78 | Case #78: 0 79 | Case #79: 1023 80 | Case #80: 872 81 | Case #81: 0 82 | Case #82: 873 83 | Case #83: 0 84 | Case #84: 962 85 | Case #85: 0 86 | Case #86: 863 87 | Case #87: 0 88 | Case #88: 0 89 | Case #89: 440 90 | Case #90: 0 91 | Case #91: 862 92 | Case #92: 960 93 | Case #93: 832 94 | Case #94: 852 95 | Case #95: 1022 96 | Case #96: 877 97 | Case #97: 0 98 | Case #98: 0 99 | Case #99: 864 100 | Case #100: 125 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 5 2 | Case #2: 16 3 | Case #3: 0 4 | Case #4: 768 5 | Case #5: 252 6 | Case #6: 512 7 | Case #7: 512 8 | Case #8: 1012 9 | Case #9: 0 10 | Case #10: 0 11 | Case #11: 0 12 | Case #12: 224 13 | Case #13: 0 14 | Case #14: 1008 15 | Case #15: 1023 16 | Case #16: 1 17 | Case #17: 0 18 | Case #18: 0 19 | Case #19: 0 20 | Case #20: 0 21 | Case #21: 841 22 | Case #22: 0 23 | Case #23: 0 24 | Case #24: 0 25 | Case #25: 0 26 | Case #26: 0 27 | Case #27: 865 28 | Case #28: 0 29 | Case #29: 0 30 | Case #30: 1023 31 | Case #31: 280 32 | Case #32: 1020 33 | Case #33: 807 34 | Case #34: 0 35 | Case #35: 0 36 | Case #36: 0 37 | Case #37: 872 38 | Case #38: 800 39 | Case #39: 876 40 | Case #40: 0 41 | Case #41: 884 42 | Case #42: 1016 43 | Case #43: 0 44 | Case #44: 992 45 | Case #45: 0 46 | Case #46: 992 47 | Case #47: 256 48 | Case #48: 832 49 | Case #49: 0 50 | Case #50: 0 51 | Case #51: 0 52 | Case #52: 992 53 | Case #53: 0 54 | Case #54: 837 55 | Case #55: 0 56 | Case #56: 992 57 | Case #57: 879 58 | Case #58: 0 59 | Case #59: 1022 60 | Case #60: 874 61 | Case #61: 876 62 | Case #62: 0 63 | Case #63: 0 64 | Case #64: 896 65 | Case #65: 857 66 | Case #66: 0 67 | Case #67: 388 68 | Case #68: 1022 69 | Case #69: 0 70 | Case #70: 832 71 | Case #71: 256 72 | Case #72: 0 73 | Case #73: 1012 74 | Case #74: 0 75 | Case #75: 828 76 | Case #76: 1008 77 | Case #77: 0 78 | Case #78: 0 79 | Case #79: 0 80 | Case #80: 992 81 | Case #81: 240 82 | Case #82: 768 83 | Case #83: 882 84 | Case #84: 0 85 | Case #85: 0 86 | Case #86: 512 87 | Case #87: 992 88 | Case #88: 837 89 | Case #89: 855 90 | Case #90: 1021 91 | Case #91: 64 92 | Case #92: 852 93 | Case #93: 0 94 | Case #94: 843 95 | Case #95: 0 96 | Case #96: 849 97 | Case #97: 769 98 | Case #98: 520 99 | Case #99: 1017 100 | Case #100: 0 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-small-attempt1-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 5 2 | Case #2: 16 3 | Case #3: 0 4 | Case #4: 768 5 | Case #5: 829 6 | Case #6: 0 7 | Case #7: 0 8 | Case #8: 1020 9 | Case #9: 0 10 | Case #10: 770 11 | Case #11: 880 12 | Case #12: 0 13 | Case #13: 865 14 | Case #14: 0 15 | Case #15: 0 16 | Case #16: 846 17 | Case #17: 384 18 | Case #18: 0 19 | Case #19: 1018 20 | Case #20: 0 21 | Case #21: 0 22 | Case #22: 0 23 | Case #23: 896 24 | Case #24: 0 25 | Case #25: 768 26 | Case #26: 0 27 | Case #27: 0 28 | Case #28: 1023 29 | Case #29: 0 30 | Case #30: 1023 31 | Case #31: 964 32 | Case #32: 0 33 | Case #33: 0 34 | Case #34: 0 35 | Case #35: 640 36 | Case #36: 846 37 | Case #37: 1008 38 | Case #38: 0 39 | Case #39: 1008 40 | Case #40: 0 41 | Case #41: 853 42 | Case #42: 328 43 | Case #43: 1016 44 | Case #44: 512 45 | Case #45: 1022 46 | Case #46: 0 47 | Case #47: 1016 48 | Case #48: 992 49 | Case #49: 0 50 | Case #50: 0 51 | Case #51: 842 52 | Case #52: 1 53 | Case #53: 859 54 | Case #54: 896 55 | Case #55: 1022 56 | Case #56: 0 57 | Case #57: 416 58 | Case #58: 867 59 | Case #59: 0 60 | Case #60: 1022 61 | Case #61: 0 62 | Case #62: 512 63 | Case #63: 0 64 | Case #64: 868 65 | Case #65: 0 66 | Case #66: 859 67 | Case #67: 867 68 | Case #68: 128 69 | Case #69: 0 70 | Case #70: 0 71 | Case #71: 864 72 | Case #72: 0 73 | Case #73: 772 74 | Case #74: 1008 75 | Case #75: 0 76 | Case #76: 870 77 | Case #77: 0 78 | Case #78: 64 79 | Case #79: 1016 80 | Case #80: 0 81 | Case #81: 640 82 | Case #82: 847 83 | Case #83: 352 84 | Case #84: 320 85 | Case #85: 861 86 | Case #86: 224 87 | Case #87: 0 88 | Case #88: 0 89 | Case #89: 992 90 | Case #90: 544 91 | Case #91: 768 92 | Case #92: 1020 93 | Case #93: 1009 94 | Case #94: 0 95 | Case #95: 0 96 | Case #96: 854 97 | Case #97: 873 98 | Case #98: 0 99 | Case #99: 1023 100 | Case #100: 0 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-large-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 6 2 | Case #2: 14 3 | Case #3: 7 4 | Case #4: 31 5 | Case #5: 150 6 | Case #6: 281 7 | Case #7: 11249949 8 | Case #8: 174 9 | Case #9: 169 10 | Case #10: 244 11 | Case #11: 289 12 | Case #12: 122 13 | Case #13: 321 14 | Case #14: 151 15 | Case #15: 279 16 | Case #16: 342 17 | Case #17: 183 18 | Case #18: 286 19 | Case #19: 123 20 | Case #20: 287 21 | Case #21: 211 22 | Case #22: 284 23 | Case #23: 1 24 | Case #24: 149 25 | Case #25: 377 26 | Case #26: 228 27 | Case #27: 203 28 | Case #28: 225 29 | Case #29: 408 30 | Case #30: 68 31 | Case #31: 115 32 | Case #32: 0 33 | Case #33: 231 34 | Case #34: 256 35 | Case #35: 255 36 | Case #36: 238 37 | Case #37: 204 38 | Case #38: 77 39 | Case #39: 3 40 | Case #40: 261 41 | Case #41: 160 42 | Case #42: 192 43 | Case #43: 289 44 | Case #44: 263 45 | Case #45: 47 46 | Case #46: 0 47 | Case #47: 50 48 | Case #48: 258 49 | Case #49: 203 50 | Case #50: 204 51 | Case #51: 278 52 | Case #52: 258 53 | Case #53: 313 54 | Case #54: 324 55 | Case #55: 56 56 | Case #56: 216 57 | Case #57: 225 58 | Case #58: 279 59 | Case #59: 372 60 | Case #60: 278 61 | Case #61: 1 62 | Case #62: 450 63 | Case #63: 92 64 | Case #64: 251 65 | Case #65: 158 66 | Case #66: 277 67 | Case #67: 354 68 | Case #68: 112 69 | Case #69: 239 70 | Case #70: 146 71 | Case #71: 254 72 | Case #72: 170 73 | Case #73: 247 74 | Case #74: 2 75 | Case #75: 138 76 | Case #76: 393 77 | Case #77: 298 78 | Case #78: 287 79 | Case #79: 248 80 | Case #80: 323 81 | Case #81: 270 82 | Case #82: 219 83 | Case #83: 2 84 | Case #84: 65 85 | Case #85: 204 86 | Case #86: 282 87 | Case #87: 144 88 | Case #88: 18 89 | Case #89: 1 90 | Case #90: 370 91 | Case #91: 202 92 | Case #92: 164 93 | Case #93: 3 94 | Case #94: 285 95 | Case #95: 173 96 | Case #96: 167 97 | Case #97: 339 98 | Case #98: 86 99 | Case #99: 209 100 | Case #100: 15 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-small-attempt1-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 6 2 | Case #2: 14 3 | Case #3: 7 4 | Case #4: 31 5 | Case #5: 120 6 | Case #6: 282 7 | Case #7: 127 8 | Case #8: 215 9 | Case #9: 15 10 | Case #10: 209 11 | Case #11: 301 12 | Case #12: 225 13 | Case #13: 3 14 | Case #14: 304 15 | Case #15: 192 16 | Case #16: 450 17 | Case #17: 315 18 | Case #18: 255 19 | Case #19: 195 20 | Case #20: 250 21 | Case #21: 67 22 | Case #22: 235 23 | Case #23: 122 24 | Case #24: 264 25 | Case #25: 3 26 | Case #26: 373 27 | Case #27: 301 28 | Case #28: 261 29 | Case #29: 182 30 | Case #30: 287 31 | Case #31: 95 32 | Case #32: 2 33 | Case #33: 0 34 | Case #34: 1 35 | Case #35: 268 36 | Case #36: 294 37 | Case #37: 209 38 | Case #38: 279 39 | Case #39: 139 40 | Case #40: 275 41 | Case #41: 241 42 | Case #42: 179 43 | Case #43: 0 44 | Case #44: 166 45 | Case #45: 27 46 | Case #46: 284 47 | Case #47: 418 48 | Case #48: 29 49 | Case #49: 124 50 | Case #50: 176 51 | Case #51: 160 52 | Case #52: 247 53 | Case #53: 58 54 | Case #54: 350 55 | Case #55: 258 56 | Case #56: 316 57 | Case #57: 180 58 | Case #58: 338 59 | Case #59: 184 60 | Case #60: 1 61 | Case #61: 120 62 | Case #62: 235 63 | Case #63: 75 64 | Case #64: 264 65 | Case #65: 22 66 | Case #66: 212 67 | Case #67: 219 68 | Case #68: 119 69 | Case #69: 207 70 | Case #70: 65 71 | Case #71: 322 72 | Case #72: 66 73 | Case #73: 324 74 | Case #74: 107 75 | Case #75: 211 76 | Case #76: 88 77 | Case #77: 301 78 | Case #78: 279 79 | Case #79: 66 80 | Case #80: 251 81 | Case #81: 124 82 | Case #82: 214 83 | Case #83: 115 84 | Case #84: 1 85 | Case #85: 71 86 | Case #86: 377 87 | Case #87: 266 88 | Case #88: 121 89 | Case #89: 55 90 | Case #90: 430 91 | Case #91: 355 92 | Case #92: 18 93 | Case #93: 121 94 | Case #94: 318 95 | Case #95: 376 96 | Case #96: 225 97 | Case #97: 138 98 | Case #98: 2 99 | Case #99: 186 100 | Case #100: 304 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-small-attempt0-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 6 2 | Case #2: 14 3 | Case #3: 7 4 | Case #4: 31 5 | Case #5: 18 6 | Case #6: 1 7 | Case #7: 215 8 | Case #8: 56 9 | Case #9: 122 10 | Case #10: 284 11 | Case #11: 257 12 | Case #12: 319 13 | Case #13: 145 14 | Case #14: 178 15 | Case #15: 427 16 | Case #16: 237 17 | Case #17: 155 18 | Case #18: 285 19 | Case #19: 52 20 | Case #20: 360 21 | Case #21: 1 22 | Case #22: 72 23 | Case #23: 203 24 | Case #24: 295 25 | Case #25: 270 26 | Case #26: 80 27 | Case #27: 380 28 | Case #28: 121 29 | Case #29: 2 30 | Case #30: 407 31 | Case #31: 393 32 | Case #32: 265 33 | Case #33: 225 34 | Case #34: 230 35 | Case #35: 257 36 | Case #36: 285 37 | Case #37: 238 38 | Case #38: 194 39 | Case #39: 193 40 | Case #40: 364 41 | Case #41: 167 42 | Case #42: 194 43 | Case #43: 237 44 | Case #44: 15 45 | Case #45: 299 46 | Case #46: 275 47 | Case #47: 90 48 | Case #48: 330 49 | Case #49: 159 50 | Case #50: 228 51 | Case #51: 65 52 | Case #52: 152 53 | Case #53: 284 54 | Case #54: 184 55 | Case #55: 3 56 | Case #56: 253 57 | Case #57: 1 58 | Case #58: 130 59 | Case #59: 177 60 | Case #60: 225 61 | Case #61: 328 62 | Case #62: 199 63 | Case #63: 250 64 | Case #64: 280 65 | Case #65: 139 66 | Case #66: 90 67 | Case #67: 189 68 | Case #68: 251 69 | Case #69: 225 70 | Case #70: 252 71 | Case #71: 2 72 | Case #72: 95 73 | Case #73: 125 74 | Case #74: 296 75 | Case #75: 58 76 | Case #76: 192 77 | Case #77: 47 78 | Case #78: 109 79 | Case #79: 229 80 | Case #80: 0 81 | Case #81: 299 82 | Case #82: 369 83 | Case #83: 407 84 | Case #84: 278 85 | Case #85: 293 86 | Case #86: 0 87 | Case #87: 385 88 | Case #88: 143 89 | Case #89: 199 90 | Case #90: 128 91 | Case #91: 3 92 | Case #92: 160 93 | Case #93: 149 94 | Case #94: 52 95 | Case #95: 223 96 | Case #96: 154 97 | Case #97: 408 98 | Case #98: 275 99 | Case #99: 404 100 | Case #100: 450 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 6 2 | Case #2: 14 3 | Case #3: 7 4 | Case #4: 31 5 | Case #5: 183 6 | Case #6: 250 7 | Case #7: 231 8 | Case #8: 408 9 | Case #9: 261 10 | Case #10: 379 11 | Case #11: 271 12 | Case #12: 96 13 | Case #13: 69 14 | Case #14: 225 15 | Case #15: 1 16 | Case #16: 284 17 | Case #17: 119 18 | Case #18: 215 19 | Case #19: 147 20 | Case #20: 26 21 | Case #21: 160 22 | Case #22: 298 23 | Case #23: 105 24 | Case #24: 1 25 | Case #25: 211 26 | Case #26: 263 27 | Case #27: 223 28 | Case #28: 236 29 | Case #29: 328 30 | Case #30: 121 31 | Case #31: 254 32 | Case #32: 15 33 | Case #33: 110 34 | Case #34: 368 35 | Case #35: 266 36 | Case #36: 339 37 | Case #37: 271 38 | Case #38: 119 39 | Case #39: 252 40 | Case #40: 289 41 | Case #41: 147 42 | Case #42: 139 43 | Case #43: 83 44 | Case #44: 261 45 | Case #45: 222 46 | Case #46: 209 47 | Case #47: 172 48 | Case #48: 227 49 | Case #49: 358 50 | Case #50: 236 51 | Case #51: 187 52 | Case #52: 241 53 | Case #53: 413 54 | Case #54: 90 55 | Case #55: 332 56 | Case #56: 280 57 | Case #57: 379 58 | Case #58: 250 59 | Case #59: 349 60 | Case #60: 18 61 | Case #61: 133 62 | Case #62: 207 63 | Case #63: 320 64 | Case #64: 225 65 | Case #65: 241 66 | Case #66: 2 67 | Case #67: 262 68 | Case #68: 81 69 | Case #69: 159 70 | Case #70: 199 71 | Case #71: 219 72 | Case #72: 65 73 | Case #73: 388 74 | Case #74: 187 75 | Case #75: 404 76 | Case #76: 158 77 | Case #77: 228 78 | Case #78: 232 79 | Case #79: 242 80 | Case #80: 2 81 | Case #81: 132 82 | Case #82: 253 83 | Case #83: 0 84 | Case #84: 358 85 | Case #85: 311 86 | Case #86: 0 87 | Case #87: 450 88 | Case #88: 178 89 | Case #89: 206 90 | Case #90: 51 91 | Case #91: 1 92 | Case #92: 3 93 | Case #93: 250 94 | Case #94: 293 95 | Case #95: 309 96 | Case #96: 185 97 | Case #97: 3 98 | Case #98: 302 99 | Case #99: 72 100 | Case #100: 255 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 6 2 | Case #2: 14 3 | Case #3: 7 4 | Case #4: 31 5 | Case #5: 291 6 | Case #6: 235 7 | Case #7: 114 8 | Case #8: 100 9 | Case #9: 279 10 | Case #10: 119 11 | Case #11: 342 12 | Case #12: 365 13 | Case #13: 1 14 | Case #14: 302 15 | Case #15: 269 16 | Case #16: 331 17 | Case #17: 158 18 | Case #18: 263 19 | Case #19: 292 20 | Case #20: 210 21 | Case #21: 226 22 | Case #22: 200 23 | Case #23: 261 24 | Case #24: 127 25 | Case #25: 214 26 | Case #26: 252 27 | Case #27: 15 28 | Case #28: 130 29 | Case #29: 73 30 | Case #30: 270 31 | Case #31: 168 32 | Case #32: 319 33 | Case #33: 225 34 | Case #34: 330 35 | Case #35: 171 36 | Case #36: 202 37 | Case #37: 362 38 | Case #38: 182 39 | Case #39: 328 40 | Case #40: 273 41 | Case #41: 198 42 | Case #42: 353 43 | Case #43: 316 44 | Case #44: 253 45 | Case #45: 183 46 | Case #46: 272 47 | Case #47: 100 48 | Case #48: 284 49 | Case #49: 2 50 | Case #50: 238 51 | Case #51: 65 52 | Case #52: 1 53 | Case #53: 165 54 | Case #54: 180 55 | Case #55: 206 56 | Case #56: 189 57 | Case #57: 203 58 | Case #58: 0 59 | Case #59: 139 60 | Case #60: 329 61 | Case #61: 349 62 | Case #62: 284 63 | Case #63: 277 64 | Case #64: 77 65 | Case #65: 247 66 | Case #66: 307 67 | Case #67: 2 68 | Case #68: 11262415 69 | Case #69: 289 70 | Case #70: 184 71 | Case #71: 450 72 | Case #72: 225 73 | Case #73: 30 74 | Case #74: 91 75 | Case #75: 276 76 | Case #76: 177 77 | Case #77: 239 78 | Case #78: 3 79 | Case #79: 299 80 | Case #80: 168 81 | Case #81: 74 82 | Case #82: 18 83 | Case #83: 129 84 | Case #84: 281 85 | Case #85: 160 86 | Case #86: 0 87 | Case #87: 266 88 | Case #88: 303 89 | Case #89: 3 90 | Case #90: 1 91 | Case #91: 165 92 | Case #92: 163 93 | Case #93: 240 94 | Case #94: 229 95 | Case #95: 159 96 | Case #96: 251 97 | Case #97: 219 98 | Case #98: 399 99 | Case #99: 108 100 | Case #100: 374 101 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/B-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 624 2 | Case #2: 92 3 | Case #3: 107 4 | Case #4: 974 5 | Case #5: 862 6 | Case #6: 616 7 | Case #7: 855 8 | Case #8: 74 9 | Case #9: 537 10 | Case #10: 517 11 | Case #11: 124 12 | Case #12: 887 13 | Case #13: 686 14 | Case #14: 637 15 | Case #15: 484 16 | Case #16: 645 17 | Case #17: 324 18 | Case #18: 527 19 | Case #19: 597 20 | Case #20: 574 21 | Case #21: 374 22 | Case #22: 416 23 | Case #23: 605 24 | Case #24: 802 25 | Case #25: 433 26 | Case #26: 383 27 | Case #27: 914 28 | Case #28: 222 29 | Case #29: 999 30 | Case #30: 797 31 | Case #31: 364 32 | Case #32: 317 33 | Case #33: 134 34 | Case #34: 827 35 | Case #35: 13 36 | Case #36: 967 37 | Case #37: 675 38 | Case #38: 923 39 | Case #39: 776 40 | Case #40: 216 41 | Case #41: 205 42 | Case #42: 24 43 | Case #43: 745 44 | Case #44: 907 45 | Case #45: 357 46 | Case #46: 736 47 | Case #47: 2 48 | Case #48: 145 49 | Case #49: 402 50 | Case #50: 44 51 | Case #51: 586 52 | Case #52: 344 53 | Case #53: 196 54 | Case #54: 726 55 | Case #55: 446 56 | Case #56: 13 57 | Case #57: 394 58 | Case #58: 282 59 | Case #59: 265 60 | Case #60: 37 61 | Case #61: 333 62 | Case #62: 465 63 | Case #63: 954 64 | Case #64: 874 65 | Case #65: 426 66 | Case #66: 477 67 | Case #67: 542 68 | Case #68: 174 69 | Case #69: 694 70 | Case #70: 493 71 | Case #71: 247 72 | Case #72: 765 73 | Case #73: 817 74 | Case #74: 982 75 | Case #75: 12 76 | Case #76: 2 77 | Case #77: 942 78 | Case #78: 837 79 | Case #79: 257 80 | Case #80: 555 81 | Case #81: 503 82 | Case #82: 782 83 | Case #83: 115 84 | Case #84: 307 85 | Case #85: 933 86 | Case #86: 233 87 | Case #87: 846 88 | Case #88: 716 89 | Case #89: 566 90 | Case #90: 656 91 | Case #91: 664 92 | Case #92: 453 93 | Case #93: 162 94 | Case #94: 26 95 | Case #95: 293 96 | Case #96: 275 97 | Case #97: 897 98 | Case #98: 54 99 | Case #99: 755 100 | Case #100: 82 101 | -------------------------------------------------------------------------------- /2014/Round D/Problem B/B-small-practice.in: -------------------------------------------------------------------------------- 1 | 6 2 | 10 3 | 37 83 14 57 27 33 21 48 18 63 45 61 26 69 47 67 22 37 4 14 4 | 5 5 | 3 6 | 15 7 | 30 8 | 97 9 | 98 10 | 11 | 25 12 | 39 93 46 92 107 218 74 189 35 110 94 167 75 119 16 140 41 80 68 143 122 124 84 97 94 113 81 153 119 177 26 66 69 106 50 69 73 144 109 118 22 79 20 98 12 73 17 30 62 78 13 | 25 14 | 128 15 | 11 16 | 127 17 | 102 18 | 24 19 | 245 20 | 101 21 | 142 22 | 27 23 | 180 24 | 158 25 | 247 26 | 170 27 | 120 28 | 26 29 | 221 30 | 74 31 | 94 32 | 125 33 | 174 34 | 149 35 | 74 36 | 86 37 | 201 38 | 79 39 | 40 | 50 41 | 1 500 500 500 21 67 112 216 152 180 93 291 67 293 58 268 176 273 71 319 73 169 10 18 187 244 24 266 8 156 239 327 6 189 71 270 61 71 135 269 233 291 50 286 140 182 237 302 69 291 109 258 45 169 19 195 12 252 200 222 228 454 136 239 43 185 47 253 88 239 207 317 63 200 242 488 2 66 94 188 60 138 193 245 139 333 60 69 237 275 178 315 181 429 230 346 33 237 241 290 42 | 50 43 | 4 44 | 387 45 | 267 46 | 86 47 | 245 48 | 194 49 | 303 50 | 97 51 | 433 52 | 164 53 | 309 54 | 131 55 | 443 56 | 428 57 | 483 58 | 378 59 | 84 60 | 166 61 | 81 62 | 441 63 | 106 64 | 182 65 | 412 66 | 167 67 | 192 68 | 192 69 | 160 70 | 31 71 | 113 72 | 211 73 | 67 74 | 493 75 | 385 76 | 260 77 | 57 78 | 270 79 | 495 80 | 326 81 | 197 82 | 424 83 | 42 84 | 480 85 | 458 86 | 306 87 | 231 88 | 160 89 | 60 90 | 323 91 | 435 92 | 475 93 | 94 | 15 95 | 29 29 34 34 111 111 10 49 75 151 132 312 116 162 121 294 191 247 72 113 116 141 68 169 99 117 110 200 152 156 96 | 8 97 | 29 98 | 31 99 | 287 100 | 163 101 | 183 102 | 135 103 | 269 104 | 111 105 | 106 | 20 107 | 138 192 188 296 191 281 241 340 182 356 232 378 63 83 113 241 39 43 89 221 181 356 231 378 149 275 199 337 60 110 110 255 172 221 222 310 45 153 95 276 108 | 15 109 | 187 110 | 170 111 | 44 112 | 108 113 | 89 114 | 189 115 | 242 116 | 233 117 | 114 118 | 90 119 | 232 120 | 200 121 | 111 122 | 223 123 | 96 124 | 125 | 15 126 | 165 222 78 165 4 124 49 98 79 88 32 173 23 92 198 368 59 100 195 230 54 248 24 177 19 76 52 121 59 85 127 | 8 128 | 165 129 | 95 130 | 213 131 | 245 132 | 238 133 | 46 134 | 248 135 | 371 136 | 137 | -------------------------------------------------------------------------------- /2015/Round E/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Lazy Spelling Bee: 2 | https://code.google.com/codejam/contest/8264486/dashboard#s=p0 3 | 4 | =============================== 5 | `Problem A. Lazy Spelling Bee`_ 6 | =============================== 7 | 8 | Problem 9 | ------- 10 | In the Lazy Spelling Bee, a contestant is given a target word W to spell. 11 | The contestant's answer word A is acceptable if it is the same length as the 12 | target word, and the i-th letter of A is either the i-th, (i-1)th, or (i+1)th 13 | letter of W, for all i in the range of the length of A. 14 | (The first letter of A must match either the first or second letter of W, 15 | since the 0th letter of W doesn't exist. Similarly, the last letter of A must 16 | match either the last or next-to-last letter of W.) 17 | Note that the target word itself is always an acceptable answer word. 18 | 19 | You are preparing a Lazy Spelling Bee, and you have been asked to determine, 20 | for each target word, how many distinct acceptable answer words there are. 21 | Since this number may be very large, please output it modulo 1000000007 22 | (|10^9| + 7). 23 | 24 | .. |10^9| replace:: 10\ :sup:`9` 25 | 26 | Input 27 | ----- 28 | The first line of the input gives the number of test cases, **T**. 29 | **T** test cases follow; each consists of one line with a string consisting 30 | only of lowercase English letters (``a`` through ``z``). 31 | 32 | Output 33 | ------ 34 | For each test case, output one line containing "Case #x: y", 35 | where x is the test case number (starting from 1) 36 | and y is the number of distinct acceptable answer words, modulo |10^9| + 7. 37 | 38 | Limits 39 | ------ 40 | 1 ≤ **T** ≤ 100. 41 | 42 | Small dataset 43 | ------------- 44 | 1 ≤ length of each string ≤ 5. 45 | 46 | Large dataset 47 | ------------- 48 | 1 ≤ length of each string ≤ 1000. 49 | 50 | Sample 51 | ------ 52 | 53 | :: 54 | 55 | Input Output 56 | 57 | 4 Case #1: 4 58 | ag Case #2: 1 59 | aa Case #3: 108 60 | abcde Case #4: 1 61 | x 62 | 63 | In sample case #1, the acceptable answer words are 64 | ``aa``, ``ag``, ``ga``, and ``gg``. 65 | 66 | In sample case #2, the only acceptable answer word is ``aa``. 67 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 463691 2 | Case #2: 144717 3 | Case #3: 0 4 | Case #4: 270499 5 | Case #5: 1000000 6 | Case #6: 287383 7 | Case #7: 395106 8 | Case #8: 465799 9 | Case #9: 372912 10 | Case #10: 529477 11 | Case #11: 496097 12 | Case #12: 94368 13 | Case #13: 497820 14 | Case #14: 822125 15 | Case #15: 598857 16 | Case #16: 345633 17 | Case #17: 233267 18 | Case #18: 644950 19 | Case #19: 0 20 | Case #20: 160589 21 | Case #21: 774110 22 | Case #22: 301567 23 | Case #23: 623194 24 | Case #24: 537077 25 | Case #25: 327122 26 | Case #26: 110788 27 | Case #27: 660294 28 | Case #28: 104171 29 | Case #29: 352947 30 | Case #30: 212374 31 | Case #31: 550000 32 | Case #32: 407534 33 | Case #33: 990485 34 | Case #34: 256158 35 | Case #35: 424185 36 | Case #36: 592056 37 | Case #37: 388022 38 | Case #38: 0 39 | Case #39: 147592 40 | Case #40: 462268 41 | Case #41: 850531 42 | Case #42: 855558 43 | Case #43: 484924 44 | Case #44: 271126 45 | Case #45: 442316 46 | Case #46: 427570 47 | Case #47: 542417 48 | Case #48: 588523 49 | Case #49: 587879 50 | Case #50: 791589 51 | Case #51: 391300 52 | Case #52: 854779 53 | Case #53: 374147 54 | Case #54: 0 55 | Case #55: 385659 56 | Case #56: 348616 57 | Case #57: 643328 58 | Case #58: 535695 59 | Case #59: 1000000 60 | Case #60: 667656 61 | Case #61: 440421 62 | Case #62: 599045 63 | Case #63: 989088 64 | Case #64: 685869 65 | Case #65: 727892 66 | Case #66: 176112 67 | Case #67: 593551 68 | Case #68: 40973 69 | Case #69: 366642 70 | Case #70: 326866 71 | Case #71: 841644 72 | Case #72: 984086 73 | Case #73: 501911 74 | Case #74: 593819 75 | Case #75: 364112 76 | Case #76: 873080 77 | Case #77: 637234 78 | Case #78: 629779 79 | Case #79: 905747 80 | Case #80: 788111 81 | Case #81: 438898 82 | Case #82: 865871 83 | Case #83: 165998 84 | Case #84: 692347 85 | Case #85: 0 86 | Case #86: 217390 87 | Case #87: 474672 88 | Case #88: 416459 89 | Case #89: 707223 90 | Case #90: 607738 91 | Case #91: 207329 92 | Case #92: 505480 93 | Case #93: 905353 94 | Case #94: 360000 95 | Case #95: 1 96 | Case #96: 0 97 | Case #97: 851629 98 | Case #98: 424366 99 | Case #99: 656014 100 | Case #100: 880070 101 | -------------------------------------------------------------------------------- /2014/Round A/Problem A/A-solution.py: -------------------------------------------------------------------------------- 1 | numbers = {0: [True, True, True, True, True, True, False], 2 | 1: [False, True, True, False, False, False, False], 3 | 2: [True, True, False, True, True, False, True], 4 | 3: [True, True, True, True, False, False, True], 5 | 4: [False, True, True, False, False, True, True], 6 | 5: [True, False, True, True, False, True, True], 7 | 6: [True, False, True, True, True, True, True], 8 | 7: [True, True, True, False, False, False, False], 9 | 8: [True, True, True, True, True, True, True], 10 | 9: [True, True, True, True, False, True, True]} 11 | 12 | T = int(input()) 13 | for x in range(1, T + 1): 14 | states = input().split() 15 | N = int(states.pop(0)) 16 | possible = {number: [None] * 7 for number in range(10)} 17 | for n, state in enumerate(states): 18 | for number, segments in possible.copy().items(): 19 | current_possible = (number - n) % 10 20 | for segment, value in enumerate(map(int, state)): 21 | if value: 22 | if (not numbers[current_possible][segment] 23 | or segments[segment] == False): 24 | del possible[number] 25 | break 26 | else: 27 | possible[number][segment] = True 28 | elif numbers[current_possible][segment]: 29 | if segments[segment]: 30 | del possible[number] 31 | break 32 | else: 33 | possible[number][segment] = False 34 | y = "" 35 | for number, segments in possible.items(): 36 | number = (number - N) % 10 37 | state = "" 38 | for segment in range(7): 39 | if numbers[number][segment] and segments[segment] is None: 40 | state = "ERROR!" 41 | break 42 | state += str(int(numbers[number][segment] and segments[segment])) 43 | if not y: 44 | y = state 45 | if state == "ERROR!" or y != state: 46 | y = "ERROR!" 47 | break 48 | if not y: 49 | y = "ERROR!" 50 | print(f"Case #{x}: {y}") 51 | -------------------------------------------------------------------------------- /2014/Round A/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0010011 2 | Case #2: 1110000 3 | Case #3: 0000100 4 | Case #4: 0011010 5 | Case #5: ERROR! 6 | Case #6: 1011011 7 | Case #7: ERROR! 8 | Case #8: 1101100 9 | Case #9: 1011001 10 | Case #10: 1001110 11 | Case #11: 1011011 12 | Case #12: ERROR! 13 | Case #13: 0110110 14 | Case #14: ERROR! 15 | Case #15: 1010111 16 | Case #16: ERROR! 17 | Case #17: 1101011 18 | Case #18: ERROR! 19 | Case #19: 0011111 20 | Case #20: ERROR! 21 | Case #21: 1101000 22 | Case #22: ERROR! 23 | Case #23: 1110000 24 | Case #24: ERROR! 25 | Case #25: 1011101 26 | Case #26: 1011101 27 | Case #27: ERROR! 28 | Case #28: 1010000 29 | Case #29: 0010000 30 | Case #30: 1110110 31 | Case #31: ERROR! 32 | Case #32: 1011010 33 | Case #33: ERROR! 34 | Case #34: 0100101 35 | Case #35: ERROR! 36 | Case #36: ERROR! 37 | Case #37: 1011110 38 | Case #38: 1111100 39 | Case #39: ERROR! 40 | Case #40: 0110000 41 | Case #41: ERROR! 42 | Case #42: ERROR! 43 | Case #43: 0110000 44 | Case #44: ERROR! 45 | Case #45: ERROR! 46 | Case #46: ERROR! 47 | Case #47: 0110000 48 | Case #48: ERROR! 49 | Case #49: 1101000 50 | Case #50: ERROR! 51 | Case #51: 1011111 52 | Case #52: 1100000 53 | Case #53: ERROR! 54 | Case #54: ERROR! 55 | Case #55: ERROR! 56 | Case #56: 0101001 57 | Case #57: 1111101 58 | Case #58: ERROR! 59 | Case #59: 0111111 60 | Case #60: ERROR! 61 | Case #61: 1101100 62 | Case #62: 0111110 63 | Case #63: 0010011 64 | Case #64: 1101001 65 | Case #65: 1101110 66 | Case #66: ERROR! 67 | Case #67: ERROR! 68 | Case #68: 0011011 69 | Case #69: ERROR! 70 | Case #70: ERROR! 71 | Case #71: 0100000 72 | Case #72: ERROR! 73 | Case #73: ERROR! 74 | Case #74: ERROR! 75 | Case #75: ERROR! 76 | Case #76: 1010101 77 | Case #77: ERROR! 78 | Case #78: 0111011 79 | Case #79: 1011000 80 | Case #80: 1111001 81 | Case #81: ERROR! 82 | Case #82: 1011001 83 | Case #83: ERROR! 84 | Case #84: 1011001 85 | Case #85: 0000000 86 | Case #86: 1011001 87 | Case #87: 0010011 88 | Case #88: 1001011 89 | Case #89: 0100000 90 | Case #90: 0010011 91 | Case #91: 0110000 92 | Case #92: 1110000 93 | Case #93: 1011010 94 | Case #94: ERROR! 95 | Case #95: 1011001 96 | Case #96: ERROR! 97 | Case #97: ERROR! 98 | Case #98: ERROR! 99 | Case #99: ERROR! 100 | Case #100: 0110000 101 | -------------------------------------------------------------------------------- /2014/Round A/Problem D/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem D. Cut Tiles: 2 | https://code.google.com/codejam/contest/3214486/dashboard#s=p3 3 | 4 | ======================= 5 | `Problem D. Cut Tiles`_ 6 | ======================= 7 | 8 | Problem 9 | ------- 10 | Enzo is doing renovation for his new house. 11 | The most difficult part is to buy exactly the right number of tiles. 12 | He wants **N** tiles of different sizes. 13 | Of course they have to be cut from the tiles he bought. 14 | All the required tiles are square. 15 | The lengths of side of the tiles are |2S1|, |2S2|, ..., |2SN|. 16 | He can only buy a lot of tiles sized **M**\*\ **M**, 17 | and he decides to only cut tiles parallel to their sides for convenience. 18 | How many tiles does he need to buy? 19 | 20 | .. |2S1| raw:: html 21 | 22 | 2S1 23 | 24 | .. |2S2| raw:: html 25 | 26 | 2S2 27 | 28 | .. |2SN| raw:: html 29 | 30 | 2SN 31 | 32 | Input 33 | ----- 34 | The first line of the input gives the number of test cases: **T**. 35 | **T** lines follow. 36 | Each line start with the number **N** and **M**, indicating 37 | the number of required tiles and the size of the big tiles Enzo can buy. 38 | **N** numbers follow: 39 | |S1|, |S2|, ... |SN|, showing the sizes of the required tiles. 40 | 41 | .. |S1| raw:: html 42 | 43 | S1 44 | 45 | .. |S2| raw:: html 46 | 47 | S2 48 | 49 | .. |SN| raw:: html 50 | 51 | SN 52 | 53 | Output 54 | ------ 55 | For each test case, output one line containing "Case #x: y", 56 | where x is the test case number (starting from 1) 57 | and y is the number of the big tiles Enzo need [sic] to buy. 58 | 59 | Limits 60 | ------ 61 | 1 ≤ |2Sk| ≤ **M** ≤ 2^31-1. 62 | 63 | .. |2Sk| raw:: html 64 | 65 | 2Sk 66 | 67 | Small dataset 68 | ------------- 69 | | 1 ≤ **T** ≤ 100. 70 | | 1 ≤ **N** ≤ 20. 71 | 72 | Large dataset 73 | ------------- 74 | | 1 ≤ **T** ≤ 1000. 75 | | 1 ≤ **N** ≤ 500. 76 | 77 | Sample 78 | ------ 79 | 80 | :: 81 | 82 | Input Output 83 | 84 | 4 Case #1: 1 85 | 1 6 2 Case #2: 2 86 | 2 6 2 2 Case #3: 1 87 | 3 6 2 1 1 Case #4: 2 88 | 7 277 3 8 2 6 1 3 6 89 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 666106750 2 | Case #2: 240561145 3 | Case #3: 4332096 4 | Case #4: 183984153 5 | Case #5: 195179403 6 | Case #6: 163878 7 | Case #7: 1250025000 8 | Case #8: 706259736 9 | Case #9: 89826906 10 | Case #10: 130839576 11 | Case #11: 210 12 | Case #12: 39245370 13 | Case #13: 1556730 14 | Case #14: 150606690 15 | Case #15: 128232105 16 | Case #16: 0 17 | Case #17: 16128360 18 | Case #18: 601715395 19 | Case #19: 143422516 20 | Case #20: 247053106 21 | Case #21: 188675025 22 | Case #22: 5057790 23 | Case #23: 173510506 24 | Case #24: 19110 25 | Case #25: 28 26 | Case #26: 632879253 27 | Case #27: 448516225 28 | Case #28: 37208251 29 | Case #29: 45034795 30 | Case #30: 195000 31 | Case #31: 29641150 32 | Case #32: 1 33 | Case #33: 128120028 34 | Case #34: 2659971 35 | Case #35: 12140128 36 | Case #36: 189238785 37 | Case #37: 163470321 38 | Case #38: 172821936 39 | Case #39: 89131276 40 | Case #40: 4825171 41 | Case #41: 49775253 42 | Case #42: 122954721 43 | Case #43: 570932736 44 | Case #44: 816423436 45 | Case #45: 78 46 | Case #46: 278798691 47 | Case #47: 20412855 48 | Case #48: 174929160 49 | Case #49: 289117081 50 | Case #50: 2731953 51 | Case #51: 1375311 52 | Case #52: 45 53 | Case #53: 28891401 54 | Case #54: 658536486 55 | Case #55: 1052097256 56 | Case #56: 52975 57 | Case #57: 40847241 58 | Case #58: 0 59 | Case #59: 19766328 60 | Case #60: 103701601 61 | Case #61: 19590670 62 | Case #62: 502207278 63 | Case #63: 2102275 64 | Case #64: 104466285 65 | Case #65: 215873031 66 | Case #66: 1723296 67 | Case #67: 256160295 68 | Case #68: 297033751 69 | Case #69: 337077630 70 | Case #70: 30035125 71 | Case #71: 84337578 72 | Case #72: 285234670 73 | Case #73: 1602945 74 | Case #74: 4444671 75 | Case #75: 976665306 76 | Case #76: 7875 77 | Case #77: 12557566 78 | Case #78: 522145770 79 | Case #79: 222111 80 | Case #80: 413985925 81 | Case #81: 32671486 82 | Case #82: 586890930 83 | Case #83: 136149751 84 | Case #84: 227708470 85 | Case #85: 203686836 86 | Case #86: 0 87 | Case #87: 0 88 | Case #88: 43445181 89 | Case #89: 21528 90 | Case #90: 180300555 91 | Case #91: 24566545 92 | Case #92: 0 93 | Case #93: 0 94 | Case #94: 29772186 95 | Case #95: 75786516 96 | Case #96: 6352830 97 | Case #97: 287004861 98 | Case #98: 298229253 99 | Case #99: 888627403 100 | Case #100: 539709085 101 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/B-large-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 14919921443713777 3 | 16035713712910627 4 | 470988884881403701 5 | 663208457429249320 6 | 35417244247309081 7 | 18912140357306197 8 | 821424692950225218 9 | 194148123592167400 10 | 169683965173070355 11 | 30896151154490161 12 | 8152332946963171 13 | 26504196177401065 14 | 727004545306745403 15 | 1000000000000000000 16 | 210724372007205925 17 | 230839591399678411 18 | 139782788180007861 19 | 31108559476176585 20 | 70640308161049884 21 | 919818571896748567 22 | 805068181058041870 23 | 528077080918778560 24 | 3392264354546656 25 | 172589956609631527 26 | 752116768933572174 27 | 278385972618095971 28 | 500364605967785712 29 | 936501597464173890 30 | 5346848976102943 31 | 42711799474754936 32 | 39739406344976521 33 | 96642126154887385 34 | 507373618559718949 35 | 148522861921131118 36 | 5990709545080807 37 | 58873926717610501 38 | 779668738937986840 39 | 34824506845925071 40 | 131226544799105148 41 | 14500751095055161 42 | 541064907662839644 43 | 665930169964312773 44 | 2854907964745564 45 | 151970818238211610 46 | 916365355264637559 47 | 353896329635329936 48 | 625318600331879360 49 | 690683275350237133 50 | 31899883679471306 51 | 99670604181093725 52 | 736827088955709913 53 | 113836064401097977 54 | 8508110325218143 55 | 13321050162245608 56 | 609649911611389831 57 | 46268622795238201 58 | 468339557884957084 59 | 25965247599543841 60 | 381252133354068211 61 | 494196153725539231 62 | 945648548682242665 63 | 19337682799995045 64 | 619861907468053901 65 | 229239004074282805 66 | 386581418747680 67 | 610260633162639678 68 | 299694296458966143 69 | 845078653019833051 70 | 373345485670171062 71 | 27233228344819564 72 | 129023667184858285 73 | 83124300916686757 74 | 379255974823102021 75 | 245249591795535097 76 | 43969534069696 77 | 66722517469920 78 | 9858438270839893 79 | 6910943299863520 80 | 25717131834499624 81 | 92023103018361641 82 | 943990493461794871 83 | 513767149194597040 84 | 112064524403878803 85 | 174210760090244515 86 | 5811353213141560 87 | 85718519097865885 88 | 984245729893369243 89 | 516227865362638410 90 | 106954294285992115 91 | 58860842632125700 92 | 446401559469368954 93 | 900075818947323940 94 | 813918209914834753 95 | 803117911029730313 96 | 130463899351376137 97 | 6980452392892987 98 | 66613711011280280 99 | 311119354403376793 100 | 114349900145584129 101 | 182859777940000980 102 | -------------------------------------------------------------------------------- /2015/Round E/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 370377619 2 | Case #2: 322287252 3 | Case #3: 557483120 4 | Case #4: 1 5 | Case #5: 273654609 6 | Case #6: 898187660 7 | Case #7: 253874103 8 | Case #8: 980164637 9 | Case #9: 52713686 10 | Case #10: 141077196 11 | Case #11: 8788418 12 | Case #12: 1 13 | Case #13: 485857656 14 | Case #14: 879029786 15 | Case #15: 838434410 16 | Case #16: 945735149 17 | Case #17: 470923213 18 | Case #18: 827386192 19 | Case #19: 339738034 20 | Case #20: 416272910 21 | Case #21: 354589437 22 | Case #22: 130485071 23 | Case #23: 6850263 24 | Case #24: 195354665 25 | Case #25: 144 26 | Case #26: 762993493 27 | Case #27: 1 28 | Case #28: 165330823 29 | Case #29: 744208692 30 | Case #30: 11664 31 | Case #31: 854393974 32 | Case #32: 839788301 33 | Case #33: 428955916 34 | Case #34: 367558909 35 | Case #35: 232626062 36 | Case #36: 178069043 37 | Case #37: 1 38 | Case #38: 285668460 39 | Case #39: 4 40 | Case #40: 54714192 41 | Case #41: 320611319 42 | Case #42: 774338514 43 | Case #43: 246511504 44 | Case #44: 144813590 45 | Case #45: 972 46 | Case #46: 971142348 47 | Case #47: 847620757 48 | Case #48: 725983021 49 | Case #49: 919876233 50 | Case #50: 322050759 51 | Case #51: 791583447 52 | Case #52: 120130062 53 | Case #53: 813398361 54 | Case #54: 338947741 55 | Case #55: 552588676 56 | Case #56: 475782081 57 | Case #57: 20499162 58 | Case #58: 434345829 59 | Case #59: 631282147 60 | Case #60: 606211594 61 | Case #61: 115731109 62 | Case #62: 1 63 | Case #63: 1 64 | Case #64: 480270930 65 | Case #65: 190830242 66 | Case #66: 223385569 67 | Case #67: 816064939 68 | Case #68: 48 69 | Case #69: 30724517 70 | Case #70: 832318538 71 | Case #71: 415181916 72 | Case #72: 584277406 73 | Case #73: 868525651 74 | Case #74: 907458014 75 | Case #75: 4 76 | Case #76: 435890236 77 | Case #77: 733922348 78 | Case #78: 115672944 79 | Case #79: 907123972 80 | Case #80: 1 81 | Case #81: 22565960 82 | Case #82: 464935572 83 | Case #83: 940156453 84 | Case #84: 5832 85 | Case #85: 318900666 86 | Case #86: 78565043 87 | Case #87: 491601840 88 | Case #88: 428607076 89 | Case #89: 572431827 90 | Case #90: 1296 91 | Case #91: 277451383 92 | Case #92: 432 93 | Case #93: 298576704 94 | Case #94: 436179085 95 | Case #95: 941280267 96 | Case #96: 151518740 97 | Case #97: 4 98 | Case #98: 222711619 99 | Case #99: 1 100 | Case #100: 961261653 101 | -------------------------------------------------------------------------------- /2016/Round E/Problem B/B-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 496 2 | Case #2: 502 3 | Case #3: 686286299 4 | Case #4: 872067 5 | Case #5: 117 6 | Case #6: 516 7 | Case #7: 821424692950225217 8 | Case #8: 579043 9 | Case #9: 553622 10 | Case #10: 560 11 | Case #11: 90290270 12 | Case #12: 298152 13 | Case #13: 727004545306745402 14 | Case #14: 999999999999999999 15 | Case #15: 84 16 | Case #16: 480457689 17 | Case #17: 373875364 18 | Case #18: 314504 19 | Case #19: 413381 20 | Case #20: 986 21 | Case #21: 805068181058041869 22 | Case #22: 808287 23 | Case #23: 150255 24 | Case #24: 746 25 | Case #25: 752116768933572173 26 | Case #26: 527622945 27 | Case #27: 500364605967785711 28 | Case #28: 936501597464173889 29 | Case #29: 418 30 | Case #30: 42711799474754935 31 | Case #31: 584 32 | Case #32: 458904 33 | Case #33: 507373618559718948 34 | Case #34: 148522861921131117 35 | Case #35: 426 36 | Case #36: 242639499 37 | Case #37: 779668738937986839 38 | Case #38: 45 39 | Case #39: 131226544799105147 40 | Case #40: 120419064 41 | Case #41: 541064907662839643 42 | Case #42: 665930169964312772 43 | Case #43: 141861 44 | Case #44: 81 45 | Case #45: 971306 46 | Case #46: 707335 47 | Case #47: 625318600331879359 48 | Case #48: 690683275350237132 49 | Case #49: 31899883679471305 50 | Case #50: 268 51 | Case #51: 858386328 52 | Case #52: 696 53 | Case #53: 92239418 54 | Case #54: 201 55 | Case #55: 847930 56 | Case #56: 599 57 | Case #57: 776581 58 | Case #58: 544 59 | Case #59: 725110 60 | Case #60: 889 61 | Case #61: 981544 62 | Case #62: 212 63 | Case #63: 619861907468053900 64 | Case #64: 21881 65 | Case #65: 72847 66 | Case #66: 610260633162639677 67 | Case #67: 547443418 68 | Case #68: 174 69 | Case #69: 373345485670171061 70 | Case #70: 300861 71 | Case #71: 505308 72 | Case #72: 288312852 73 | Case #73: 615837620 74 | Case #74: 791 75 | Case #75: 35295 76 | Case #76: 40559 77 | Case #77: 99289668 78 | Case #78: 183 79 | Case #79: 295171 80 | Case #80: 92023103018361640 81 | Case #81: 980970 82 | Case #82: 800919 83 | Case #83: 334760398 84 | Case #84: 558502 85 | Case #85: 179787 86 | Case #86: 76 87 | Case #87: 992091593 88 | Case #88: 516227865362638409 89 | Case #89: 474678 90 | Case #90: 388993 91 | Case #91: 446401559469368953 92 | Case #92: 900075818947323939 93 | Case #93: 31 94 | Case #94: 803117911029730312 95 | Case #95: 712 96 | Case #96: 437 97 | Case #97: 253 98 | Case #98: 823 99 | Case #99: 485376 100 | Case #100: 37 101 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 200530450 2 | Case #2: 205847540 3 | Case #3: 238891991 4 | Case #4: 476253232 5 | Case #5: 78833962 6 | Case #6: 577117268 7 | Case #7: 847661150 8 | Case #8: 758643232 9 | Case #9: 324133993 10 | Case #10: 8903332 11 | Case #11: 686315717 12 | Case #12: 335509060 13 | Case #13: 198746240 14 | Case #14: 447513699 15 | Case #15: 5858580 16 | Case #16: 27816610 17 | Case #17: 201062327 18 | Case #18: 225333480 19 | Case #19: 197906781 20 | Case #20: 27786030 21 | Case #21: 815465989 22 | Case #22: 919400445 23 | Case #23: 2145710 24 | Case #24: 45793040 25 | Case #25: 329597575 26 | Case #26: 895356 27 | Case #27: 585865760 28 | Case #28: 49786030 29 | Case #29: 954127449 30 | Case #30: 817232083 31 | Case #31: 719026 32 | Case #32: 29671950 33 | Case #33: 139243888 34 | Case #34: 713549250 35 | Case #35: 133112518 36 | Case #36: 199027911 37 | Case #37: 220253098 38 | Case #38: 223639957 39 | Case #39: 630278740 40 | Case #40: 617709252 41 | Case #41: 98462 42 | Case #42: 304632588 43 | Case #43: 379771630 44 | Case #44: 491972608 45 | Case #45: 213281262 46 | Case #46: 1234408 47 | Case #47: 437610380 48 | Case #48: 501150650 49 | Case #49: 538390750 50 | Case #50: 4801020 51 | Case #51: 133702369 52 | Case #52: 21679140 53 | Case #53: 553469730 54 | Case #54: 74795781 55 | Case #55: 247118474 56 | Case #56: 734351530 57 | Case #57: 578982626 58 | Case #58: 16410495 59 | Case #59: 107797631 60 | Case #60: 159915019 61 | Case #61: 811496937 62 | Case #62: 692144293 63 | Case #63: 103999505 64 | Case #64: 302971200 65 | Case #65: 206670298 66 | Case #66: 277234556 67 | Case #67: 17985729 68 | Case #68: 603107359 69 | Case #69: 86530319 70 | Case #70: 3834670 71 | Case #71: 962070848 72 | Case #72: 2700348 73 | Case #73: 3357900 74 | Case #74: 2342949 75 | Case #75: 7728672 76 | Case #76: 165509188 77 | Case #77: 322728 78 | Case #78: 429375543 79 | Case #79: 803744958 80 | Case #80: 139554376 81 | Case #81: 731950750 82 | Case #82: 782887304 83 | Case #83: 708294437 84 | Case #84: 908610560 85 | Case #85: 607937046 86 | Case #86: 248725899 87 | Case #87: 420263123 88 | Case #88: 212763320 89 | Case #89: 159825011 90 | Case #90: 46816980 91 | Case #91: 201655798 92 | Case #92: 330891423 93 | Case #93: 827260 94 | Case #94: 194843819 95 | Case #95: 285069600 96 | Case #96: 3656436 97 | Case #97: 624358232 98 | Case #98: 332592319 99 | Case #99: 483389156 100 | Case #100: 214548663 101 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 104051143 2 | Case #2: 335170187 3 | Case #3: 578765808 4 | Case #4: 168909961 5 | Case #5: 122361780 6 | Case #6: 463541885 7 | Case #7: 547040780 8 | Case #8: 773457288 9 | Case #9: 619130412 10 | Case #10: 528928646 11 | Case #11: 702604897 12 | Case #12: 650094779 13 | Case #13: 469962275 14 | Case #14: 751276666 15 | Case #15: 610774125 16 | Case #16: 347202686 17 | Case #17: 284825496 18 | Case #18: 997213608 19 | Case #19: 332088995 20 | Case #20: 846304062 21 | Case #21: 614477728 22 | Case #22: 591377503 23 | Case #23: 130070298 24 | Case #24: 770329930 25 | Case #25: 298982629 26 | Case #26: 387804968 27 | Case #27: 489361320 28 | Case #28: 783846394 29 | Case #29: 541027289 30 | Case #30: 781469820 31 | Case #31: 524244925 32 | Case #32: 939113095 33 | Case #33: 163531966 34 | Case #34: 612236185 35 | Case #35: 785789014 36 | Case #36: 344022947 37 | Case #37: 733742726 38 | Case #38: 205227972 39 | Case #39: 600400027 40 | Case #40: 536764182 41 | Case #41: 348646763 42 | Case #42: 34586908 43 | Case #43: 823565211 44 | Case #44: 486884245 45 | Case #45: 68366337 46 | Case #46: 167303767 47 | Case #47: 167199882 48 | Case #48: 792216226 49 | Case #49: 148381217 50 | Case #50: 299745825 51 | Case #51: 698756732 52 | Case #52: 778019601 53 | Case #53: 385981258 54 | Case #54: 365208252 55 | Case #55: 464695081 56 | Case #56: 426730819 57 | Case #57: 280277216 58 | Case #58: 884974836 59 | Case #59: 219848034 60 | Case #60: 207603415 61 | Case #61: 661404679 62 | Case #62: 810557421 63 | Case #63: 912455497 64 | Case #64: 490942412 65 | Case #65: 767821947 66 | Case #66: 675575376 67 | Case #67: 577037870 68 | Case #68: 42018248 69 | Case #69: 931211204 70 | Case #70: 180307339 71 | Case #71: 57812951 72 | Case #72: 884801216 73 | Case #73: 220376948 74 | Case #74: 790918801 75 | Case #75: 106941890 76 | Case #76: 715789802 77 | Case #77: 69388523 78 | Case #78: 189268617 79 | Case #79: 824471620 80 | Case #80: 473801372 81 | Case #81: 333424356 82 | Case #82: 203392103 83 | Case #83: 331883563 84 | Case #84: 351738665 85 | Case #85: 615285591 86 | Case #86: 954570332 87 | Case #87: 955077621 88 | Case #88: 783905714 89 | Case #89: 842478950 90 | Case #90: 397562482 91 | Case #91: 425740054 92 | Case #92: 169642057 93 | Case #93: 777633802 94 | Case #94: 305698020 95 | Case #95: 774554198 96 | Case #96: 603151683 97 | Case #97: 152449356 98 | Case #98: 460480349 99 | Case #99: 738615546 100 | Case #100: 189610139 101 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/A-large-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 991312703 818140587 3 | 656786231 764155324 4 | 298121190 772533305 5 | 338352336 343915834 6 | 372539766 986283416 7 | 869774534 705378771 8 | 365196576 397839622 9 | 553857424 933128642 10 | 296259683 827836028 11 | 649866812 441620933 12 | 925970067 829167436 13 | 981359391 758229323 14 | 955459627 191525521 15 | 736608943 562100546 16 | 124400869 793100455 17 | 146689213 787834371 18 | 923803357 383707651 19 | 560695512 223184460 20 | 384304036 597242100 21 | 693556985 484735440 22 | 676456222 870041436 23 | 654340796 498927476 24 | 117693537 585283772 25 | 177501660 426257545 26 | 825809538 375693526 27 | 939754454 107384114 28 | 636780643 264710678 29 | 949818674 154519302 30 | 393953038 827015769 31 | 565447233 373259809 32 | 470304555 110967334 33 | 181260783 303313195 34 | 968139305 179201278 35 | 931477644 710550713 36 | 460487127 212532125 37 | 558481540 815096301 38 | 503372836 424749733 39 | 983356968 995028624 40 | 880279209 245040288 41 | 892043624 765261162 42 | 103305033 342955066 43 | 303342572 328962488 44 | 217501695 926013111 45 | 925300845 639203640 46 | 434328663 239284672 47 | 135435589 173874723 48 | 769110160 627462602 49 | 232239867 895712902 50 | 947730429 701048274 51 | 155192472 199519751 52 | 904026350 357807482 53 | 454117729 155953475 54 | 826787127 241998514 55 | 330876887 532803538 56 | 633067914 573637896 57 | 572424979 290048520 58 | 476630896 469063013 59 | 591290838 570983208 60 | 915803610 406369231 61 | 772718624 862141836 62 | 922507606 934411764 63 | 345359159 643604325 64 | 749270720 925318420 65 | 955749873 207255144 66 | 248182454 387898641 67 | 908703757 328780216 68 | 386400172 718586211 69 | 799866567 833072313 70 | 935164808 460698811 71 | 118135160 963504178 72 | 885009209 873041523 73 | 147412202 181806848 74 | 127789897 396180865 75 | 147407650 173234200 76 | 148681322 288336478 77 | 741534080 807257731 78 | 458471845 106373940 79 | 995031797 284747981 80 | 997617722 427226738 81 | 765015496 578587258 82 | 534482414 819592512 83 | 945545701 469525057 84 | 546177871 741996851 85 | 291209153 656458159 86 | 636446406 935245217 87 | 997807199 756644805 88 | 909230633 292510078 89 | 990577220 192547786 90 | 627443968 373227248 91 | 560685113 167896289 92 | 789189405 900244041 93 | 880445254 787305221 94 | 665687849 109618865 95 | 652217152 910505576 96 | 215444912 771616560 97 | 225097821 143032206 98 | 570329233 950848820 99 | 390404099 751617997 100 | 909117378 336154541 101 | 606124015 987249903 102 | -------------------------------------------------------------------------------- /2017/Round A/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Square Counting: 2 | https://code.google.com/codejam/contest/8284486/dashboard#s=p0 3 | 4 | ============================= 5 | `Problem A. Square Counting`_ 6 | ============================= 7 | 8 | Problem 9 | ------- 10 | Mr. Panda has recently fallen in love with a new game called Square Off, 11 | in which players compete to find as many different squares as possible on an 12 | evenly spaced rectangular grid of dots. To find a square, a player must 13 | identify four dots that form the vertices of a square. Each side of the square 14 | must have the same length, of course, but it does not matter what that length 15 | is, and the square does not necessarily need to be aligned with the axes of 16 | the grid. The player earns one point for every different square found in this 17 | way. Two squares are different if and only if their sets of four dots are 18 | different. 19 | 20 | Mr. Panda has just been given a grid with **R** rows and **C** columns of 21 | dots. How many different squares can he find in this grid? 22 | Since the number might be very large, please output the answer modulo 23 | |10^9| + 7 (1000000007). 24 | 25 | .. |10^9| replace:: 10\ :sup:`9` 26 | 27 | Input 28 | ----- 29 | The first line of the input gives the number of test cases, **T**. 30 | **T** lines follow. Each line has two integers **R** and **C**: 31 | the number of dots in each row and column of the grid, respectively. 32 | 33 | Output 34 | ------ 35 | For each test case, output one line containing ``Case #x: y``, 36 | where ``x`` is the test case number (starting from 1) 37 | and ``y`` is the number of different squares can be found in the grid. 38 | 39 | Limits 40 | ------ 41 | 1 ≤ **T** ≤ 100. 42 | 43 | Small dataset 44 | ------------- 45 | | 2 ≤ **R** ≤ 1000. 46 | | 2 ≤ **C** ≤ 1000. 47 | 48 | Large dataset 49 | ------------- 50 | | 2 ≤ **R** ≤ |10^9|. 51 | | 2 ≤ **C** ≤ |10^9|. 52 | 53 | Sample 54 | ------ 55 | 56 | :: 57 | 58 | Input Output 59 | 60 | 4 Case #1: 3 61 | 2 4 Case #2: 10 62 | 3 4 Case #3: 20 63 | 4 4 Case #4: 624937395 64 | 1000 500 65 | 66 | The pictures below illustrate the grids from the three sample cases 67 | and a valid square in the third sample case. 68 | 69 | .. image:: https://code.google.com/codejam/contest/images/?image=sample1.png&p=5680283126857728&c=8284486 70 | 71 | .. image:: https://code.google.com/codejam/contest/images/?image=sample2.png&p=5680283126857728&c=8284486 72 | 73 | .. image:: https://code.google.com/codejam/contest/images/?image=sample3.png&p=5680283126857728&c=8284486 74 | -------------------------------------------------------------------------------- /2016/Round A/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Country Leader: 2 | https://code.google.com/codejam/contest/11274486/dashboard#s=p0 3 | 4 | ============================ 5 | `Problem A. Country Leader`_ 6 | ============================ 7 | 8 | Problem 9 | ------- 10 | The Constitution of a certain country states that the leader is the person 11 | with the name containing the greatest number of different alphabet letters. 12 | (The country uses the uppercase English alphabet from A through Z.) 13 | For example, the name ``GOOGLE`` has four different alphabet letters: 14 | E, G, L, and O. The name ``APAC CODE JAM`` has eight different letters. 15 | If the country only consists of these 2 persons, ``APAC CODE JAM`` would be 16 | the leader. 17 | 18 | If there is a tie, the person whose name comes earliest in alphabetical order 19 | is the leader. 20 | 21 | Given a list of names of the citizens of the country, can you determine who 22 | the leader is? 23 | 24 | Input 25 | ----- 26 | The first line of the input gives the number of test cases, **T**. 27 | **T** test cases follow. Each test case starts with a line with an 28 | interger [sic] **N**, the number of people in the country. 29 | Then **N** lines follow. The i-th line represents the name of the i-th person. 30 | Each name contains at most 20 characters and contains at least one alphabet 31 | letter. 32 | 33 | Output 34 | ------ 35 | For each test case, output one line containing ``Case #x: y``, where ``x`` is 36 | the test case number (starting from 1) and y is the name of the leader. 37 | 38 | Limits 39 | ------ 40 | | 1 ≤ **T** ≤ 100. 41 | | 1 ≤ **N** ≤ 100. 42 | 43 | Small dataset 44 | ------------- 45 | Each name consists of at most 20 characters and only consists of the uppercase 46 | English letters ``A`` through ``Z``. 47 | 48 | Large dataset 49 | ------------- 50 | | Each name consists of at most 20 characters and only consists of the uppercase English letters ``A`` through ``Z`` and ' '(space). 51 | | All names start and end with alphabet letters. 52 | 53 | Sample 54 | ------ 55 | 56 | :: 57 | 58 | Input Output 59 | 60 | 2 Case #1: JOHNSON 61 | 3 Case #2: A AB C 62 | ADAM 63 | BOB 64 | JOHNSON 65 | 2 66 | A AB C 67 | DEF 68 | 69 | In sample case #1, ``JOHNSON`` contains 5 different 70 | alphabet letters('H', 'J', 'N', 'O', 'S'), so he is the leader. 71 | 72 | Sample case #2 would only appear in Large data set. 73 | The name ``DEF`` contains 3 different alphabet letters, 74 | the name ``A AB C`` also contains 3 different alphabet letters. 75 | ``A AB C`` comes alphabetically earlier so he is the leader. 76 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-large-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 5 2 | Case #2: 16 3 | Case #3: 0 4 | Case #4: 1073414144 5 | Case #5: 261240814218696 6 | Case #6: 1125899906159220 7 | Case #7: 0 8 | Case #8: 307863255777280 9 | Case #9: 1125899906787761 10 | Case #10: 1125899906826240 11 | Case #11: 0 12 | Case #12: 0 13 | Case #13: 0 14 | Case #14: 1125891316678656 15 | Case #15: 1125899906787811 16 | Case #16: 1125899903687754 17 | Case #17: 1125899902035971 18 | Case #18: 0 19 | Case #19: 1125899369971712 20 | Case #20: 70368744046592 21 | Case #21: 0 22 | Case #22: 1125899906842623 23 | Case #23: 0 24 | Case #24: 281200098803712 25 | Case #25: 0 26 | Case #26: 1125899636000354 27 | Case #27: 0 28 | Case #28: 0 29 | Case #29: 140737488355328 30 | Case #30: 0 31 | Case #31: 0 32 | Case #32: 0 33 | Case #33: 562949953421312 34 | Case #34: 1125899906651560 35 | Case #35: 1125899906828174 36 | Case #36: 0 37 | Case #37: 0 38 | Case #38: 281474975662080 39 | Case #39: 1125882726973440 40 | Case #40: 1125899906841600 41 | Case #41: 35115619057664 42 | Case #42: 1 43 | Case #43: 0 44 | Case #44: 1125899873288192 45 | Case #45: 562949953069312 46 | Case #46: 562949953328128 47 | Case #47: 1125899873288192 48 | Case #48: 1125899904209472 49 | Case #49: 0 50 | Case #50: 0 51 | Case #51: 914793674309632 52 | Case #52: 1125762467889152 53 | Case #53: 1125899906208198 54 | Case #54: 206634315936639 55 | Case #55: 426969824964139 56 | Case #56: 1125899902386192 57 | Case #57: 0 58 | Case #58: 1121501860331520 59 | Case #59: 1125899904745472 60 | Case #60: 0 61 | Case #61: 1124800395214848 62 | Case #62: 0 63 | Case #63: 1125899906788172 64 | Case #64: 1125899906777088 65 | Case #65: 140668768878336 66 | Case #66: 1125899369844736 67 | Case #67: 1125899873235840 68 | Case #68: 1125899906841600 69 | Case #69: 562949953421312 70 | Case #70: 844424930131968 71 | Case #71: 1125899906842560 72 | Case #72: 0 73 | Case #73: 0 74 | Case #74: 0 75 | Case #75: 0 76 | Case #76: 1125899906834433 77 | Case #77: 0 78 | Case #78: 1125899906270945 79 | Case #79: 0 80 | Case #80: 1125899906685663 81 | Case #81: 1125899906842622 82 | Case #82: 1125899902386180 83 | Case #83: 1125898833100800 84 | Case #84: 1125899873246673 85 | Case #85: 1125899906838528 86 | Case #86: 0 87 | Case #87: 0 88 | Case #88: 1125899906800768 89 | Case #89: 280341105344512 90 | Case #90: 1125899906842368 91 | Case #91: 1125899906834436 92 | Case #92: 131801104104765 93 | Case #93: 0 94 | Case #94: 0 95 | Case #95: 1125899906746299 96 | Case #96: 0 97 | Case #97: 0 98 | Case #98: 1125899889782043 99 | Case #99: 1125899872608928 100 | Case #100: 0 101 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 5 2 | Case #2: 16 3 | Case #3: 0 4 | Case #4: 1073414144 5 | Case #5: 1125899369711616 6 | Case #6: 1125899369971712 7 | Case #7: 0 8 | Case #8: 844424929878016 9 | Case #9: 0 10 | Case #10: 0 11 | Case #11: 255219841630208 12 | Case #12: 1125899890065408 13 | Case #13: 1125899839471620 14 | Case #14: 1125899890065408 15 | Case #15: 0 16 | Case #16: 0 17 | Case #17: 407840560618416 18 | Case #18: 562949953421312 19 | Case #19: 1125899906519397 20 | Case #20: 1125899906101503 21 | Case #21: 1125899638177792 22 | Case #22: 0 23 | Case #23: 0 24 | Case #24: 1125899906525649 25 | Case #25: 1125762467889152 26 | Case #26: 1125899906514600 27 | Case #27: 0 28 | Case #28: 1125899369971712 29 | Case #29: 1 30 | Case #30: 1125899905658294 31 | Case #31: 123110643990528 32 | Case #32: 0 33 | Case #33: 0 34 | Case #34: 1125865546842120 35 | Case #35: 0 36 | Case #36: 190874315120216 37 | Case #37: 0 38 | Case #38: 166842292227253 39 | Case #39: 0 40 | Case #40: 1125899906826256 41 | Case #41: 1125899905639897 42 | Case #42: 70360153194464 43 | Case #43: 140737487815133 44 | Case #44: 0 45 | Case #45: 131391639519232 46 | Case #46: 562949953273824 47 | Case #47: 1125899873034240 48 | Case #48: 0 49 | Case #49: 1125899906059875 50 | Case #50: 1125899906162652 51 | Case #51: 1125899873178625 52 | Case #52: 309375005249111 53 | Case #53: 0 54 | Case #54: 0 55 | Case #55: 1125899898415225 56 | Case #56: 0 57 | Case #57: 281440616972288 58 | Case #58: 1123700883587072 59 | Case #59: 0 60 | Case #60: 1125899772624896 61 | Case #61: 266905859598638 62 | Case #62: 481079616210099 63 | Case #63: 1125899906842592 64 | Case #64: 1125899906446289 65 | Case #65: 1125899906795033 66 | Case #66: 1125899369971712 67 | Case #67: 1125899906187296 68 | Case #68: 1125899906803978 69 | Case #69: 0 70 | Case #70: 1125899369971712 71 | Case #71: 1125831187365888 72 | Case #72: 0 73 | Case #73: 1125899638407168 74 | Case #74: 1117103813820416 75 | Case #75: 122732985442285 76 | Case #76: 1125899903382549 77 | Case #77: 1125899906842623 78 | Case #78: 1125899906801428 79 | Case #79: 0 80 | Case #80: 1125899906319360 81 | Case #81: 0 82 | Case #82: 1125899896263139 83 | Case #83: 1125899905673471 84 | Case #84: 0 85 | Case #85: 0 86 | Case #86: 408779253350400 87 | Case #87: 0 88 | Case #88: 1125899906462057 89 | Case #89: 1125899906672100 90 | Case #90: 0 91 | Case #91: 536315377670300 92 | Case #92: 1125899906826240 93 | Case #93: 292743793770147 94 | Case #94: 1125899906842368 95 | Case #95: 0 96 | Case #96: 1059929209700352 97 | Case #97: 562949953421312 98 | Case #98: 1121570588196864 99 | Case #99: 1125899906842608 100 | Case #100: 1125899906580480 101 | -------------------------------------------------------------------------------- /2014/Round A/Problem C/C-small-practice.in: -------------------------------------------------------------------------------- 1 | 10 2 | 10 3 | e+f=72803 4 | f+g=62326 5 | g+b=-2171 6 | b+c=16359 7 | e+f=72803 8 | e+f=72803 9 | e+b=8306 10 | b+e=8306 11 | b+e=8306 12 | e+b=8306 13 | 10 14 | c+b 15 | e+b 16 | g+f 17 | b+c 18 | e+e 19 | f+c 20 | f+c 21 | f+g 22 | f+g 23 | c+b 24 | 10 25 | b+d=116668 26 | d+g=98710 27 | g+c=103409 28 | c+e=8291 29 | b+e=64240 30 | e+c=8291 31 | g+c=103409 32 | b+d=116668 33 | c+b=121367 34 | d+d=56020 35 | 10 36 | f+f 37 | b+e 38 | c+b 39 | c+b 40 | b+e 41 | b+c 42 | c+g 43 | d+c 44 | g+c 45 | e+c 46 | 10 47 | e+f=2995 48 | f+g=81595 49 | g+c=63114 50 | c+d=132803 51 | g+f=81595 52 | f+e=2995 53 | e+c=-15486 54 | c+g=63114 55 | f+g=81595 56 | f+g=81595 57 | 10 58 | e+g 59 | b+g 60 | f+f 61 | g+b 62 | b+b 63 | c+e 64 | c+e 65 | e+f 66 | f+d 67 | d+f 68 | 10 69 | e+g=136007 70 | g+f=-20417 71 | f+d=-85519 72 | d+b=-88962 73 | e+b=24520 74 | e+g=136007 75 | b+g=-23860 76 | f+b=-131904 77 | f+g=-20417 78 | d+e=70905 79 | 10 80 | d+g 81 | c+f 82 | c+f 83 | e+g 84 | g+d 85 | g+g 86 | f+f 87 | d+g 88 | b+f 89 | f+e 90 | 10 91 | e+g=30602 92 | g+b=52920 93 | b+d=130086 94 | d+f=104163 95 | d+e=107768 96 | b+d=130086 97 | b+g=52920 98 | g+f=26997 99 | f+d=104163 100 | g+e=30602 101 | 10 102 | f+e 103 | c+e 104 | g+b 105 | d+e 106 | d+b 107 | b+d 108 | f+d 109 | e+g 110 | d+e 111 | b+d 112 | 10 113 | b+b=156820 114 | f+f=-189258 115 | c+e=58886 116 | e+g=31772 117 | e+g=31772 118 | b+b=156820 119 | c+e=58886 120 | g+e=31772 121 | b+b=156820 122 | e+c=58886 123 | 10 124 | g+e 125 | c+g 126 | f+b 127 | d+g 128 | e+g 129 | c+e 130 | g+e 131 | c+e 132 | b+b 133 | g+e 134 | 10 135 | g+g=-55865 136 | e+e=114393 137 | f+c=138289 138 | c+b=137848 139 | g+g=-55865 140 | b+c=137848 141 | f+c=138289 142 | c+b=137848 143 | c+b=137848 144 | f+c=138289 145 | 10 146 | e+c 147 | d+d 148 | g+b 149 | g+f 150 | b+e 151 | b+c 152 | g+e 153 | c+f 154 | c+f 155 | g+g 156 | 10 157 | d+d=-12402 158 | g+g=95176 159 | e+c=-47973 160 | c+b=93913 161 | e+c=-47973 162 | c+e=-47973 163 | c+e=-47973 164 | b+c=93913 165 | e+c=-47973 166 | c+e=-47973 167 | 10 168 | g+g 169 | e+b 170 | d+b 171 | g+f 172 | e+g 173 | d+g 174 | g+g 175 | e+c 176 | e+c 177 | b+c 178 | 10 179 | c+c=149853 180 | d+d=110407 181 | e+g=76900 182 | g+f=14048 183 | g+e=76900 184 | g+e=76900 185 | e+g=76900 186 | g+f=14048 187 | e+g=76900 188 | c+c=149853 189 | 10 190 | e+e 191 | c+f 192 | d+f 193 | c+d 194 | b+g 195 | c+c 196 | f+g 197 | g+f 198 | d+c 199 | e+g 200 | 10 201 | f+f=-59355 202 | g+g=-71609 203 | e+b=-50823 204 | b+c=-19113 205 | c+b=-19113 206 | b+c=-19113 207 | b+e=-50823 208 | c+b=-19113 209 | e+b=-50823 210 | b+c=-19113 211 | 10 212 | g+c 213 | d+b 214 | d+f 215 | g+d 216 | b+b 217 | f+g 218 | b+c 219 | c+b 220 | b+e 221 | f+f 222 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Vote: 2 | https://code.google.com/codejam/contest/5264486/dashboard#s=p0 3 | 4 | ================== 5 | `Problem A. Vote`_ 6 | ================== 7 | 8 | Problem 9 | ------- 10 | A and B are the only two candidates competing in a certain election. 11 | We know from polls that exactly **N** voters support A, and exactly **M** 12 | voters support B. We also know that **N** is greater than **M**, 13 | so A will win. 14 | 15 | Voters will show up at the polling place one at a time, in an order chosen 16 | uniformly at random from all possible (**N** + **M**)! orders. 17 | After each voter casts their vote, the polling place worker will update the 18 | results and note which candidate (if any) is winning so far. 19 | (If the votes are tied, neither candidate is considered to be winning.) 20 | 21 | What is the probability that A stays in the lead the entire time -- that is, 22 | that A will always be winning after every vote? 23 | 24 | Input 25 | ----- 26 | The input starts with one line containing one integer **T**, which is the 27 | number of test cases. Each test case consists of one line with two integers 28 | **N** and **M**: the numbers of voters supporting A and B, respectively. 29 | 30 | Output 31 | ------ 32 | For each test case, output one line containing ``Case #x: y``, where ``x`` is 33 | the test case number (starting from 1) and ``y`` is the probability that A 34 | will always be winning after every vote. 35 | 36 | ``y`` will be considered correct if ``y`` is within an absolute or relative 37 | error of 10\ :sup:`-6` of the correct answer. See the 38 | `FAQ `_ for an 39 | explanation of what that means, and what formats of real numbers we accept. 40 | 41 | Limits 42 | ------ 43 | 1 ≤ **T** ≤ 100. 44 | 45 | Small dataset 46 | ------------- 47 | 0 ≤ **M** < **N** ≤ 10. 48 | 49 | Large dataset 50 | ------------- 51 | 0 ≤ **M** < **N** ≤ 2000. 52 | 53 | Sample 54 | ------ 55 | 56 | :: 57 | 58 | Input Output 59 | 60 | 2 Case #1: 0.33333333 61 | 2 1 Case #2: 1.00000000 62 | 1 0 63 | 64 | In sample case #1, there are 3 voters. Two of them support A -- we will call 65 | them A1 and A2 -- and one of them supports B. They can come to vote in six 66 | possible orders: A1 A2 B, A2 A1 B, A1 B A2, A2 B A1, B A1 A2, B A2 A1. 67 | Only the first two of those orders guarantee that Candidate A is winning after 68 | every vote. (For example, if the order is A1 B A2, then Candidate A is winning 69 | after the first vote but tied after the second vote.) 70 | So the answer is 2/6 = 0.333333... 71 | 72 | In sample case #2, there is only 1 voter, and that voter supports A. 73 | There is only one possible order of arrival, and A will be winning after the 74 | one and only vote. 75 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0.17647058823529413 2 | Case #2: 0.6363636363636364 3 | Case #3: 0.2 4 | Case #4: 1.0 5 | Case #5: 0.3333333333333333 6 | Case #6: 0.5 7 | Case #7: 0.125 8 | Case #8: 0.6 9 | Case #9: 0.5 10 | Case #10: 0.09090909090909091 11 | Case #11: 0.75 12 | Case #12: 0.7142857142857143 13 | Case #13: 1.0 14 | Case #14: 0.6 15 | Case #15: 0.05263157894736842 16 | Case #16: 1.0 17 | Case #17: 0.07692307692307693 18 | Case #18: 0.5 19 | Case #19: 0.6 20 | Case #20: 0.14285714285714285 21 | Case #21: 0.5 22 | Case #22: 0.45454545454545453 23 | Case #23: 0.23076923076923078 24 | Case #24: 1.0 25 | Case #25: 0.06666666666666667 26 | Case #26: 0.14285714285714285 27 | Case #27: 0.6363636363636364 28 | Case #28: 0.42857142857142855 29 | Case #29: 0.07692307692307693 30 | Case #30: 0.5 31 | Case #31: 0.42857142857142855 32 | Case #32: 0.3333333333333333 33 | Case #33: 1.0 34 | Case #34: 1.0 35 | Case #35: 0.8 36 | Case #36: 0.5 37 | Case #37: 0.1111111111111111 38 | Case #38: 0.2727272727272727 39 | Case #39: 0.2727272727272727 40 | Case #40: 0.6 41 | Case #41: 0.2857142857142857 42 | Case #42: 0.2 43 | Case #43: 0.5555555555555556 44 | Case #44: 0.42857142857142855 45 | Case #45: 1.0 46 | Case #46: 0.25 47 | Case #47: 0.8181818181818182 48 | Case #48: 0.14285714285714285 49 | Case #49: 1.0 50 | Case #50: 0.17647058823529413 51 | Case #51: 0.3333333333333333 52 | Case #52: 0.3333333333333333 53 | Case #53: 1.0 54 | Case #54: 0.14285714285714285 55 | Case #55: 0.7142857142857143 56 | Case #56: 1.0 57 | Case #57: 0.5 58 | Case #58: 0.07692307692307693 59 | Case #59: 0.42857142857142855 60 | Case #60: 1.0 61 | Case #61: 0.42857142857142855 62 | Case #62: 0.8181818181818182 63 | Case #63: 0.2727272727272727 64 | Case #64: 0.5 65 | Case #65: 0.3333333333333333 66 | Case #66: 0.14285714285714285 67 | Case #67: 0.05263157894736842 68 | Case #68: 0.25 69 | Case #69: 0.5555555555555556 70 | Case #70: 0.2857142857142857 71 | Case #71: 0.3333333333333333 72 | Case #72: 0.3333333333333333 73 | Case #73: 0.16666666666666666 74 | Case #74: 0.25 75 | Case #75: 0.25 76 | Case #76: 1.0 77 | Case #77: 1.0 78 | Case #78: 0.3333333333333333 79 | Case #79: 1.0 80 | Case #80: 0.14285714285714285 81 | Case #81: 0.5384615384615384 82 | Case #82: 1.0 83 | Case #83: 0.058823529411764705 84 | Case #84: 0.09090909090909091 85 | Case #85: 1.0 86 | Case #86: 0.5555555555555556 87 | Case #87: 0.42857142857142855 88 | Case #88: 0.6666666666666666 89 | Case #89: 0.8 90 | Case #90: 0.6666666666666666 91 | Case #91: 0.25 92 | Case #92: 0.2 93 | Case #93: 1.0 94 | Case #94: 0.7142857142857143 95 | Case #95: 0.3333333333333333 96 | Case #96: 0.8181818181818182 97 | Case #97: 0.07692307692307693 98 | Case #98: 0.09090909090909091 99 | Case #99: 0.1111111111111111 100 | Case #100: 1.0 101 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Diwali lightings: 2 | https://code.google.com/codejam/contest/5264487/dashboard#s=p0 3 | 4 | ============================== 5 | `Problem A. Diwali lightings`_ 6 | ============================== 7 | 8 | Problem 9 | ------- 10 | Diwali is the festival of lights. To celebrate it, people decorate their 11 | houses with multi-color lights and burst crackers. Everyone loves Diwali, 12 | and so does Pari. Pari is very fond of lights, and has transfinite powers, 13 | so she buys an infinite number of red and blue light bulbs. As a programmer, 14 | she also loves patterns, so she arranges her lights by infinitely repeating a 15 | given finite pattern **S**. 16 | 17 | For example, if **S** is ``BBRB``, the infinite sequence Pari builds would be 18 | ``BBRBBBRBBBRB...`` 19 | 20 | Blue is Pari's favorite color, so she wants to know the number of blue bulbs 21 | between the **I**\ th bulb and **J**\ th bulb, inclusive, in the infinite sequence 22 | she built (lights are numbered with consecutive integers starting from 1). 23 | In the sequence above, the indices would be numbered as follows:: 24 | 25 | B B R B B B R B B B R B... 26 | 1 2 3 4 5 6 7 8 9 10 11 12 27 | 28 | So, for example, there are 4 blue lights between the 4th and 8th positions, 29 | but only 2 between the 10th and 12th. 30 | 31 | Since the sequence can be very long, she wrote a program to do the count for 32 | her. Can you do the same? 33 | 34 | Input 35 | ----- 36 | | The first line of the input gives the number of test cases, **T**. **T** test cases follow. 37 | | First line of each test case consists of a string S, denoting the initial finite pattern. 38 | | Second line of each test case consists of two space separated integers **I** and **J**, defined above. 39 | 40 | Output 41 | ------ 42 | For each test case, output one line containing ``Case #x: y``, where ``x`` is 43 | the test case number (starting from 1) and ``y`` is number of blue bulbs 44 | between the **I**\ th bulb and **J**\ th bulb of Pari's infinite sequence, 45 | inclusive. 46 | 47 | Limits 48 | ------ 49 | | 1 ≤ **T** ≤ 100. 50 | | 1 ≤ length of **S** ≤ 100. 51 | | Each character of **S** is either uppercase ``B`` or uppercase ``R``. 52 | 53 | Small dataset 54 | ------------- 55 | 1 ≤ **I** ≤ **J** ≤ 10\ :sup:`6`. 56 | 57 | Large dataset 58 | ------------- 59 | 1 ≤ **I** ≤ **J** ≤ 10\ :sup:`18`. 60 | 61 | Sample 62 | ------ 63 | 64 | :: 65 | 66 | Input Output 67 | 68 | 3 Case #1: 4 69 | BBRB Case #2: 2 70 | 4 8 Case #3: 500000 71 | BBRB 72 | 10 12 73 | BR 74 | 1 1000000 75 | 76 | Cases #1 and #2 are explained above. 77 | 78 | In Case #3, bulbs at odd indices are always blue, and bulbs at even indices 79 | are always red, so there are half a million blue bulbs between positions 1 and 80 | 10\ :sup:`6`. 81 | -------------------------------------------------------------------------------- /2019/Round A/Training/ANALYSIS.rst: -------------------------------------------------------------------------------- 1 | Analysis 2 | -------- 3 | | To make a fair team, we have to train the members of the team to the same 4 | skill level as the most skillful member of the team. 5 | | For any **P** students we pick, the time required to make a fair team is = 6 | Σ(max(**S**\ :sub:`i`, **S**\ :sub:`i+1`... **S**\ :sub:`P`) 7 | - **S**\ :sub:`i`), for all students i = 1 to **P** in the team. 8 | Our goal is to minimize this value. 9 | | One possible approach could be to go through all possible subsets of **P** 10 | students, from the given **N** students. But there exists |N|\ C\ |P| such 11 | subsets(here symbol C denotes Combination_) [sic]. Number [sic] of such 12 | subsets will be in the order of |Factorial(N)| and so enumerating through 13 | all of them will not fit within the time limit. 14 | 15 | .. |N| raw:: html 16 | 17 | N 18 | 19 | .. |P| raw:: html 20 | 21 | P 22 | 23 | .. _Combination: https://en.wikipedia.org/wiki/Combination/ 24 | 25 | .. |Factorial(N)| raw:: html 26 | 27 | Factorial(N) 28 | 29 | Test set 1 (Visible) 30 | -------------------- 31 | | We can start with the observation that once we fix the student with highest 32 | skill level x, to minimize our goal we should always choose students with 33 | skills as high as possible, but less than or equal to x. Hence we can sort 34 | students on the basis of skill level in decreasing order, and iterate over 35 | each student assuming they would have the highest skill level in the team. 36 | Say, this student is at position i in the sorted sequence; the team would be 37 | formed of students on positions i, i + 1, ..., i + **P** - 1 38 | (i.e. a contiguous subarray of size **P**). 39 | | For each subarray of size **P** in the sorted array, we can calculate the 40 | training time required to make a fair team using the aforementioned formula. 41 | There are **N** - **P** + 1 subarrays of size **P**, and the complexity of 42 | calculating training time of subarray size **P** is O(**P**). So the overall 43 | complexity of this approach is O(**N** × **P**), which will be sufficient 44 | for test set 1. 45 | 46 | Test set 2 (Hidden) 47 | ------------------- 48 | | We need to go through all of the subarrays once, 49 | but can we calculate the training time of a subarray faster? 50 | | Let us assume the array is sorted in decreasing order. 51 | The training time formula for a subarray starting at position i is 52 | | = Σ(**S**\ [i] - **S**\ [j]) where j = i to i + **P** -1 [sic] 53 | | = **P** × **S**\ [i] - Σ(**S**\ [j]) where j = i to i + **P** - 1 54 | | As we always need sum [sic] of a contagious subarray, we can pre compute 55 | [sic] the prefix sum of the whole array in advance, and get the sum of any 56 | subarray in O(1) time, which makes the calculation of training time O(1). 57 | | So, the overall complexity of this approach is O(**N**). 58 | -------------------------------------------------------------------------------- /2019/Round A/Training/PROBLEM.rst: -------------------------------------------------------------------------------- 1 | Problem 2 | ------- 3 | As the football coach at your local school, you have been tasked with picking 4 | a team of exactly **P** students to represent your school. 5 | There are **N** students for you to pick from. 6 | The i-th student has a *skill rating* **S**\ |i|, 7 | which is a positive integer indicating how skilled they are. 8 | 9 | .. |i| raw:: html 10 | 11 | i 12 | 13 | You have decided that a team is *fair* if it has exactly **P** students on it 14 | and they all have the same skill rating. That way, everyone plays as a team. 15 | Initially, it might not be possible to pick a fair team, so you will give some 16 | of the students one-on-one coaching. It takes one hour of coaching to increase 17 | the skill rating of any student by 1. 18 | 19 | The competition season is starting very soon (in fact, the first match has 20 | already started!), so you'd like to find the minimum number of hours of 21 | coaching you need to give before you are able to pick a fair team. 22 | 23 | Input 24 | ----- 25 | The first line of the input gives the number of test cases, **T**. 26 | **T** test cases follow. 27 | Each test case starts with a line containing the two integers **N** and **P**, 28 | the number of students and the number of students you need to pick, 29 | respectively. Then, another line follows containing **N** integers **S**\ |i|; 30 | the i-th of these is the skill of the i-th student. 31 | 32 | Output 33 | ------ 34 | For each test case, output one line containing ``Case #x: y``, 35 | where ``x`` is the test case number (starting from 1) 36 | and ``y`` is the minimum number of hours of coaching needed, 37 | before you can pick a fair team of **P** students. 38 | 39 | Limits 40 | ------ 41 | | Time limit: 15 seconds per test set. 42 | | Memory limit: 1 GB. 43 | | 1 ≤ **T** ≤ 100. 44 | | 1 ≤ **S**\ |i| ≤ 10000, for all i. 45 | | 2 ≤ **P** ≤ **N**. 46 | 47 | Test set 1 (Visible) 48 | ~~~~~~~~~~~~~~~~~~~~ 49 | 2 ≤ **N** ≤ 1000. 50 | 51 | Test set 2 (Hidden) 52 | ~~~~~~~~~~~~~~~~~~~ 53 | 2 ≤ **N** ≤ 10\ :sup:`5`. 54 | 55 | Sample 56 | ------ 57 | 58 | :: 59 | 60 | Input Output 61 | 62 | 3 63 | 4 3 64 | 3 1 9 100 Case #1: 14 65 | 6 2 Case #2: 0 66 | 5 5 1 2 3 4 Case #3: 6 67 | 5 5 68 | 7 7 1 7 7 69 | 70 | In Sample Case #1, you can spend a total of 6 hours training the first student 71 | and 8 hours training the second one. 72 | This gives the first, second and third students a skill level of 9. 73 | This is the minimum time you can spend, so the answer is 14. 74 | 75 | In Sample Case #2, you can already pick a fair team 76 | (the first and second student) without having to do any coaching, 77 | so the answer is 0. 78 | 79 | In Sample Case #3, **P** = **N**, so every student will be on your team. 80 | You have to spend 6 hours training the third student, 81 | so that they have a skill of 7, like everyone else. 82 | This is the minimum time you can spend, so the answer is 6. 83 | -------------------------------------------------------------------------------- /2014/Round A/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 5 1011011 1011111 1010000 1011111 1011011 3 | 1 1111111 4 | 5 0000000 0000000 0000000 0000100 0000000 5 | 4 0001000 0010000 0011010 0011010 6 | 1 1011110 7 | 5 1011110 1011011 1011111 1010000 1011111 8 | 2 0010011 1011001 9 | 4 0100001 1101001 1101101 0100000 10 | 5 0110000 1111000 1111001 1111001 1110000 11 | 5 0100000 1101110 1101010 1101110 1100000 12 | 2 1111011 1110000 13 | 2 1101000 0110000 14 | 5 0010011 0110011 0110001 0100101 0110000 15 | 2 0110000 1111100 16 | 2 1010111 1010000 17 | 2 0100001 1101001 18 | 4 1101001 1101001 0100000 1101010 19 | 1 0001011 20 | 3 0111011 0111111 0110000 21 | 1 0110000 22 | 4 1011010 1011010 0110010 1111000 23 | 3 1111001 1101001 0110000 24 | 2 1111010 1111110 25 | 1 0110000 26 | 3 1111001 1111101 1110000 27 | 5 1011001 1001101 0010000 1011100 1011001 28 | 1 0011111 29 | 3 1010110 1010011 1010111 30 | 5 1011101 1011001 0010001 1011001 1001101 31 | 5 1010011 0110011 1110001 1100101 0110000 32 | 2 1101001 0110000 33 | 4 1111010 1111110 1110000 1011110 34 | 1 0110000 35 | 4 0010111 0010011 0110011 0110001 36 | 2 0110010 1111000 37 | 1 1010000 38 | 5 0110000 1111110 1111010 1111110 1110000 39 | 4 0110001 1111001 1101101 0110000 40 | 1 1011100 41 | 3 1110000 1011100 1011000 42 | 3 1110001 1100101 0110000 43 | 3 1011011 0110011 1111001 44 | 5 1011010 1011010 0110010 1111000 1101000 45 | 3 1011011 0110011 1111001 46 | 2 1100100 0110000 47 | 1 1011000 48 | 5 0011011 0011011 0110011 0111001 0101001 49 | 1 0100000 50 | 4 1011010 1011010 0110010 1111000 51 | 2 0101101 0110000 52 | 2 1111111 1110000 53 | 5 1101001 0100000 1101010 1101011 1101011 54 | 2 0010111 0010011 55 | 1 0100000 56 | 1 0111001 57 | 3 0001111 0001011 0100011 58 | 4 1101101 0110000 1111100 1111001 59 | 1 0111000 60 | 3 0110000 0111110 0111011 61 | 2 0101100 0110000 62 | 4 1011100 1011000 0110000 1111000 63 | 4 0110011 0111001 0101101 0110000 64 | 4 0011111 0010000 0011111 0011011 65 | 5 1110000 1011011 1011011 0110011 1111001 66 | 4 1101100 0100000 1101110 1101010 67 | 1 1001111 68 | 1 0110011 69 | 4 0011001 0001101 0010000 0011110 70 | 2 0100000 1101110 71 | 2 0011101 0011001 72 | 5 1001110 1001010 0100010 1101000 1101100 73 | 1 0100010 74 | 1 1111110 75 | 1 1011101 76 | 2 1010111 1010011 77 | 5 0110000 1110100 1110001 1110101 1110000 78 | 2 1001001 1001101 79 | 5 0110011 0111001 0101001 0110000 0111010 80 | 2 1110000 1011100 81 | 5 0110001 1111001 1101001 0110000 1111000 82 | 1 0111011 83 | 2 1111001 1110000 84 | 1 0111010 85 | 4 1010000 1011101 1011001 0010001 86 | 3 0000011 1001001 1001101 87 | 2 1111001 1110000 88 | 5 1011011 1011111 1010000 1011111 1011011 89 | 2 1101011 1100000 90 | 2 0101011 0101111 91 | 3 0010000 0011111 0011011 92 | 5 0101001 0110000 0111010 0111011 0111011 93 | 4 0110000 1111110 1111011 1111111 94 | 3 1111010 1110000 1011010 95 | 1 1011011 96 | 2 1110000 1011001 97 | 2 0011111 0011011 98 | 1 1111001 99 | 1 0100000 100 | 1 0110000 101 | 5 1010110 1010010 0110010 1110000 1100100 102 | -------------------------------------------------------------------------------- /2016/Round B/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Sherlock and Parentheses: 2 | https://code.google.com/codejam/contest/5254487/dashboard#s=p0 3 | 4 | ====================================== 5 | `Problem A. Sherlock and Parentheses`_ 6 | ====================================== 7 | 8 | Problem 9 | ------- 10 | Sherlock and Watson have recently enrolled in a computer programming course. 11 | Today, the tutor taught them about the balanced parentheses problem. 12 | A string ``S`` consisting only of characters ``(`` and/or ``)`` is *balanced* 13 | if: 14 | 15 | - It is the empty string, or: 16 | - It has the form ``(``\ S\ ``)``, where S is a balanced string, or: 17 | - It has the form |S1|\ |S2|, where |S1| is a balanced string and |S2| is a 18 | balanced string. 19 | 20 | .. |S1| replace:: S\ :sub:`1` 21 | .. |S2| replace:: S\ :sub:`2` 22 | 23 | Sherlock coded up the solution very quickly and started bragging about how 24 | good he is, so Watson gave him a problem to test his knowledge. 25 | He asked Sherlock to generate a string S of **L + R** characters, in which 26 | there are a total of **L** left parentheses ``(`` and a total of **R** right 27 | parentheses ``)``. Moreover, the string must have as many different balanced 28 | non-empty substrings as possible. (Two substrings are considered different as 29 | long as they start or end at different indexes of the string, even if their 30 | content happens to be the same). Note that S itself does not have to be 31 | balanced. 32 | 33 | Sherlock is sure that once he knows the maximum possible number of balanced 34 | non-empty substrings, he will be able to solve the problem. 35 | Can you help him find that maximum number? 36 | 37 | Input 38 | ----- 39 | The first line of the input gives the number of test cases, **T**. 40 | **T** test cases follow. 41 | Each test case consists of one line with two integers: **L** and **R**. 42 | 43 | Output 44 | ------ 45 | For each test case, output one line containing ``Case #x: y``, 46 | where ``x`` is the test case number (starting from 1) and ``y`` is the answer, 47 | as described above. 48 | 49 | Limits 50 | ------ 51 | 1 ≤ **T** ≤ 100. 52 | 53 | Small dataset 54 | ------------- 55 | | 0 ≤ **L** ≤ 20. 56 | | 0 ≤ **R** ≤ 20. 57 | | 1 ≤ **L + R** ≤ 20. 58 | 59 | Large dataset 60 | ------------- 61 | | 0 ≤ **L** ≤ |10^5|. 62 | | 0 ≤ **R** ≤ |10^5|. 63 | | 1 ≤ **L + R** ≤ |10^5|. 64 | 65 | .. |10^5| replace:: 10\ :sup:`5` 66 | 67 | Sample 68 | ------ 69 | 70 | :: 71 | 72 | Input Output 73 | 74 | 3 Case #1: 0 75 | 1 0 Case #2: 1 76 | 1 1 Case #3: 3 77 | 3 2 78 | 79 | | In Case 1, the only possible string is ``(``. There are no balanced non-empty substrings. 80 | | In Case 2, the optimal string is ``()``. There is only one balanced non-empty substring: the entire string itself. 81 | | In Case 3, both strings ``()()(`` and ``(()()`` give the same optimal answer. 82 | | For the case ``()()(``, for example, the three balanced substrings are ``()`` from indexes 1 to 2, ``()`` from indexes 3 to 4, and ``()()`` from indexes 1 to 4. 83 | -------------------------------------------------------------------------------- /2014/Round D/Problem B/B-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 30 3 19 19 15 20 5 13 26 26 27 11 11 19 26 0 4 6 0 0 14 19 9 17 31 2 | Case #2: 76 110 102 103 38 48 51 63 86 75 38 2 97 86 3 0 20 84 91 5 103 95 66 59 6 26 77 46 82 63 95 101 96 29 87 72 16 19 101 6 95 59 45 72 0 88 16 0 97 110 3 33 52 7 110 19 25 68 1 1 4 6 29 54 74 20 88 47 94 23 6 23 57 54 15 1 87 45 93 80 49 45 6 7 75 85 1 3 32 23 92 102 94 10 53 7 7 25 88 15 3 | Case #3: 49 113 117 83 223 171 179 56 86 74 160 220 162 156 13 16 46 162 86 229 81 231 176 152 96 221 1 28 185 231 220 51 215 67 217 179 210 12 93 70 230 82 201 17 48 29 1 1 78 79 201 46 1 29 206 161 189 78 29 24 7 36 4 43 79 36 202 1 46 1 99 175 1 78 1 171 1 18 154 230 122 226 225 103 57 81 22 215 111 134 53 227 149 28 90 217 64 70 232 13 6 105 223 1 1 165 108 148 98 46 94 1 20 173 181 142 1 51 120 222 86 56 22 72 229 78 214 212 188 20 82 139 37 231 113 182 85 160 36 20 229 179 39 166 97 99 231 170 111 47 66 212 154 210 80 220 163 230 136 141 232 217 73 166 85 8 111 226 158 220 226 29 94 230 183 172 230 171 50 159 101 220 85 109 16 201 229 13 146 1 219 21 46 166 215 228 140 178 148 129 167 1 74 124 111 149 101 99 22 1 80 43 151 150 184 159 50 101 223 124 230 126 115 223 37 95 216 184 48 1 174 111 226 71 2 124 4 99 102 28 43 137 164 34 155 225 230 4 140 78 43 225 20 174 149 10 210 230 92 5 183 102 183 155 206 149 81 148 5 112 39 14 156 22 57 74 51 230 215 80 50 139 192 195 28 89 103 96 75 48 1 192 20 83 185 228 218 179 99 67 229 222 176 178 79 74 102 83 183 7 149 174 59 37 156 223 150 34 1 100 210 1 142 168 60 96 48 70 218 1 103 39 215 46 180 228 1 28 217 186 107 150 36 205 142 216 161 108 53 160 232 43 151 82 210 176 141 139 227 189 20 36 37 217 189 215 94 93 42 209 143 149 154 162 29 1 156 51 8 78 225 51 176 177 43 68 37 228 190 133 113 218 34 24 113 179 78 96 202 82 215 39 28 1 209 216 33 229 184 134 217 217 28 33 70 44 62 91 221 227 188 90 48 174 141 124 44 159 141 229 1 14 227 201 92 53 172 218 20 149 1 108 48 206 228 16 213 192 155 233 154 154 20 159 81 222 81 114 181 79 225 90 223 134 81 166 201 224 22 133 220 231 108 57 173 54 231 140 43 113 229 231 225 232 186 22 139 95 1 78 220 225 11 20 29 104 231 228 141 228 4 | Case #4: 38 38 40 58 49 4 37 39 74 40 9 23 6 1 24 13 67 30 19 42 9 0 31 48 69 63 43 0 63 2 63 47 73 37 15 19 11 12 25 61 1 1 74 48 30 25 63 31 6 37 1 71 74 3 0 52 26 0 31 69 67 68 6 11 6 70 24 48 71 53 37 72 38 52 0 1 48 71 30 64 5 | Case #5: 66 100 148 10 145 2 17 2 149 121 144 57 43 126 49 136 25 146 17 2 45 109 10 112 2 139 149 34 1 122 89 45 89 115 2 49 17 4 45 18 4 135 110 45 104 138 100 145 18 130 99 149 151 107 70 81 98 29 144 91 143 96 126 74 71 135 95 85 138 120 10 64 74 19 146 6 18 140 106 127 149 71 82 70 141 140 55 33 30 92 88 133 149 47 54 78 59 32 142 146 132 91 43 39 65 133 13 67 40 85 130 153 90 62 34 80 142 111 32 130 10 119 148 72 57 143 117 144 98 132 102 52 6 43 141 145 64 35 24 133 152 101 146 135 151 12 16 126 131 49 6 | Case #6: 76 39 59 0 0 0 70 42 72 72 6 72 60 12 4 14 17 59 34 17 69 73 9 12 30 18 0 59 70 6 41 55 7 62 45 55 76 71 72 39 9 9 38 32 48 25 72 24 54 72 55 59 41 8 38 67 6 0 41 69 13 72 10 75 65 40 6 63 62 15 67 55 0 7 12 60 2 38 0 53 7 | -------------------------------------------------------------------------------- /2016/Round C/Problem B/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem B. Safe Squares: 2 | https://code.google.com/codejam/contest/6274486/dashboard#s=p1 3 | 4 | ========================== 5 | `Problem B. Safe Squares`_ 6 | ========================== 7 | 8 | Problem 9 | ------- 10 | Codejamon trainers are actively looking for monsters, but if you are not a 11 | trainer, these monsters could be really dangerous for you. 12 | You might want to find safe places that do not have any monsters! 13 | 14 | Consider our world as a grid, and some of the cells have been occupied by 15 | monsters. We define a *safe square* as a grid-aligned **D** × **D** square of 16 | grid cells (with **D** ≥ 1) that does not contain any monsters. Your task is 17 | to find out how many safe squares (of any size) we have in the entire world. 18 | 19 | Input 20 | ----- 21 | The first line of the input gives the number of test cases, **T**. 22 | **T** test cases follow. Each test case starts with a line with three 23 | integers, **R**, **C**, and **K**. The grid has **R** rows and **C** columns, 24 | and contains **K** monsters. **K** more lines follow; each contains two 25 | integers **R**\ |i| and **C**\ |i|, indicating the row and column that the 26 | i-th monster is in. (Rows are numbered from top to bottom, starting from 0; 27 | columns are numbered from left to right, starting from 0.) 28 | 29 | .. |i| raw:: html 30 | 31 | i 32 | 33 | Output 34 | ------ 35 | For each test case, output one line containing ``Case #x: y``, 36 | where ``x`` is the test case number (starting from 1) 37 | and ``y`` is the the total number of safe zones for this test case. 38 | 39 | Limits 40 | ------ 41 | 1 ≤ **T** ≤ 20. 42 | 43 | (**R**\ |i|, **C**\ |i|) ≠ (**R**\ |j|, **C**\ |j|) for i ≠ j. 44 | (No two monsters are in the same grid cell.) 45 | 46 | 0 ≤ **R**\ |i| < **R**, i from 1 to **K** 47 | 48 | 0 ≤ **C**\ |i| < **C**, i from 1 to **K** 49 | 50 | .. |j| raw:: html 51 | 52 | j 53 | 54 | Small dataset 55 | ------------- 56 | 1 ≤ **R** ≤ 10. 57 | 58 | 1 ≤ **C** ≤ 10. 59 | 60 | 0 ≤ **K** ≤ 10. 61 | 62 | Large dataset 63 | ------------- 64 | 1 ≤ **R** ≤ 3000. 65 | 66 | 1 ≤ **C** ≤ 3000. 67 | 68 | 0 ≤ **K** ≤ 3000. 69 | 70 | Sample 71 | ------ 72 | 73 | :: 74 | 75 | Input Output 76 | 77 | 2 Case #1: 10 78 | 3 3 1 Case #2: 51 79 | 2 1 80 | 4 11 12 81 | 0 1 82 | 0 3 83 | 0 4 84 | 0 10 85 | 1 0 86 | 1 9 87 | 2 0 88 | 2 4 89 | 2 9 90 | 2 10 91 | 3 4 92 | 3 10 93 | 94 | The grid of sample case #1 is: 95 | 96 | | ``0 0 0`` 97 | | ``0 0 0`` 98 | ``0 1 0`` 99 | 100 | Here, 0 represents a cell with no monster, and 1 represents a cell with a 101 | monster. It has 10 safe squares: 8 1x1 and 2 2x2. 102 | 103 | The grid of sample case #2 is: 104 | 105 | | ``0 1 0 1 1 0 0 0 0 0 1`` 106 | | ``1 0 0 0 0 0 0 0 0 1 0`` 107 | | ``1 0 0 0 1 0 0 0 0 1 1`` 108 | ``0 0 0 0 1 0 0 0 0 0 1`` 109 | 110 | Note that sample case #2 will only appear in the Large dataset. 111 | It has 51 safe squares: 32 1x1, 13 2x2, 5 3x3, and 1 4x4. 112 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 466666666666663691 2 | Case #2: 146341463414632522 3 | Case #3: 0 4 | Case #4: 275862068965511877 5 | Case #5: 1000000000000000000 6 | Case #6: 289473684210524225 7 | Case #7: 399999999999995106 8 | Case #8: 468749999999997049 9 | Case #9: 374999999999997912 10 | Case #10: 536585365853651429 11 | Case #11: 499999999999996097 12 | Case #12: 95238095238094368 13 | Case #13: 499999999999997820 14 | Case #14: 829787234042545528 15 | Case #15: 606382978723396731 16 | Case #16: 346938775510202774 17 | Case #17: 235294117647056799 18 | Case #18: 655172413793093225 19 | Case #19: 0 20 | Case #20: 161290322580644459 21 | Case #21: 782608695652165414 22 | Case #22: 304347826086953741 23 | Case #23: 634146341463403681 24 | Case #24: 538461538461537077 25 | Case #25: 328571428571427122 26 | Case #26: 111111111111110788 27 | Case #27: 666666666666660294 28 | Case #28: 105263157894735750 29 | Case #29: 359550561797746204 30 | Case #30: 214285714285712374 31 | Case #31: 550000000000000000 32 | Case #32: 408602150537633340 33 | Case #33: 999999999999990485 34 | Case #34: 257142857142856158 35 | Case #35: 428571428571424185 36 | Case #36: 599999999999992056 37 | Case #37: 392857142857138022 38 | Case #38: 0 39 | Case #39: 148148148148147592 40 | Case #40: 466666666666662268 41 | Case #41: 854166666666663031 42 | Case #42: 865853658536575070 43 | Case #43: 492753623188397968 44 | Case #44: 275362318840575476 45 | Case #45: 444444444444442316 46 | Case #46: 431372549019604040 47 | Case #47: 550561797752800843 48 | Case #48: 595238095238088523 49 | Case #49: 596491228070166826 50 | Case #50: 803921568627438648 51 | Case #51: 395348837209298276 52 | Case #52: 862745098039207720 53 | Case #53: 374999999999999147 54 | Case #54: 0 55 | Case #55: 388888888888885659 56 | Case #56: 353658536585360811 57 | Case #57: 649999999999993328 58 | Case #58: 540540540540535695 59 | Case #59: 1000000000000000000 60 | Case #60: 678571428571417656 61 | Case #61: 441176470588234536 62 | Case #62: 604651162790692066 63 | Case #63: 999999999999989088 64 | Case #64: 694117647058815279 65 | Case #65: 734939759036137531 66 | Case #66: 178571428571426112 67 | Case #67: 599999999999993551 68 | Case #68: 41666666666665973 69 | Case #69: 372549019607837232 70 | Case #70: 328358208955222390 71 | Case #71: 853932584269650632 72 | Case #72: 999999999999984086 73 | Case #73: 506493506493501911 74 | Case #74: 599999999999993819 75 | Case #75: 367346938775506970 76 | Case #76: 880434782608688298 77 | Case #77: 646341463414625039 78 | Case #78: 639999999999989779 79 | Case #79: 906666666666665747 80 | Case #80: 799999999999988111 81 | Case #81: 444444444444438898 82 | Case #82: 874999999999990871 83 | Case #83: 166666666666665998 84 | Case #84: 694444444444442347 85 | Case #85: 0 86 | Case #86: 217948717948717390 87 | Case #87: 478260869565213802 88 | Case #88: 421052631578942776 89 | Case #89: 714285714285707223 90 | Case #90: 617021276595735399 91 | Case #91: 209302325581393375 92 | Case #92: 511627906976738040 93 | Case #93: 919354838709663418 94 | Case #94: 360000000000000000 95 | Case #95: 1 96 | Case #96: 0 97 | Case #97: 864864864864851629 98 | Case #98: 426229508196719448 99 | Case #99: 666666666666656014 100 | Case #100: 882352941176468306 101 | -------------------------------------------------------------------------------- /2016/Round D/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: 0.28683385579937304 2 | Case #2: 0.3572994300745287 3 | Case #3: 0.4934725848563969 4 | Case #4: 0.9654959950708565 5 | Case #5: 0.08252650991240203 6 | Case #6: 0.5295336787564767 7 | Case #7: 0.3489736070381232 8 | Case #8: 0.1571025399811853 9 | Case #9: 0.5630498533724341 10 | Case #10: 0.0494728304947283 11 | Case #11: 0.7071274298056156 12 | Case #12: 1.0 13 | Case #13: 0.6211812627291242 14 | Case #14: 0.23483438779307778 15 | Case #15: 0.3267950963222417 16 | Case #16: 0.22723253757736517 17 | Case #17: 0.08190171793847383 18 | Case #18: 0.16019575856443719 19 | Case #19: 0.5158254918733961 20 | Case #20: 0.27030625832223704 21 | Case #21: 0.11038430089942763 22 | Case #22: 0.09980430528375733 23 | Case #23: 0.5283136278780336 24 | Case #24: 0.17470760233918128 25 | Case #25: 0.4692218350754936 26 | Case #26: 0.09054093144344807 27 | Case #27: 0.03679885673454805 28 | Case #28: 0.2742835876442129 29 | Case #29: 0.3017667844522968 30 | Case #30: 0.6948275862068966 31 | Case #31: 0.41580381471389644 32 | Case #32: 0.36343772760378734 33 | Case #33: 0.2388362652232747 34 | Case #34: 0.14508580343213728 35 | Case #35: 0.33543903979785217 36 | Case #36: 0.4675 37 | Case #37: 0.780448717948718 38 | Case #38: 0.022988505747126436 39 | Case #39: 0.29844961240310075 40 | Case #40: 0.15578465063001146 41 | Case #41: 0.999000499750125 42 | Case #42: 0.9634464751958225 43 | Case #43: 0.5296094078118437 44 | Case #44: 0.05114029025570145 45 | Case #45: 0.3902027027027027 46 | Case #46: 0.7131147540983607 47 | Case #47: 0.04878048780487805 48 | Case #48: 0.776551724137931 49 | Case #49: 0.07751937984496124 50 | Case #50: 0.7863397548161121 51 | Case #51: 0.012840588787973693 52 | Case #52: 0.31368235811702594 53 | Case #53: 0.964248159831756 54 | Case #54: 0.0787518573551263 55 | Case #55: 0.3333333333333333 56 | Case #56: 0.41404358353510895 57 | Case #57: 0.14754098360655737 58 | Case #58: 0.046708348657594705 59 | Case #59: 0.34112792297111416 60 | Case #60: 0.8518518518518519 61 | Case #61: 0.08488063660477453 62 | Case #62: 0.749034749034749 63 | Case #63: 0.1833385926159672 64 | Case #64: 0.38995568685376664 65 | Case #65: 0.019279738086576938 66 | Case #66: 0.4915079773546063 67 | Case #67: 0.5584303579128935 68 | Case #68: 0.4425806451612903 69 | Case #69: 0.727810650887574 70 | Case #70: 0.1836734693877551 71 | Case #71: 0.6482084690553745 72 | Case #72: 0.11413454270597127 73 | Case #73: 0.043029259896729774 74 | Case #74: 1.0 75 | Case #75: 0.8512297540491902 76 | Case #76: 0.16636528028933092 77 | Case #77: 0.2625841615902533 78 | Case #78: 0.06534199465036301 79 | Case #79: 0.6512027491408935 80 | Case #80: 0.6408808582721626 81 | Case #81: 0.41508759385055416 82 | Case #82: 0.048818897637795275 83 | Case #83: 0.27481713688610243 84 | Case #84: 0.3045429052159282 85 | Case #85: 0.47551020408163264 86 | Case #86: 0.04818763326226013 87 | Case #87: 0.13368983957219252 88 | Case #88: 0.5942028985507246 89 | Case #89: 0.01607717041800643 90 | Case #90: 0.00025006251562890725 91 | Case #91: 0.20066889632107024 92 | Case #92: 0.23605150214592274 93 | Case #93: 0.6600826825907212 94 | Case #94: 0.07430997876857749 95 | Case #95: 0.2715551974214343 96 | Case #96: 0.7805405405405406 97 | Case #97: 0.9835345773874863 98 | Case #98: 0.23601973684210525 99 | Case #99: 0.6136528685548294 100 | Case #100: 0.46234509056244044 101 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/C-small-practice.in: -------------------------------------------------------------------------------- 1 | 50 2 | 1000 1 19 15 17 14 8 20 3 | 1000 8 19 14 16 1 4 20 4 | 1000 10 12 9 15 14 1 20 5 | 1000 0 999995001 1 0 10000 10000 1000000000 6 | 1 622295210 818961667 0 0 514209038 20631819 960988685 7 | 4 484116014 658268577 0 0 551601488 327939466 939080682 8 | 1 292232854 896894315 0 0 479061765 299210935 976175136 9 | 2 142502304 890235588 0 0 32541867 14121448 968211753 10 | 4 753617 882843865 0 0 72063687 624465689 987435521 11 | 1000 74657024 163822613 0 0 447425142 549710036 924477972 12 | 1000 281439273 961964542 0 0 61829024 639596734 955931073 13 | 1000 489295966 770776836 0 0 59732606 196543025 999772851 14 | 1000 803421 137144037 0 0 867311301 978625672 947666872 15 | 1000 36517779 679716007 0 0 594144585 835909261 967306529 16 | 1000 302080834 847224573 262459029 723757896 0 0 982271414 17 | 1000 377774953 553846558 294309496 531250518 0 0 982154319 18 | 1000 144962014 973489864 489216220 999517491 0 0 919484895 19 | 1000 319430434 762359205 639797997 577467273 0 0 972849382 20 | 1000 411587588 789855217 328434141 79490465 0 0 928062911 21 | 1000 266262474 628300813 769786402 441383498 484186986 723567466 940642240 22 | 1000 110352529 411439440 118867344 820027764 410584037 105045030 974963387 23 | 1000 29313008 375169227 135772217 28529115 83924639 352208254 982842777 24 | 1000 459715330 501130810 577575662 761703058 366391258 528873045 938942796 25 | 1000 439877045 674412426 88365719 720944764 593519237 622494146 844429447 26 | 1000 164459784 565374209 81049497 898723469 385411789 995041098 949295357 27 | 1000 187223497 697668143 56028582 367224336 973091218 14730443 972504359 28 | 1000 566209460 992915439 976426103 216773334 916411093 2379812 930701145 29 | 1000 140278796 289037769 700773258 435995583 841357022 339859173 981531718 30 | 1000 600548978 822748685 899465724 57125379 396503499 895468734 993888553 31 | 1000 262105786 287839606 985976333 859135343 732186259 66161028 982221799 32 | 1000 19694964 456733741 954341359 652151741 917885354 80946035 986829680 33 | 1000 62586094 348871376 276105028 644371240 123596680 128170092 946147730 34 | 1000 304110441 475411611 809999364 230978168 404737027 324279512 971648040 35 | 1000 7653517 55142560 908697213 693560278 353255692 651404461 946899652 36 | 1000 140535925 834996180 611201312 110205601 975311356 248440541 932552527 37 | 1000 334188374 921411473 955332558 388472884 16581108 862482734 944855746 38 | 1000 24642622 998041333 859095368 812843672 419808410 574445130 952629548 39 | 1000 205072304 413823218 664988198 495028229 996564056 209754889 975400156 40 | 1000 636667549 678201228 383261331 27290862 965153481 609382711 945647881 41 | 1000 517946350 972938742 390538189 854695546 366222472 59837307 982410008 42 | 1000 321497817 631904998 84518490 809986614 761347591 903294103 975677723 43 | 1000 72898102 211172132 488269818 274994160 233377913 928237751 962660123 44 | 997 178622196 282196639 217454409 333993639 370687882 713045549 967750417 45 | 995 266879862 704083174 621464846 139064822 53955913 968627703 913718057 46 | 948 531547564 796245442 751099374 470238435 828072769 400273742 903386330 47 | 952 227854771 935344149 201903631 337516161 880867662 309656832 943868603 48 | 1000 140747090 893149084 11836941 267259828 333735916 794529350 995166050 49 | 1000 66992513 426795422 386566889 671424446 621988107 556974781 984598569 50 | 1000 503580429 508539367 197990654 368399284 940181094 104854259 927618673 51 | 1000 504901682 973731461 636434916 384077141 224831334 730235134 951129510 52 | -------------------------------------------------------------------------------- /2016/Round A/Problem A/A-large-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: CJZFF SONVBXRKPSAGMX 2 | Case #2: IR XOPHCQ DTVCRDKGFI 3 | Case #3: AZOLQJ XCW QPWF SHZM 4 | Case #4: CA FTGTOCEGNSLVURC Y 5 | Case #5: BLCBJRJVEOVGMUIHFZMZ 6 | Case #6: LGGBKEW COVA HXNTY 7 | Case #7: GMACODMKY SWBTBVQG 8 | Case #8: VW SAILXNCFJB I YK 9 | Case #9: GYLHCAMSOLQOPX EVQ 10 | Case #10: S MTAHIEJMQSZFCWNVB 11 | Case #11: UPQCMTWHKPRZKIJNEJ 12 | Case #12: FUSTYWCCEBZGKLQTTP 13 | Case #13: IOV UGNVRQMWICRZUAEK 14 | Case #14: GKBVQFXMYJKOZ N P 15 | Case #15: GMKG BPRSDNFATKJVBYX 16 | Case #16: HE BGN XCIRJWQPWZ 17 | Case #17: HWLVTQOVCASWZXBKDOLE 18 | Case #18: ESLQ YKVCHXBGDS J D 19 | Case #19: ABEIYHTUP X OZNMVJ 20 | Case #20: BZHPJQYF JUQWCRO VE 21 | Case #21: YCBLRDHUSIJD YNEVK O 22 | Case #22: DJNTGSLZHDYQVEVYJRNC 23 | Case #23: BL IFZTIUXQMSCWVU O 24 | Case #24: GGVJKUQIYHPNSOZYP 25 | Case #25: INAUVMBXZX DETKZLHF 26 | Case #26: A Y EXFJSVRVWOOQHWNC 27 | Case #27: ICAW GTDTLRQVHYMCNEF 28 | Case #28: MQAJN GB CLVWFRKS 29 | Case #29: EXWACICYZSXXBBAOVZK 30 | Case #30: A AB C 31 | Case #31: WJLSIALFRKXAQ CYL ZT 32 | Case #32: EUZ PBAJCFKWRFMVQP 33 | Case #33: ZYBXIKZPSRVGLOSNDQAF 34 | Case #34: FHIMUDFNJEQ LMSWWVOM 35 | Case #35: MUNYUJJAOFLBGTFCUBR 36 | Case #36: WVIRUAHFPUEDZNLSEAX 37 | Case #37: BVUAZP EFLW QTKARGWE 38 | Case #38: CVL RKXKP IAJDZ RBF 39 | Case #39: NJLZSFQA OMUTEEBHC 40 | Case #40: KZNGDIOJAPVHCMJXUP 41 | Case #41: RBAEVSTVQFPMUJI SK 42 | Case #42: KDA NJUQHXGAISDCZ NV 43 | Case #43: EWRUPSFMUZINQLRZDVBX 44 | Case #44: GZNCSCHRQTWFIPEEJS 45 | Case #45: IKTM MRUE MVKRNJG BH 46 | Case #46: CJTBOEVUNAHWEG JKR 47 | Case #47: YMKIGTWZZSHIQBK DVU 48 | Case #48: JPGRXPDHIVZADUYK 49 | Case #49: JDGETB A YXINCKQOHV 50 | Case #50: BHBRZNAPVFFLWUEIQXH 51 | Case #51: HP FZVNKORIMLXGMPTV 52 | Case #52: PRAD KYZWCAGGXLROKQH 53 | Case #53: DBEMTTSAH NZOOH CUL 54 | Case #54: BHVMQEFWKU GYIDMUY 55 | Case #55: QHOVBPSU KDWYCEZYGU 56 | Case #56: DYACYDV OGTMYFIPHL 57 | Case #57: ZEICNDVRFGACLYWG 58 | Case #58: LAGTKU WVAAMRSHCXTR 59 | Case #59: PMS SIHRQKYLNPGPUXHB 60 | Case #60: LKQEBRLPGZRDYFIMX H 61 | Case #61: MKNBWQZG UODYZRAGALE 62 | Case #62: QMO TDTZACNHOEF XSWE 63 | Case #63: LSWLENINKPHVKQVYMXR 64 | Case #64: COEJ DFIISTFCRVXUEPK 65 | Case #65: AOEPJXDGBJWGIHZ 66 | Case #66: JRGNBFWD AMZCHOIARQ 67 | Case #67: LHDUPSLJMB RGGFDYQW 68 | Case #68: LGNKJBIX FQHLYCU 69 | Case #69: FMUWSKDCDEMRSHACMVIM 70 | Case #70: TZUNHP LQGCWTKQSTSDG 71 | Case #71: AMJZCDOTIFOUISWWRHS 72 | Case #72: MJYRVCXBARGNKBHEDHQ 73 | Case #73: RM NSEPSLCDVWQJMHJB 74 | Case #74: OAGVCEUX QFKWZNM 75 | Case #75: O QEWVRQ I YFDJNCKH 76 | Case #76: CTX YQTMSOFAH BIN VZ 77 | Case #77: JEOJ P VAWRZCENTGF 78 | Case #78: FUT XORMLBHHHKY ZJNC 79 | Case #79: JOHNSON 80 | Case #80: FCXZAUSJQWLXVZJWPMUE 81 | Case #81: YFMZOJQPLUCRUEHISN 82 | Case #82: EBKMRLOZQEGPPYZFHT 83 | Case #83: B ZJNOXQMGJACUFSORJD 84 | Case #84: U XRAPJHGWR BKIPQDDC 85 | Case #85: CUIDQWTS FHB PIDNG I 86 | Case #86: AMRIGSQUCIDNLVS WX 87 | Case #87: RTO HVYWB IKEDZASPC 88 | Case #88: LFTUSVQXH WXBJEUGG 89 | Case #89: EUBW KOACTN YMXD R 90 | Case #90: HWTELGICKUINESL BRO 91 | Case #91: OP VCOZAWTYU AAQNLXP 92 | Case #92: EPHZHARSQNTKXDIB TV 93 | Case #93: UZRHABLW DNCGMMYK 94 | Case #94: BNTNHGAIALSDUFLN WXE 95 | Case #95: ADNYWNUODRFVUEZKIQ 96 | Case #96: IEFLXC TMIURVQZVKSP 97 | Case #97: JD XMIWNHMOIGTCZ GYA 98 | Case #98: FMPPJEWBI OZBNFYXG 99 | Case #99: VO PFZFKHJXFYUAXTS 100 | Case #100: DUERQQO YAXMV CTI 101 | -------------------------------------------------------------------------------- /2016/Round A/Problem A/A-small-practice-solution.txt: -------------------------------------------------------------------------------- 1 | Case #1: CMWGICOTZKVNXFJGPB 2 | Case #2: SNKLYGHSEAJNXOPHDIIU 3 | Case #3: CKLGNTVKPJUQVHFKOJYC 4 | Case #4: VKUZECHUBKDQSYIEGR 5 | Case #5: MYLXVXPROOQACCREXGNK 6 | Case #6: JDGETBAYXINCKQOHVAL 7 | Case #7: IESUGXPJKNYQTMZCVRK 8 | Case #8: KQLWBYJUXWMQZNBVRZIZ 9 | Case #9: XFYUAXTSOIPXJNTWEMVR 10 | Case #10: IOVUGNVRQMWICRZUAEKL 11 | Case #11: MDBPULJTNVIBPVKWICXY 12 | Case #12: LPGZRDYFIMXHMOKTGV 13 | Case #13: EMRVAZWTJNRCSTUOGUPP 14 | Case #14: NDBKMRKUOZSLZALHQTC 15 | Case #15: GDNERYKFLCEMFDGHBLIA 16 | Case #16: LYJTSODMNVPIGOZA 17 | Case #17: UBLFILHYXVAXRBVPTQSN 18 | Case #18: SJMKNBWQZGUODYZRAGA 19 | Case #19: EYTIFRXVXXHYMOPKQDLM 20 | Case #20: QKXGRHJSUENSBAVCW 21 | Case #21: JQFCGOGSYYUPVVRHTEHB 22 | Case #22: SQRXALITJVBJBKOGCNK 23 | Case #23: MXZEKVRXPZNGLGBRZDSC 24 | Case #24: OLZVNQRDOJACJIBTGVO 25 | Case #25: MQTLVPBSVWYUIELEZRN 26 | Case #26: SHDBQGVDATZNJGXMII 27 | Case #27: DHQACXDZOVTMQKRCBFEH 28 | Case #28: WZAZZEBRSFTYMKUHQT 29 | Case #29: GRXPDHIVZADUYKEB 30 | Case #30: FDYXFKCIQBHRJAWLAC 31 | Case #31: IWSMGCQOIKDVQXNLY 32 | Case #32: JOHNSON 33 | Case #33: JEOJPVAWRZCENTGFKI 34 | Case #34: FSCXCZVNTKGIJGGNPUAE 35 | Case #35: VVKFJMPMZOBITLREWDUK 36 | Case #36: NOHRGSWBSDZATZXPEYE 37 | Case #37: EKLVVCOWGCFMGYRQNJM 38 | Case #38: UMAWLBCOZUPOAIYXEQH 39 | Case #39: THKLUBIIJRQZXENQYAST 40 | Case #40: EXRCBRWAYEMNJQGIH 41 | Case #41: DRYTBDIDQYXKJPVEAMHF 42 | Case #42: SYXUWQKTDINJFGVZRXXB 43 | Case #43: LAZADBYKWMHVGXONHKOQ 44 | Case #44: BZHPJQYFJUQWCROVENVD 45 | Case #45: PMJBXUXTAVJCGLWZVSDB 46 | Case #46: DKOFVRRATZFQMHLYFZJ 47 | Case #47: ZKXZFIOALVYWJCMDNXSU 48 | Case #48: BCFTWBGTJNUVHBLRDANP 49 | Case #49: IAMGPYOLQRXBPWETMFUS 50 | Case #50: RCSAEOBQWZGVBJIUUGFH 51 | Case #51: HQDPQFJASYSNELVKQRIX 52 | Case #52: KYRFULXATNJNWVIJDM 53 | Case #53: CQGLORUCKTVNILVYBF 54 | Case #54: RIXQXPNUFZQHXTCKVI 55 | Case #55: VLEBPQDTDUSERAWWOZ 56 | Case #56: KZYRVCMEUUNPLNNYJOT 57 | Case #57: MQWFZORJAXYHCBV 58 | Case #58: TUHWOCETRPPADJKVLKNG 59 | Case #59: GUICHJCXRXEYPCWAMJTZ 60 | Case #60: MKZOUDFBJEGXMWBHCR 61 | Case #61: NZRYUQQLPPBLTKMIXDJ 62 | Case #62: BMEGRSHWTELGICKUINES 63 | Case #63: AFQMWIFUPALEXSCYMHQE 64 | Case #64: RGJSZANOPIDLFMIWEMDW 65 | Case #65: RGLOHVHKFIIURNWDZEPQ 66 | Case #66: LZUQIMFHPBFLTXRDKTSN 67 | Case #67: WUQCACYBPHKZJCHLMZVE 68 | Case #68: VMKBTAEAUGZOYSPDJLB 69 | Case #69: FUTXORMLBHHHKYZJNCLZ 70 | Case #70: HCLGMKOXSIPDJXJRWZHV 71 | Case #71: RDHGVYJAOPUCLTQKLIF 72 | Case #72: FTHDLNMSWJIHVAQQUK 73 | Case #73: CMTWHKPRZKIJNEJYO 74 | Case #74: GOINKYFXEFLCPMRAC 75 | Case #75: OCAQVKDDBUPZHHDYINW 76 | Case #76: GEFRIAAYXTMZQJOACLHB 77 | Case #77: SZKTFPYEOLETGJHRAGV 78 | Case #78: BECALENCOGVVXTJQZWYI 79 | Case #79: LUOPHLJCJNSTKEDMZA 80 | Case #80: PHBUTJJDFPIAKLRQEN 81 | Case #81: NFMSZXJCQDEFYHUFIIG 82 | Case #82: NDLPQRABTPNGENICJH 83 | Case #83: BBIGSRFDCYXVCRVHZRWL 84 | Case #84: MTAHIEJMQSZFCWNVBHR 85 | Case #85: CEWRDARJMIGLFAJKZSN 86 | Case #86: IUICJYOEHDDLSHPZZNTF 87 | Case #87: BMMJKKTWSSRPLYXNHSEU 88 | Case #88: NLWKASORQGNUVRKPFILZ 89 | Case #89: MMBYOLIKMAXPESTRHUYF 90 | Case #90: EJGDQGQBOXFPMZWTAR 91 | Case #91: ZJMUCAVPSAFMXHAQGIAR 92 | Case #92: QQZRAXPNKUCLBCLFVDLG 93 | Case #93: BDZHVEXHWIVRMULGA 94 | Case #94: PRKZNGDIOJAPVHCMJ 95 | Case #95: HTVGUTOACIZWSRGLZZJM 96 | Case #96: VRDDKNYPGLSGWAMQRCJO 97 | Case #97: YCHSETBJFOFMLDUIZ 98 | Case #98: PWUPMLZKFDVOIXHEYWQ 99 | Case #99: HLROMTPZKCCKVBQEJLVZ 100 | Case #100: GQMDJBECWISYPZHWOFA 101 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/C-large-practice.in: -------------------------------------------------------------------------------- 1 | 50 2 | 500000 5 85 39 61 72 97 100 3 | 500000 167 891 711 270 424 901 981 4 | 100000 0 999995001 1 0 10000 10000 1000000000 5 | 1 622295210 818961667 0 0 514209038 20631819 960988685 6 | 4 484116014 658268577 0 0 551601488 327939466 939080682 7 | 1 292232854 896894315 0 0 479061765 299210935 976175136 8 | 2 142502304 890235588 0 0 32541867 14121448 968211753 9 | 4 753617 882843865 0 0 72063687 624465689 987435521 10 | 1000 74657024 163822613 0 0 447425142 549710036 924477972 11 | 1000 281439273 961964542 0 0 61829024 639596734 955931073 12 | 1000 489295966 770776836 0 0 59732606 196543025 999772851 13 | 1000 803421 137144037 0 0 867311301 978625672 947666872 14 | 1000 36517779 679716007 0 0 594144585 835909261 967306529 15 | 1000 302080834 847224573 262459029 723757896 0 0 982271414 16 | 1000 377774953 553846558 294309496 531250518 0 0 982154319 17 | 1000 144962014 973489864 489216220 999517491 0 0 919484895 18 | 1000 319430434 762359205 639797997 577467273 0 0 972849382 19 | 1000 411587588 789855217 328434141 79490465 0 0 928062911 20 | 1000 266262474 628300813 769786402 441383498 484186986 723567466 940642240 21 | 1000 110352529 411439440 118867344 820027764 410584037 105045030 974963387 22 | 1000 29313008 375169227 135772217 28529115 83924639 352208254 982842777 23 | 1000 459715330 501130810 577575662 761703058 366391258 528873045 938942796 24 | 1000 439877045 674412426 88365719 720944764 593519237 622494146 844429447 25 | 1000 164459784 565374209 81049497 898723469 385411789 995041098 949295357 26 | 1000 187223497 697668143 56028582 367224336 973091218 14730443 972504359 27 | 1000 566209460 992915439 976426103 216773334 916411093 2379812 930701145 28 | 1000 140278796 289037769 700773258 435995583 841357022 339859173 981531718 29 | 1000 600548978 822748685 899465724 57125379 396503499 895468734 993888553 30 | 1000 262105786 287839606 985976333 859135343 732186259 66161028 982221799 31 | 1000 19694964 456733741 954341359 652151741 917885354 80946035 986829680 32 | 1000 62586094 348871376 276105028 644371240 123596680 128170092 946147730 33 | 1000 304110441 475411611 809999364 230978168 404737027 324279512 971648040 34 | 1000 7653517 55142560 908697213 693560278 353255692 651404461 946899652 35 | 1000 140535925 834996180 611201312 110205601 975311356 248440541 932552527 36 | 1000 334188374 921411473 955332558 388472884 16581108 862482734 944855746 37 | 1000 24642622 998041333 859095368 812843672 419808410 574445130 952629548 38 | 1000 205072304 413823218 664988198 495028229 996564056 209754889 975400156 39 | 1000 636667549 678201228 383261331 27290862 965153481 609382711 945647881 40 | 1000 517946350 972938742 390538189 854695546 366222472 59837307 982410008 41 | 1000 321497817 631904998 84518490 809986614 761347591 903294103 975677723 42 | 1000 72898102 211172132 488269818 274994160 233377913 928237751 962660123 43 | 474413 178622196 282196639 217454409 333993639 370687882 713045549 967750417 44 | 499455 266879862 704083174 621464846 139064822 53955913 968627703 913718057 45 | 495531 531547564 796245442 751099374 470238435 828072769 400273742 903386330 46 | 497006 227854771 935344149 201903631 337516161 880867662 309656832 943868603 47 | 500000 140747090 893149084 11836941 267259828 333735916 794529350 995166050 48 | 500000 66992513 426795422 386566889 671424446 621988107 556974781 984598569 49 | 500000 503580429 508539367 197990654 368399284 940181094 104854259 927618673 50 | 500000 504901682 973731461 636434916 384077141 224831334 730235134 951129510 51 | 500000 32185262 326226781 850130543 151076481 20906307 862105217 977403603 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Google Kick Start](https://codingcompetitions.withgoogle.com/kickstart) 2 | 3 | Previously known as [Google Code Jam Kickstart](https://code.google.com/codejam/kickstart/) 4 | and [Google APAC University Graduates Test](https://code.google.com/codejam/apactest) 5 | 6 | ## [2019](2019) 7 | 8 | Note: F-strings are not supported on the new platform, 9 | as it [uses Python 3.5](https://code.google.com/codejam/resources/faq#language-details). 10 | 11 | ### [Practice Round](https://codingcompetitions.withgoogle.com/kickstart/round/0000000000051060) 12 | 13 | - Mural (See [2018 Round H Problem B](2018/Round%20H/Problem%20B)) 14 | 15 | ### [Round A](2019/Round%20A) 16 | 17 | - [Training](2019/Round%20A/Training) 18 | 19 | ## [2018](2018) 20 | 21 | ### [Practice Round](https://code.google.com/codejam/contest/4374486/dashboard) 22 | 23 | - Problem A. GBus count (See [2014 Round D Problem B](2014/Round%20D/Problem%20B)) 24 | 25 | ### [Round H](2018/Round%20H) 26 | 27 | - [Problem A. Big Buttons](2018/Round%20H/Problem%20A) 28 | - [Problem B. Mural](2018/Round%20H/Problem%20B) 29 | 30 | ## [2017](2017) 31 | 32 | ### [Practice Round](https://code.google.com/codejam/contest/6304486/dashboard) 33 | 34 | - Problem A. Country Leader (See [2016 Round A Problem A](2016/Round%20A/Problem%20A)) 35 | - Problem B. Vote (See [2016 Round D Problem A](2016/Round%20D/Problem%20A)) 36 | - Problem C. Sherlock and Parentheses (See [2016 Round B Problem A](2016/Round%20B/Problem%20A)) 37 | 38 | ### [Round A](2017/Round%20A) 39 | 40 | - [Problem A. Square Counting](2017/Round%20A/Problem%20A) 41 | 42 | ### [Round B](2017/Round%20B) 43 | 44 | - [Problem A. Math Encoder](2017/Round%20B/Problem%20A) 45 | 46 | ### [Practice Round 2](https://code.google.com/codejam/contest/12254486/dashboard) 47 | 48 | - Problem A. Diwali lightings (See [2016 Round E Problem A](2016/Round%20E/Problem%20A)) 49 | - Problem B. Safe Squares (See [2016 Round C Problem B](2016/Round%20C/Problem%20B)) 50 | - Problem C. Beautiful Numbers (See [2016 Round E Problem B](2016/Round%20E/Problem%20B)) 51 | - Problem D. Watson and Intervals (See [2016 Round B Problem C](2016/Round%20B/Problem%20C)) 52 | 53 | ## [2016](2016) 54 | 55 | ### [Practice Round](https://code.google.com/codejam/contest/5254486/dashboard) 56 | 57 | - Problem A. Lazy Spelling Bee (See [2015 Round E Problem A](2015/Round%20E/Problem%20A)) 58 | 59 | ### [Round A](2016/Round%20A) 60 | 61 | - [Problem A. Country Leader](2016/Round%20A/Problem%20A) 62 | 63 | ### [Round B](2016/Round%20B) 64 | 65 | - [Problem A. Sherlock and Parentheses](2016/Round%20B/Problem%20A) 66 | - [Problem C. Watson and Intervals](2016/Round%20B/Problem%20C) 67 | 68 | ### [Round C](2016/Round%20C) 69 | 70 | - [Problem B. Safe Squares](2016/Round%20C/Problem%20B) 71 | 72 | ### [Round D](2016/Round%20D) 73 | 74 | - [Problem A. Vote](2016/Round%20D/Problem%20A) 75 | 76 | ### [Round E](2016/Round%20E) 77 | 78 | - [Problem A. Diwali lightings](2016/Round%20E/Problem%20A) 79 | - [Problem B. Beautiful Numbers](2016/Round%20E/Problem%20B) 80 | 81 | ## [2015](2015) 82 | 83 | ### [Round E](2015/Round%20E) 84 | 85 | - [Problem A. Lazy Spelling Bee](2015/Round%20E/Problem%20A) 86 | 87 | ## [2014](2014) 88 | 89 | ### [Round A](2014/Round%20A) 90 | 91 | - [Problem A. Seven-segment Display](2014/Round%20A/Problem%20A) 92 | - [Problem B. Super 2048](2014/Round%20A/Problem%20B) 93 | - [Problem C. Addition](2014/Round%20A/Problem%20C) 94 | - [Problem D. Cut Tiles](2014/Round%20A/Problem%20D) 95 | 96 | ### [Round D](2014/Round%20D) 97 | 98 | - [Problem B. GBus count](2014/Round%20D/Problem%20B) 99 | -------------------------------------------------------------------------------- /2014/Round A/Problem D/D-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 6 6 2 1 1 1 1 1 3 | 8 6 2 2 1 1 1 1 1 1 4 | 8 5 2 2 1 1 1 1 1 1 5 | 20 7 2 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 9 6 2 2 2 2 2 2 2 2 2 7 | 9 12 2 2 2 2 2 2 2 2 2 8 | 2 1 0 0 9 | 1 192 5 10 | 5 151 4 6 5 4 3 11 | 4 134217728 21 7 5 27 12 | 9 201 2 6 4 3 4 3 3 4 4 13 | 5 267 4 8 4 0 2 14 | 9 406 0 3 0 0 5 1 3 8 8 15 | 7 2 0 0 1 0 1 1 1 16 | 9 241 5 3 7 5 5 5 2 0 7 17 | 7 259 3 2 5 7 3 6 1 18 | 7 5 2 0 0 2 2 2 0 19 | 5 435 7 3 3 3 6 20 | 5 277 3 5 0 4 8 21 | 5 2 1 1 0 1 1 22 | 6 3 1 0 0 1 0 1 23 | 6 128 4 1 1 2 6 1 24 | 6 4 0 2 0 0 1 1 25 | 5 134217728 6 18 21 20 25 26 | 5 4 0 0 1 1 2 27 | 6 168 5 2 2 7 6 3 28 | 5 183 6 5 7 4 4 29 | 6 8 3 3 2 0 0 1 30 | 5 3 1 1 1 0 1 31 | 6 383 3 2 5 0 2 3 32 | 7 2048 10 9 2 7 2 3 6 33 | 8 1 0 0 0 0 0 0 0 0 34 | 9 434 5 8 8 3 4 1 2 2 2 35 | 8 310 2 8 5 0 8 8 2 8 36 | 9 312 5 3 6 3 5 1 8 1 6 37 | 9 404 2 8 4 8 5 3 1 6 0 38 | 6 2 0 0 1 0 0 0 39 | 8 193 7 1 4 6 4 4 4 6 40 | 6 238 1 0 1 6 2 2 41 | 7 5 0 0 2 2 0 2 1 42 | 9 433 4 3 3 5 2 3 3 4 0 43 | 8 8 2 1 1 0 1 3 0 3 44 | 7 2 1 1 0 1 0 1 1 45 | 6 64 5 2 3 1 4 5 46 | 5 256 2 7 6 1 6 47 | 9 1 0 0 0 0 0 0 0 0 0 48 | 6 281 5 0 6 6 3 7 49 | 8 131072 16 11 7 2 11 6 16 1 50 | 6 253 7 7 7 6 3 6 51 | 6 1 0 0 0 0 0 0 52 | 13 2 0 1 1 0 1 0 0 0 1 0 1 1 0 53 | 10 5 1 0 1 1 1 0 2 2 1 1 54 | 18 536870912 7 13 16 27 29 4 27 17 7 28 29 27 28 27 22 15 9 26 55 | 11 319 1 2 4 5 6 5 6 5 4 3 6 56 | 19 194 1 6 5 6 7 0 6 7 4 0 3 7 4 7 6 0 2 5 7 57 | 10 369 3 6 0 4 5 6 4 4 6 0 58 | 16 210 0 4 3 5 4 3 4 5 0 7 0 3 4 4 2 0 59 | 12 132 5 2 7 1 1 4 6 6 5 7 7 7 60 | 10 5 2 2 2 0 2 2 0 2 0 2 61 | 18 64 4 0 6 4 2 5 0 0 1 6 4 1 1 5 4 2 2 6 62 | 10 157 1 4 7 7 1 6 2 2 5 5 63 | 12 3 1 0 1 0 1 1 0 1 0 0 1 1 64 | 19 134217728 22 19 25 1 25 19 24 0 27 24 4 25 24 14 9 12 27 23 20 65 | 16 324 4 1 6 2 2 3 2 6 5 2 3 0 1 5 3 5 66 | 19 399 2 6 5 4 7 6 7 1 7 3 2 0 1 8 7 3 6 1 0 67 | 14 5 2 0 2 1 0 1 0 2 1 1 1 0 2 0 68 | 11 1 0 0 0 0 0 0 0 0 0 0 0 69 | 19 5 0 2 1 0 1 1 2 0 2 0 1 0 1 1 0 0 1 2 2 70 | 13 185 6 2 6 3 5 5 7 4 7 7 7 6 7 71 | 13 67108864 10 0 25 23 13 22 10 17 4 3 5 17 20 72 | 15 4 0 2 1 1 0 2 2 2 0 0 1 0 1 2 1 73 | 15 1048576 19 19 3 18 18 17 20 18 10 8 13 9 18 20 11 74 | 15 230 7 4 4 6 7 0 3 2 5 5 4 7 1 3 7 75 | 18 184 2 3 1 3 5 5 1 2 0 5 4 0 2 3 2 2 7 2 76 | 16 461 7 1 0 5 5 7 1 4 6 0 4 2 2 1 2 2 77 | 20 159 1 7 3 7 5 0 0 6 7 7 2 6 6 0 7 2 6 4 6 1 78 | 20 150 6 1 3 6 1 2 2 5 1 1 6 0 3 5 7 4 6 5 3 7 79 | 20 137 3 2 7 6 4 1 0 6 5 6 1 0 1 3 3 0 0 1 3 3 80 | 20 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81 | 20 5 1 2 1 0 1 1 0 0 0 0 0 1 2 0 2 0 0 2 2 0 82 | 20 352 4 5 7 7 5 4 6 6 6 5 3 2 3 6 5 4 7 2 8 3 83 | 20 2 0 0 1 1 0 0 0 1 0 1 0 1 1 1 0 1 0 0 0 1 84 | 20 163 1 6 0 5 7 5 3 2 6 0 5 3 6 7 3 0 7 3 2 1 85 | 20 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 86 | 20 64 4 5 1 4 1 2 3 4 0 0 4 4 6 6 0 1 1 3 3 5 87 | 20 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 88 | 20 178 1 3 5 6 7 2 4 4 3 6 0 2 6 5 5 4 7 6 6 5 89 | 20 298 8 8 8 8 0 6 8 0 5 1 0 3 7 8 7 7 0 7 5 1 90 | 20 232 3 0 4 4 6 6 0 5 7 4 3 6 1 1 4 6 0 3 7 7 91 | 20 208 1 0 1 1 3 1 7 6 2 4 6 2 1 7 4 5 2 3 6 4 92 | 20 2 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 0 93 | 20 221 6 1 7 2 1 4 2 6 6 0 2 4 7 2 3 5 5 1 2 5 94 | 20 356 4 0 0 3 6 3 7 8 0 1 4 4 0 2 3 5 6 7 0 6 95 | 20 452 5 4 8 5 8 8 4 4 6 6 5 1 3 8 1 5 7 8 0 6 96 | 20 178 4 6 0 4 6 4 2 0 7 5 6 3 0 2 5 0 0 7 7 4 97 | 20 5 2 2 1 1 0 2 0 1 0 1 2 0 2 2 2 0 0 0 2 1 98 | 20 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99 | 20 386 8 1 5 0 7 2 8 6 4 7 5 8 1 7 5 2 8 3 5 0 100 | 20 16777216 22 5 4 13 6 21 10 6 21 23 23 11 2 2 11 7 1 21 9 20 101 | 20 3 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 102 | -------------------------------------------------------------------------------- /2017/Round B/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Math Encoder: 2 | https://code.google.com/codejam/contest/11304486/dashboard#s=p0 3 | 4 | ========================== 5 | `Problem A. Math Encoder`_ 6 | ========================== 7 | 8 | Problem 9 | ------- 10 | Professor Math is working on a secret project and is facing a challenge where 11 | a list of numbers need to be encoded into a single number in the most 12 | efficient manner. After much research, Professor Math finds a 3 step process 13 | that can best encode the numbers: 14 | 15 | 1. The first step is to find all possible non-empty subsets of the list of 16 | numbers and then, for each subset, find the difference between the largest 17 | and smallest numbers (that is, the largest minus the smallest) in that 18 | subset. Note that if there is only one number in a subset, it is both the 19 | largest and the smallest number in that subset. The complete set itself is 20 | also considered a subset. 21 | 2. Then add up all the differences to get the final encoded number. 22 | 3. As the number may be large, output the number modulo 23 | |10^9| + 7 (1000000007). 24 | 25 | .. |10^9| replace:: 10\ :sup:`9` 26 | 27 | The professor has shared an example and its explanation below. 28 | Given a list of numbers, can you help the professor build an efficient 29 | function to compute the final encoded number? 30 | 31 | Input 32 | ----- 33 | The first line of the input gives the number of test cases, **T**. 34 | This is followed by T test cases where each test case is defined by 2 lines: 35 | 36 | 1. The first line gives a positive number **N**: 37 | the number of numbers in the list and 38 | 2. The second line contains a list of **N** positive integers |Ki|, 39 | sorted in non-decreasing order. 40 | 41 | .. |Ki| raw:: html 42 | 43 | Ki 44 | 45 | Output 46 | ------ 47 | For each test case, output one line containing ``Case #x: y``, 48 | where ``x`` is the test case number (starting from 1) 49 | and ``y`` is the final encoded number. 50 | 51 | Since the output can be a really big number, we only ask you to output 52 | the remainder of dividing the result by the prime |10^9| + 7 (1000000007). 53 | 54 | Limits 55 | ------ 56 | | 1 ≤ **T** ≤ 25. 57 | | 1 ≤ |Ki| ≤ 10000, for all i. 58 | | |Ki| ≤ |Ki+1|, for all i < **N** - 1. 59 | 60 | .. |Ki+1| raw:: html 61 | 62 | Ki+1 63 | 64 | Small dataset 65 | ------------- 66 | 1 ≤ **N** ≤ 10. 67 | 68 | Large dataset 69 | ------------- 70 | 1 ≤ **N** ≤ 10000. 71 | 72 | Sample 73 | ------ 74 | 75 | :: 76 | 77 | Input Output 78 | 79 | 1 Case #1: 44 80 | 4 81 | 3 6 7 9 82 | 83 | **Explanation for the sample input** 84 | 85 | 1. | Find all subsets and get the difference between largest & smallest numbers: 86 | | [3], largest-smallest = 3 - 3 = 0. 87 | | [6], largest-smallest = 6 - 6 = 0. 88 | | [7], largest-smallest = 7 - 7 = 0. 89 | | [9], largest-smallest = 9 - 9 = 0. 90 | | [3, 6], largest-smallest = 6 - 3 = 3. 91 | | [3, 7], largest-smallest = 7 - 3 = 4. 92 | | [3, 9], largest-smallest = 9 - 3 = 6. 93 | | [6, 7], largest-smallest = 7 - 6 = 1. 94 | | [6, 9], largest-smallest = 9 - 6 = 3. 95 | | [7, 9], largest-smallest = 9 - 7 = 2. 96 | | [3, 6, 7], largest-smallest = 7 - 3 = 4. 97 | | [3, 6, 9], largest-smallest = 9 - 3 = 6. 98 | | [3, 7, 9], largest-smallest = 9 - 3 = 6. 99 | | [6, 7, 9], largest-smallest = 9 - 6 = 3. 100 | | [3, 6, 7, 9], largest-smallest = 9 - 3 = 6. 101 | 2. | Find the sum of the differences calculated in the previous step: 102 | | 3+4+6+1+3+2+4+6+6+3+6 103 | | = 44. 104 | 3. | Find the answer modulo |10^9| + 7 (1000000007): 105 | | 44 % 1000000007 = 44 106 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem B. Mural: 2 | https://codejam.withgoogle.com/codejam/contest/3324486/dashboard#s=p1 3 | 4 | =================== 5 | `Problem B. Mural`_ 6 | =================== 7 | 8 | Problem 9 | ------- 10 | Thanh wants to paint a wonderful mural on a wall that is **N** sections long. 11 | Each section of the wall has a *beauty score*, which indicates how beautiful 12 | it will look if it is painted. Unfortunately, the wall is starting to crumble 13 | due to a recent flood, so he will need to work fast! 14 | 15 | At the beginning of each day, Thanh will paint one of the sections of the 16 | wall. On the first day, he is free to paint any section he likes. On each 17 | subsequent day, he must paint a new section that is next to a section he has 18 | already painted, since he does not want to split up the mural. 19 | 20 | At the end of each day, one section of the wall will be destroyed. 21 | It is always a section of wall that is adjacent to only one other section and 22 | is unpainted (Thanh is using a waterproof paint, so painted sections can't be 23 | destroyed). 24 | 25 | The *total beauty* of Thanh's mural will be equal to the sum of the beauty 26 | scores of the sections he has painted. Thanh would like to guarantee that, 27 | no matter how the wall is destroyed, he can still achieve a total beauty of 28 | at least B. 29 | What's the maximum value of B for which he can make this guarantee? 30 | 31 | Input 32 | ----- 33 | The first line of the input gives the number of test cases, **T**. 34 | **T** test cases follow. 35 | Each test case starts with a line containing an integer **N**. 36 | Then, another line follows containing a string of **N** digits from 0 to 9. 37 | The i-th digit represents the beauty score of the i-th section of the wall. 38 | 39 | Output 40 | ------ 41 | For each test case, output one line containing ``Case #x: y``, 42 | where ``x`` is the test case number (starting from 1) and ``y`` is 43 | the maximum beauty score that Thanh can guarantee that he can achieve, 44 | as described above. 45 | 46 | Limits 47 | ------ 48 | 1 ≤ **T** ≤ 100. 49 | 50 | Small dataset 51 | ------------- 52 | 2 ≤ **N** ≤ 100. 53 | 54 | Large dataset 55 | ------------- 56 | For exactly 1 case, **N** = 5 × 10\ :sup:`6`; 57 | for the other **T** - 1 cases, 2 ≤ **N** ≤ 100. 58 | 59 | Sample 60 | ------ 61 | 62 | :: 63 | 64 | Input Output 65 | 66 | 4 Case #1: 6 67 | 4 Case #2: 14 68 | 1332 Case #3: 7 69 | 4 Case #4: 31 70 | 9583 71 | 3 72 | 616 73 | 10 74 | 1029384756 75 | 76 | In the first sample case, Thanh can get a total beauty of 6, no matter how 77 | the wall is destroyed. On the first day, he can paint either section of wall 78 | with beauty score 3. At the end of the day, either the 1st section or 79 | the 4th section will be destroyed, but it does not matter which one. 80 | On the second day, he can paint the other section with beauty score 3. 81 | 82 | In the second sample case, Thanh can get a total beauty of 14, 83 | by painting the leftmost section of wall (with beauty score 9). 84 | The only section of wall that can be destroyed is the rightmost one, 85 | since the leftmost one is painted. On the second day, 86 | he can paint the second leftmost section with beauty score 5. 87 | Then the last unpainted section of wall on the right is destroyed. 88 | Note that on the second day, Thanh cannot choose to paint the third section of 89 | wall (with beauty score 8), since it is not adjacent to any other painted 90 | sections. 91 | 92 | In the third sample case, Thanh can get a total beauty of 7. 93 | He begins by painting the section in the middle (with beauty score 1). 94 | Whichever section is destroyed at the end of the day, 95 | he can paint the remaining wall at the start of the second day. 96 | -------------------------------------------------------------------------------- /2014/Round A/Problem C/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem C. Addition: 2 | https://code.google.com/codejam/contest/3214486/dashboard#s=p2 3 | 4 | ====================== 5 | `Problem C. Addition`_ 6 | ====================== 7 | 8 | Problem 9 | ------- 10 | Six years ago, a robot, Bob, with infant's intelligence has been [sic] 11 | invented by an evil scientist, Alice. 12 | 13 | Now the robot is six years old and studies in primary school. 14 | Addition is the first operation he learned in math. 15 | Due to his strong reasoning ability, 16 | he could now conclude a+b=12 from a=2 and b=10. 17 | 18 | Alice wanted to test Bob's addition skills. 19 | Some equations were given to Bob in form [sic] of a=2, b=10, c=4, 20 | and Bob has to find out the answers of questions like a+b, a+c, etc. 21 | 22 | Alice checked Bob's answers one by one in the test papers, 23 | and no mistake has been found so far, 24 | but Alice lost the given equations after a cup of coffee poured on them [sic]. 25 | However she has some of Bob's correct answers, e.g. a+b=12, a+c=6, c+d=5. 26 | She wants to continue with the checkable equations, 27 | e.g. b+d=11 could be concluded by a+b=12, a+c=6, c+d=5, 28 | and thus the question b+d is checkable. 29 | 30 | To prevent the artificial intelligence technology from being under the control 31 | of Alice, you disguised yourself as her assistant. Now Alice wants you to 32 | figure out which of the rest of questions [sic] are checkable and their 33 | answers [sic]. 34 | 35 | Input 36 | ----- 37 | The first line of the input gives the number of test cases, **T**. 38 | **T** test cases follow. 39 | 40 | The first line of each test case contains a single integer **N**: 41 | the number of correctly answered questions. 42 | Each of the next **N** lines contain [sic] one correctly answered question 43 | in the form "**x**\ +\ **y**\ =\ **z**", 44 | where **x** and **y** are names of variables and **z** is a decimal integer. 45 | 46 | The next line contains a single integer **Q**: 47 | the number of remaining questions. 48 | Each of the next **Q** lines contain [sic] one question in the form 49 | "**x**\ +\ **y**", where **x** and **y** are names of variables. 50 | 51 | Output 52 | ------ 53 | For each test case, the first line of output contains "Case #\ **x**:", 54 | where **x** is the test case number (starting from 1). 55 | For each question in the input that was checkable, 56 | output a single line with the answer in the form "**x**\ +\ **y**\ =\ **z**", 57 | where **x** and **y** are names of variables and **z** is a decimal integer. 58 | Questions should be listed in the same order as they were given in the input. 59 | Please do **NOT** ignore duplicated questions, 60 | since Alice would fire you if you pointed [sic] any mistake of hers. 61 | 62 | Limits 63 | ------ 64 | Names of variables are strings of lowercase English letters. 65 | Each name contains at most 10 characters. 66 | 67 | -200000 ≤ **z** ≤ 200000 68 | 69 | There is no contradiction in the answered questions 70 | and if the answer is checkable, the result is an integer. 71 | 72 | Small dataset 73 | ------------- 74 | **T** ≤ 10 75 | 76 | **N** ≤ 10 77 | 78 | **Q** ≤ 10 79 | 80 | Large dataset 81 | ------------- 82 | **T** ≤ 3 83 | 84 | **N** ≤ 5000 85 | 86 | **Q** ≤ 5000 87 | 88 | Sample 89 | ------ 90 | 91 | :: 92 | 93 | Input Output 94 | 95 | 2 Case #1: 96 | 2 apple+banana=10 97 | apple+banana=10 apple+banana=10 98 | coconut+coconut=12 banana+apple=10 99 | 5 Case #2: 100 | apple+banana a+d=3 101 | apple+banana b+c=3 102 | apple+apple 103 | banana+apple 104 | peach+apple 105 | 3 106 | a+b=3 107 | b+c=3 108 | c+d=3 109 | 4 110 | a+c 111 | a+d 112 | b+c 113 | b+d 114 | -------------------------------------------------------------------------------- /2018/Round H/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Big Buttons: 2 | https://codejam.withgoogle.com/codejam/contest/3324486/dashboard#s=p0 3 | 4 | ========================= 5 | `Problem A. Big Buttons`_ 6 | ========================= 7 | 8 | Problem 9 | ------- 10 | You are a contestant on a popular new game show 11 | and are playing for the grand prize! 12 | 13 | There are two big buttons, a red one and a black one. 14 | You will make a sequence of exactly **N** button presses. 15 | 16 | There are lots of different sequences of presses you could make, 17 | but there are **P** forbidden prefixes, each of length no greater than **N**. 18 | If you make a sequence of presses which begins with *any* of the forbidden 19 | sequences, you will not win the grand prize. It is fine for your sequence to 20 | contain one or more forbidden prefixes as long as they do not appear at the 21 | start of your sequence. 22 | 23 | A *winning* sequence must consist of exactly **N** button presses and must not 24 | begin with one of the forbidden prefixes. 25 | How many different winning sequences are there? 26 | 27 | Input 28 | ----- 29 | The first line of the input gives the number of test cases, **T**. **T** test 30 | cases follow. Each test case starts with a line containing two integers **N** 31 | and **P**, as described above. Then, there are **P** more lines, each of which 32 | contains a string of between 1 and **N** characters, inclusive, describing one 33 | of the forbidden sequences of presses. An ``R`` represents pressing the red 34 | button, whereas a ``B`` represents pressing the black button. 35 | 36 | Output 37 | ------ 38 | For each test case, output one line containing ``Case #x: y``, 39 | where ``x`` is the test case number (starting from 1) 40 | and ``y`` is the number of winning sequences, as desribed [sic] above. 41 | 42 | Limits 43 | ------ 44 | | 1 ≤ **T** ≤ 100. 45 | | 1 ≤ **P** ≤ min(2\ |N|, 100). 46 | | Each forbidden prefix is between 1 and **N** characters long, inclusive. 47 | | No two forbidden prefixes will be the same. 48 | 49 | .. |N| raw:: html 50 | 51 | N 52 | 53 | Small dataset 54 | ------------- 55 | 1 ≤ **N** ≤ 10. 56 | 57 | Large dataset 58 | ------------- 59 | 1 ≤ **N** ≤ 50. 60 | 61 | Sample 62 | ------ 63 | 64 | :: 65 | 66 | Input Output 67 | 68 | 4 Case #1: 5 69 | 3 2 Case #2: 16 70 | BBB Case #3: 0 71 | RB Case #4: 1125556309458944 72 | 5 1 73 | R 74 | 4 3 75 | R 76 | B 77 | RBRB 78 | 50 5 79 | BRBRBBBRBRRRBBB 80 | BRBRBRRRBRRRBRB 81 | BBBRBBBRBRRRBBB 82 | BRBRBRRRBRRRB 83 | BRBRBBBRBBBRB 84 | 85 | Note that the last Sample case would not appear in the Small dataset. 86 | 87 | In the first case, you must make a sequence of 3 presses. 88 | There are 8 possible sequences of three presses, 89 | but some of them will cause you to lose the game. 90 | They are listed below: 91 | 92 | - ``RBB``. This is forbidden since it starts with the first forbidden sequence (``RB``). 93 | - ``RBR``. This is forbidden since it starts with the first forbidden sequence (``RB``). 94 | - ``BBB``. This is forbidden since it starts with the second forbidden sequence (``BBB``). 95 | 96 | Thus, there are only 5 winning sequences. 97 | 98 | In the second case, you must make a sequence of 5 presses. 99 | There is only one forbidden sequence, which is ``R``. 100 | This means that the first press must be ``B``, 101 | and the next 4 presses can be either button. 102 | This gives a total of 16 different button presses. 103 | 104 | In the third case, you must make a sequence of 4 presses. 105 | There are three forbidden sequences, 106 | but since every possible sequence begins with either 107 | ``R`` (the first forbidden sequence) or ``B`` (the second forbidden sequence), 108 | there are no winning sequences. So the answer is 0. 109 | -------------------------------------------------------------------------------- /2014/Round D/Problem B/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem B. GBus count: 2 | https://code.google.com/codejam/contest/6214486/dashboard#s=p1 3 | 4 | ======================== 5 | `Problem B. GBus count`_ 6 | ======================== 7 | 8 | Problem 9 | ------- 10 | There exist some cities that are built along a straight road. 11 | The cities are numbered 1, 2, 3... from left to right. 12 | 13 | There are **N** GBuses that operate along this road. 14 | For each GBus, we know the range of cities that it serves: 15 | the i-th gBus serves the cities with numbers between 16 | **A**\ |i| and **B**\ |i|, inclusive. 17 | 18 | .. |i| raw:: html 19 | 20 | i 21 | 22 | We are interested in a particular subset of **P** cities. 23 | For each of those cities, we need to find out how many GBuses serve that 24 | particular city. 25 | 26 | Input 27 | ----- 28 | 29 | The first line of the input gives the number of test cases, **T**. 30 | Then, **T** test cases follow; each case is separated from the next by one 31 | |blank| line. (Notice that this is unusual for Kickstart data sets.) 32 | 33 | .. |blank| raw:: html 34 | 35 | blank 36 | 37 | In each test case: 38 | 39 | - The first line contains one integer **N**: the number of GBuses. 40 | - The second line contains 2\ **N** integers representing the ranges of cities 41 | that the buses serve, in the form **A**\ |1| **B**\ |1| 42 | **A**\ |2| **B**\ |2| **A**\ |3| **B**\ |3| ... **A**\ |N| **B**\ |N|. 43 | That is, the first GBus serves the cities numbered from 44 | **A**\ |1| to **B**\ |1| (inclusive), and so on. 45 | - The third line contains one integer **P**: the number of cities we are 46 | interested in, as described above. (Note that this is not necessarily the 47 | same as the total number of cities in the problem, which is not given.) 48 | - Finally, there are **P** more lines; the i-th of these contains the number 49 | **C**\ |i| of a city we are interested in. 50 | 51 | .. |1| raw:: html 52 | 53 | 1 54 | 55 | .. |2| raw:: html 56 | 57 | 2 58 | 59 | .. |3| raw:: html 60 | 61 | 3 62 | 63 | .. |N| raw:: html 64 | 65 | N 66 | 67 | Output 68 | ------ 69 | For each test case, output one line containing ``Case #x: y``, where ``x`` is 70 | the number of the test case (starting from 1), and ``y`` is a list of **P** 71 | integers, in which the i-th integer is the number of GBuses that serve city 72 | **C**\ |i|. 73 | 74 | Limits 75 | ------ 76 | 1 ≤ **T** ≤ 10. 77 | 78 | Small dataset 79 | ------------- 80 | | 1 ≤ **N** ≤ 50 81 | | 1 ≤ **A**\ |i| ≤ 500, for all i. 82 | | 1 ≤ **B**\ |i| ≤ 500, for all i. 83 | | 1 ≤ **C**\ |i| ≤ 500, for all i. 84 | | 1 ≤ **P** ≤ 50. 85 | 86 | Large dataset 87 | ------------- 88 | | 1 ≤ **N** ≤ 500. 89 | | 1 ≤ **A**\ |i| ≤ 5000, for all i. 90 | | 1 ≤ **B**\ |i| ≤ 5000, for all i. 91 | | 1 ≤ **C**\ |i| ≤ 5000, for all i. 92 | | 1 ≤ **P** ≤ 500. 93 | 94 | Sample 95 | ------ 96 | 97 | |sample_start| 98 | Input\ |newline| 99 | 2 100 | 4 101 | 15 25 30 35 45 50 10 20 102 | 2 103 | 15 104 | 25\ |newline| 105 | 10 106 | 10 15 5 12 40 55 1 10 25 35 45 50 20 28 27 35 15 40 4 5 107 | 3 108 | 5 109 | 10 110 | 27\ |newline| 111 | |hr|\ Output\ |newline| 112 | Case #1: 2 1 113 | Case #2: 3 3 4\ |newline| 114 | |sample_end| 115 | 116 | .. |sample_start| raw:: html 117 | 118 |
119 | 
120 | .. |newline| raw:: html
121 | 
122 |     
123 | 124 | .. |hr| raw:: html 125 | 126 |
127 | 128 | .. |sample_end| raw:: html 129 | 130 |
131 | 132 | In Sample Case #1, there are four GBuses. 133 | The first serves cities 15 through 25, 134 | the second serves cities 30 through 35, 135 | the third serves cities 45 through 50, 136 | and the fourth serves cities 10 through 20. 137 | City 15 is served by the first and fourth buses, 138 | so the first number in our answer list is 2. 139 | City 25 is served by only the first bus, 140 | so the second number in our answer list is 1. 141 | -------------------------------------------------------------------------------- /2014/Round A/Problem B/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem B. Super 2048: 2 | https://code.google.com/codejam/contest/3214486/dashboard#s=p1 3 | 4 | ======================== 5 | `Problem B. Super 2048`_ 6 | ======================== 7 | 8 | Problem 9 | ------- 10 | 2048 is a famous single-player game in which the objective is to slide tiles 11 | on a grid to combine them and create a tile with the number 2048. 12 | 13 | 2048 is played on a simple 4 x 4 grid with tiles that slide smoothly when a 14 | player moves them. For each movement, the player can choose to move all tiles 15 | in 4 directions, left, right, up, and down, as far as possible at the same 16 | time. If two tiles of the same number collide while moving, they will merge 17 | into a tile with the total value of the two tiles that collided. **In one 18 | movement, one newly created tile can not be merged again and always is merged 19 | with the tile next to it along the moving direction first.** E.g. if the three 20 | "2" are in a row "2 2 2" and the player choose to move left, it will become 21 | "4 2 0", the most left 2 "2" are merged. 22 | 23 | .. image:: https://code.google.com/codejam/contest/images/?image=2048.png&p=5742336445251584&c=3214486 24 | 25 | The above figure shows how 4 x 4 grid varies when player moves all tiles 26 | 'right'. 27 | 28 | Alice and Bob accidentally find this game and love the feel when two tiles are 29 | merged. After a few round [sic], they start to be bored about the size of the 30 | board and decide to extend the size of board to **N** x **N**, which they 31 | called [sic] the game "Super 2048". 32 | 33 | The big board then makes them dazzled (no zuo no die -_-| ). They ask you to 34 | write a program to help them figure out what the board will be looked [sic] 35 | like after all tiles move to one specific direction on a given board. 36 | 37 | Input 38 | ----- 39 | The first line of the input gives the number of test cases, **T**. 40 | **T** test cases follow. The first line of each test case gives the side 41 | length of the board, **N**, and the direction the tiles will move to, **DIR**. 42 | **N** and **DIR** are separated by a single space. 43 | **DIR** will be one of four strings: "left", "right", "up", or "down". 44 | 45 | The next **N** lines each contain **N** space-separated integers describing 46 | the original state of the board. Each line represents a row of the board 47 | (from top to bottom); each integer represents the value of a tile 48 | (or 0 if there is no number at that position). 49 | 50 | Output 51 | ------ 52 | For each test case, output one line containing "Case #x:", 53 | where x is the test case number (starting from 1). 54 | Then output **N** more lines, each containing **N** space-separated integers 55 | which describe the board after the move in the same format as the input. 56 | 57 | Limits 58 | ------ 59 | Each number in the grid is either 0 or a power of two between 2 and 1024, 60 | inclusive. 61 | 62 | Small dataset 63 | ------------- 64 | | 1 ≤ **T** ≤ 20 65 | | 1 ≤ **N** ≤ 4 66 | 67 | Large dataset 68 | ------------- 69 | | 1 ≤ **T** ≤ 100 70 | | 1 ≤ **N** ≤ 20 71 | 72 | Sample 73 | ------ 74 | 75 | :: 76 | 77 | Input Output 78 | 79 | 3 Case #1: 80 | 4 right 0 0 4 4 81 | 2 0 2 4 0 2 4 2 82 | 2 0 4 2 0 4 4 8 83 | 2 2 4 8 0 0 4 8 84 | 2 2 4 4 Case #2: 85 | 10 up 4 0 0 0 0 0 0 0 0 0 86 | 2 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 87 | 2 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 88 | 2 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 89 | 2 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 90 | 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 91 | 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92 | 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 93 | 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 94 | 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 95 | 2 0 0 0 0 0 0 0 0 0 Case #3: 96 | 3 right 0 2 4 97 | 2 2 2 0 4 8 98 | 4 4 4 0 8 16 99 | 8 8 8 100 | -------------------------------------------------------------------------------- /2014/Round A/Problem A/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem A. Seven-segment Display: 2 | https://code.google.com/codejam/contest/3214486/dashboard#s=p0 3 | 4 | =================================== 5 | `Problem A. Seven-segment Display`_ 6 | =================================== 7 | 8 | Problem 9 | ------- 10 | Tom is a boy whose dream is to become a scientist, 11 | he invented a lot in his spare time. 12 | He came up with a great idea several days ago: to make a stopwatch by himself! 13 | So he bought a seven-segment display immediately. 14 | 15 | The seven elements of the display are all light-emitting diodes (LEDs) and 16 | can be lit in different combinations to represent the arabic numerals like: 17 | 18 | .. image:: https://code.google.com/codejam/contest/images/?image=digits_30.png&p=5768691975192576&c=3214486 19 | 20 | However, just when he finished the programs and tried to test the stopwatch, 21 | some of the LEDs turned out to be broken! 22 | Some of the segments can never be lit while others worked fine. 23 | So the display kept on producing some ambiguous states all the time... 24 | 25 | Tom has recorded a continuous sequence of states which were produced by the 26 | display and is curious about whether it is possible to understand what this 27 | display was doing. He thinks the first step is to determine the state which 28 | the display will show **next**, could you help him? 29 | 30 | Please note that the display works well despite those broken segments, 31 | which means that the display will keep on counting down **cyclically** 32 | starting from a certain number 33 | (can be any one of 0-9 since we don't know where this record starts from). 34 | 'Cyclically' here means that each time when the display reaches 0, 35 | it will keep on counting down starting from 9 again. 36 | 37 | For convenience, we refer [sic] the seven segments of the display by 38 | the letters A to G as the picture below: 39 | 40 | .. image:: https://code.google.com/codejam/contest/images/?image=marks_40.png&p=5768691975192576&c=3214486 41 | 42 | For example, if the record of states is like: 43 | 44 | .. image:: https://code.google.com/codejam/contest/images/?image=example_in_30.png&p=5768691975192576&c=3214486 45 | 46 | It's not that hard to figure out that ONLY segment B is broken 47 | and the sequence of states the display is trying to produce is simply 48 | "9 -> 8 -> 7 -> 6 -> 5". Then the next number should be 4, 49 | but considering of [sic] the brokenness of segment B, 50 | the next state should be: 51 | 52 | .. image:: https://code.google.com/codejam/contest/images/?image=example_out_30.png&p=5768691975192576&c=3214486 53 | 54 | Input 55 | ----- 56 | The first line of the input gives the number of test cases, **T**. 57 | Each test case is a line containing an integer **N** 58 | which is the number of states Tom recorded 59 | and a list of the **N** states separated by spaces. 60 | Each state is encoded into a 7-character string represent [sic] 61 | the display of segment A-G, from the left to the right. 62 | Characters in the string can either be '1' or '0', 63 | denoting the corresponding segment is on or off, respectively. 64 | 65 | Output 66 | ------ 67 | For each test case, output one line containing "Case #x: y", 68 | where x is the test case number (starting from 1). 69 | If the input unambiguously determines the next state of the display, 70 | y should be that next state (in the same format as the input). 71 | Otherwise, y should be "ERROR!". 72 | 73 | Limits 74 | ------ 75 | 1 ≤ **T** ≤ 2000. 76 | 77 | Small dataset 78 | ------------- 79 | 1 ≤ **N** ≤ 5. 80 | 81 | Large dataset 82 | ------------- 83 | 1 ≤ **N** ≤ 100. 84 | 85 | Sample 86 | ------ 87 | 88 | |sample_start| 89 | Input\ |newline| 90 | 4 91 | 1 1111111 92 | 2 0000000 0001010 93 | 3 0100000 0000111 0000011 94 | 5 1011011 1011111 1010000 1011111 1011011 95 | |hr|\ Output\ |newline| 96 | Case #1: 1110000 97 | Case #2: ERROR! 98 | Case #3: 0100011 99 | Case #4: 0010011\ |newline| 100 | |sample_end| 101 | 102 | .. |sample_start| raw:: html 103 | 104 |
105 | 
106 | .. |newline| raw:: html
107 | 
108 |     
109 | 110 | .. |hr| raw:: html 111 | 112 |
113 | 114 | .. |sample_end| raw:: html 115 | 116 |
117 | -------------------------------------------------------------------------------- /2016/Round B/Problem C/README.rst: -------------------------------------------------------------------------------- 1 | .. _Problem C. Watson and Intervals: 2 | https://code.google.com/codejam/contest/5254487/dashboard#s=p2 3 | 4 | ================================== 5 | `Problem C. Watson and Intervals`_ 6 | ================================== 7 | 8 | Problem 9 | ------- 10 | Sherlock and Watson have mastered the intricacies of the language C++ in their 11 | programming course, so they have moved on to algorithmic problems. In today's 12 | class, the tutor introduced the problem of merging one-dimensional intervals. 13 | **N** intervals are given, and the ``i``\ th interval is defined by the 14 | inclusive endpoints [**L**\ |i|\ **, R**\ |i|], where **L**\ |i| **≤ R**\ |i|. 15 | 16 | .. |i| raw:: html 17 | 18 | i 19 | 20 | The tutor defined the *covered area* of a set of intervals as the number of 21 | integers appearing in at least one of the intervals. (Formally, an integer p 22 | contributes to the covered area if there is some j such that 23 | **L**\ |j| ≤ ``p`` ≤ **R**\ |j|.) 24 | 25 | .. |j| raw:: html 26 | 27 | j 28 | 29 | Now, Watson always likes to challenge Sherlock. He has asked Sherlock to 30 | remove exactly one interval such that the covered area of the remaining 31 | intervals is minimized. Help Sherlock find this minimum possible covered area, 32 | after removing exactly one of the **N** intervals. 33 | 34 | Input 35 | ----- 36 | Each test case consists of one line with eight integers **N**, 37 | **L**\ |1|\ **, R**\ |1|, **A**, **B**, **C**\ |1|, **C**\ |2|, and **M**. 38 | **N** is the number of intervals, and the other seven values are parameters 39 | that you should use to generate the other intervals, as follows: 40 | 41 | .. |1| raw:: html 42 | 43 | 1 44 | 45 | .. |2| raw:: html 46 | 47 | 2 48 | 49 | First define |x_1| = **L**\ |1| and |y_1| = **R**\ |1|. 50 | Then, use the recurrences below to generate |x_i, y_i| for 51 | ``i`` = 2 to **N**: 52 | 53 | .. |x_1| raw:: html 54 | 55 | x1 56 | 57 | .. |y_1| raw:: html 58 | 59 | y1 60 | 61 | .. |x_i, y_i| raw:: html 62 | 63 | xi, yi 64 | 65 | - |x_i| = ( **A**\*\ |x_i-1| + **B**\*\ |y_i-1| + **C**\ |1| ) modulo **M**. 66 | - |y_i| = ( **A**\*\ |y_i-1| + **B**\*\ |x_i-1| + **C**\ |2| ) modulo **M**. 67 | 68 | .. |x_i| raw:: html 69 | 70 | xi 71 | 72 | .. |y_i| raw:: html 73 | 74 | yi 75 | 76 | .. |x_i-1| raw:: html 77 | 78 | xi-1 79 | 80 | .. |y_i-1| raw:: html 81 | 82 | yi-1 83 | 84 | We define **L**\ |i| = |min(x_i, y_i)| and **R**\ |i| = |max(x_i, y_i)|, 85 | for all ``i`` = 2 to **N**. 86 | 87 | .. |min(x_i, y_i)| raw:: html 88 | 89 | min(xi, yi) 90 | 91 | .. |max(x_i, y_i)| raw:: html 92 | 93 | max(xi, yi) 94 | 95 | Output 96 | ------ 97 | For each test case, output one line containing ``Case #x: y``, where ``x`` is 98 | the test case number (starting from 1) and ``y`` is the minimum possible 99 | covered area of all of the intervals remaining after removing exactly one 100 | interval. 101 | 102 | Limits 103 | ------ 104 | | 1 ≤ **T** ≤ 50. 105 | | 0 ≤ **L**\ |1| ≤ **R**\ |1| ≤ |10^9|. 106 | | 0 ≤ **A** ≤ |10^9|. 107 | | 0 ≤ **B** ≤ |10^9|. 108 | | 0 ≤ **C**\ |1| ≤ |10^9|. 109 | | 0 ≤ **C**\ |2| ≤ |10^9|. 110 | | 1 ≤ **M** ≤ |10^9|. 111 | 112 | .. |10^9| replace:: 10\ :sup:`9` 113 | 114 | Small dataset 115 | ------------- 116 | 1 ≤ **N** ≤ 1000. 117 | 118 | Large dataset 119 | ------------- 120 | 1 ≤ **N** ≤ 5 * 10\ :sup:`5`\ (500000). 121 | 122 | Sample 123 | ------ 124 | 125 | :: 126 | 127 | Input Output 128 | 129 | 3 Case #1: 0 130 | 1 1 1 1 1 1 1 1 Case #2: 4 131 | 3 2 5 1 2 3 4 10 Case #3: 9 132 | 4 3 4 3 3 8 10 10 133 | 134 | In case 1, using the generation method, the set of intervals generated are: 135 | {[1, 1]}. Removing the only interval, the covered area is 0. 136 | 137 | In case 2, using the generation method, the set of intervals generated are: 138 | {[2, 5], [3, 5], [4, 7]}. Removing the first, second or third interval would 139 | cause the covered area of remaining intervals to be 5, 6 and 4, respectively. 140 | 141 | In case 3, using the generation method, the set of intervals generated are: 142 | {[3, 4], [1, 9], [0, 8], [2, 4]}. Removing the first, second, third or fourth 143 | interval would cause the covered area of remaining intervals to be 144 | 10, 9, 9 and 10, respectively. 145 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/A-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | BBBRRBBRBBBRRBRRRRBRRBRBBBRRRR 3 | 4391 998016 4 | BRRRRRBRRRRBRRRRRRRRRRRBBRRRRRRRRRRRRBRRR 5 | 8125 997021 6 | RR 7 | 3031 995356 8 | RBBRRBRRRRRRBRRRRRRRRBRBRBRBRBBRRRBRRBRBBRRRBRRRRRRRBRRRRR 9 | 9911 990469 10 | B 11 | 1 1000000 12 | RRBBBBRBRBBRRBRRRRRRRBBRRRRRRRRBRRRRRR 13 | 4214 996987 14 | RBRRBRBRRBBRRBR 15 | 8502 996266 16 | RRBRBRRBRBRBBBBBBRRBBRRRRBBRRRRB 17 | 3925 997632 18 | BBRRBRBRBRBBBRRRBBRRBRRRRRRRRBRR 19 | 2108 996534 20 | BRBBBRRRBBBBRRRRRRBBRRRBRBRBBBRRBBBRBRRRBBRRBBRBBBBBBBBBBBRRRBRBRRRBRRBBBRRBBRBBRR 21 | 7275 994035 22 | RRRBBBRBBR 23 | 4787 996983 24 | RRRRRRBRRRRRRRRRRRRRRRRRRRRRBRRRRRBRRRRRRRBRRRRRRRRBBRRRRRRRRRRRRRRRRRRRRBRRRRRRBRRR 25 | 7587 998450 26 | BRRRRBBBBBBBRBRRRBRRBBRBBRRBRBRRBRBBRRRB 27 | 3721 999360 28 | BBBBBRBBBBBBBRBBBBBBBBRBBBBBBBBBBBBBBBBBBBBRBBBBBRBBBBBBRRBBBBRBBBBBBRBRBBRBBBRRBBBBRBRBBRBBBB 29 | 4840 995605 30 | BBRBBRBBBBBBBBRBRBRRRRBBBRBRBBRBBBBRRRBBBBBBBBBBBRRBRBBBRRRRBBBRRRBBBBRRRRRBRRBRRRBBRBBBRBBRBB 31 | 7723 995313 32 | RRBRRRBRBRRRRRBRRRRBRRRBBRRRBBBBRRRBRRBBBBRRRRRRB 33 | 2197 998434 34 | BRRRRRRRRRRBRRBBRBBRRBBBRRRRRRBRRBRBRBRRRRRRRRRRRRRRRRRRRRBBRRRBRRRR 35 | 8350 999732 36 | RBBRRBBBBRRBBBBBRBRRRRRBBRBBBBBBRBBBRBBBBBBRBBRRBBBRBBBBRR 37 | 6418 990811 38 | R 39 | 1 1 40 | RRRRRRRRRRRBRRRRRRBRRRRBRRRBRRB 41 | 1750 997395 42 | RRBBBRBBRBRBBBBBBRBBBRBBBBBBBRBRRBBBBBBBBBBBBB 43 | 2339 991478 44 | BRBRRBRRBBBRRRRRRRRRBBRRRRBRRRBRRRBRRRBRRBRRBR 45 | 4189 995049 46 | RBBRBBBBRBRBBBBBBBBBBBRRRBBRRRBRBBRRBBRBR 47 | 8558 991286 48 | BRBRBRRBBBRBR 49 | 2116 999543 50 | BBBRRRBRRRRRRRRBRBBRRRRRRBBRRRBRRRRRRBRRRRRRRBRRRRBRRRBBBBRBBBBRRBBRRR 51 | 1036 996615 52 | RRRRRRRRRRRRRBRRRRRRRRBBRRR 53 | 1408 998507 54 | BRBBBBBBRBRBRBBBRRRRBBRBRBBBBB 55 | 5973 996415 56 | BRRRRRRRRRRBRRRRRRR 57 | 3766 993396 58 | RRRRBBRRRBBRBBRRBRRRRRRRRBBBRBBRRRRBBBBRRBBRRBBRRRRRRBRRRBBRRBBRBRRRBRBRRRRRRRBRRBRRRRBRB 59 | 8468 990097 60 | RRRRRRBRBBRRRR 61 | 6070 997145 62 | BRBRRBRRRBBBBRRRBBBBRBRBRBRBRRBRBRRBBRBBBRRBRRBRRRBRBBBBRBBBBRBRRBBBRBRBBBRRBBRBBBBRRRRRBBBBBRBBRBRR 63 | 1 1000000 64 | RRBRRBBRBBBRBRBRBRBBRBRRBBBBRBRBRBBRBRRRRRRRRBRBBRRBBRRRRBRRRRRBRBRBBBBRRRRBBRRRRRRRRRBRBBRRR 65 | 301 997684 66 | BB 67 | 57 990541 68 | BRRBRRBRBRRRRBBRRRRRRRBBRRRRBRRRRRR 69 | 3501 999668 70 | RRBRBBRRRRRBBRBBRBBRRRBRRBRB 71 | 359 990123 72 | RBRBBBBRRBRBBBR 73 | 9122 995881 74 | RRRBRRBRBRRBRBRBBRRBBBRRBRRR 75 | 5253 992947 76 | RRR 77 | 8196 998732 78 | RBBRRRRRRRBBRRRRRRRRRRRRRRR 79 | 1764 998011 80 | RRRBBBBBRRBBRRR 81 | 1095 991670 82 | BBBBBRRBBBBRBRBBBRBBBBBBBRBBBBBBBBBBBBBBBBRBBBBB 83 | 266 996008 84 | BBBBBBBRBBBRBBBRRBBBRBBBBBBBBRBBBBBBRBRBBBBBRBBBBBBBRBBRBBBBBBBBBBBBBBBBBBBBBBBBBB 85 | 6720 994827 86 | BBRBBRRRBBRBBRRBRBBBBBRBRBBRBRRBRRBRBRBRBRBRRRBRBRRRRBRBBRRBBRRBRRBBR 87 | 6872 990986 88 | RBRBRRBBBBRRBRBRRRRRRRRRRBBRRRRBBBRRRBRRRRRRRRRRRRRRRBBRBRRRRRBRRRBRR 89 | 9712 994321 90 | RBRRRBRBBRBBBRRBRR 91 | 2674 997884 92 | BRBRRRRRRRBRRBRRBBBRBBRBBBRBBBRBBRRRBRRBBRRRRRBBRRR 93 | 3733 994916 94 | BBBBBRBBRRBRRRRRRRBBBBRBBBBRBRBBRRRRBBBBRBBBBRBBBBBRBRRBBBRRRBRRRRRRRBBRRBRBRBBBRRRBRBBBB 95 | 5356 990561 96 | BBBRBBRBRBRBRRBRBRBBRBRRBRRRBBBBRBBRBBRBBB 97 | 8306 997025 98 | RRBBRRRBBBRBBRRBBRBRBRBBRBBRRBBRBBBBBBRBBRRBRBRBBBRBRBRBB 99 | 6084 991649 100 | BBBRBBBRBBBBBRBBBBBRRRBBBBBBRBBBBBRBBBRBBBBBBBBRBBB 101 | 7635 992293 102 | BRBRRRRRBBRRRRBRRBRBRRBRBBRRBBRRBBRRBBRRRRB 103 | 4965 994719 104 | BBBRBBBBBRBBBBBBBBBBBRBBBBBBBBBBRBBRBBBBRBBBRBBBBBB 105 | 600 991365 106 | RRRBRRBRRRRBRBRRRRBRBRBBRRBBBRRB 107 | 1205 998927 108 | RRRRRRRRRRRRR 109 | 140 995975 110 | RBRRBBRRRRRBBRBBRRRRRRRBRRBRRBBBBBRRRBBRBRBRRBRBBBRBBRRRRRRRBBRRRRBBRRRR 111 | 2957 994647 112 | BRRRRRBRBRRRBBRRBRRBRBRRRRBRRRRRBBBBBBRBRRRRRBBBRRBBRRRRRRRBBBRBRRRRBBRBRRRRRBRRRR 113 | 6798 992546 114 | RRBBRBBBBBRBBBRRBRBRBBRBBRBBRRBBBRRBBBBBBBBBRBBBBBBRBRBRBBBBBBRBBRRBRBRBBBRRRRBBBBBRRBRBRRRRBBBRBBBB 115 | 6338 996066 116 | RRRRBBBBBBRBBBBBRRBRBBRRBRRRRBBBBRBRBRRBRBRRBBRBRBBBRBBBBRRRRBRRBRBBRRBBBR 117 | 1587 992620 118 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 119 | 1 1000000 120 | RBBRRRBBBBRBBBBBRBBBBBBRRRBB 121 | 7002 990913 122 | RRRRRRRRRBRRRRBBBBBBRBRBRBRBBRBBBR 123 | 128 998411 124 | RBRRBRBBBRBBBRBBRRBBBBBBBBBBBRRBBRRRRBBBBBBBRBRRBBBRBRBRBRRBBBBRRBBBRRBBRRRBBBRRRBRBBR 125 | 3846 994572 126 | B 127 | 7130 996217 128 | RBBRBRRRBBRBBBBBRBBBBRBBRBBBBBBBBRBBRBBBBRRBBRBRBBBBRRBBBRBBBRBBBRBBBBBBRBRRBBRBBBBRR 129 | 2382 990494 130 | BBBBBRBBBBBBBBRRRBBBBRBBBBBRBRBRBBBBBBRRBBBRBBBBBRBBRRBBBBRBBBBBRBRBBRBRBRRBBBBRBBB 131 | 764 991175 132 | RRRRRBRRRBRRRRRRRRRRBRBRRRRB 133 | 9872 996099 134 | BBRBBRRBBRBBBBBRRRBBBRBBBBRRRRBBRRBBBRRRBRBRRBBBBBBRBBR 135 | 958 990212 136 | RRRRRRBRRRRRRRRRRRRRRRRR 137 | 7637 990986 138 | RBRRRRBRRBBBRBRBRBBRBRRBRBBRRRBBRRRRBBRBRRBRRRRRRRR 139 | 9038 993183 140 | BBRRRRRRRRRRRBRBBRBRBRRRRBRRRBRBRBRBRRRRRRRBRRBRRRRRBBBRBRBBBRBRRRR 141 | 945 996405 142 | BBBRBBRBBRBBBBBBBBRBRBBBBBBBRBBBBBBBBBBBBBBBBBRBRBBRBBBBBBBBBBBRBRBBBRBBBBBBBBBBRBBBBBBBB 143 | 8707 994314 144 | BBBBBBBBB 145 | 7730 991815 146 | RBRBRBRRBRBBBRRRRBBBRBRRBBBRRRBRRRRBRRRBRBBBRBBBRBRBBBBBBRBBRRRRBBBRBBRBRBRRR 147 | 1040 991983 148 | RRBBBBBRRRBRBRBBRBRBBRRBBBRRBBBBRBBRBRBB 149 | 4660 994356 150 | RRRBRBBRRRRRRRBRBRBRRBBRRRRRBRBBBRBBBRRRRRBBRRBRR 151 | 602 991792 152 | BBBRBBBBBBBBBBBRBBRBBBBBBBBRBBBBRRBBBBBBBBBBBBBBBBBBBRBBBBBBBBBBBBBRBBBBBRBBBBRBBBBBBBRBBBBB 153 | 7425 999072 154 | BRBBBBBBBBBBBBBRBRBBBBBBBBRBBRRRBRRRBBRBRBRRBRBBRRRRBRRBBRBRRRBBBRBBBBRRBBBBBBBRBB 155 | 4463 990381 156 | RBBBBBBRBBRBBRRBRRBBRBRBB 157 | 6936 990968 158 | BBBBBBRBBBBRBBBBRBBBBBBBBBRBBBBBBBBBBBBBBRBBBBBBBBBBBBBBBBBBBBBBBBBRBBBRBBB 159 | 415 999400 160 | BRBRBRBRBBBBBBBBBBBBBBBBBBRBRBBBBBBBBRBRBBBBR 161 | 5752 990890 162 | RBBRBBRRR 163 | 8811 996330 164 | BBRBBBBB 165 | 7365 996931 166 | RRRRRBRRBBRRRRRRRRRRRRRBRRRRBRBRRRRRRBRBRRRRRRRRRBRRRRRRRRBR 167 | 3300 999285 168 | RBBBBRBBRRBBRBBBBBBBBBBBBBBBBRBBBRBBRBRBBBBBBBBBBRRBRBBBRRBRRRBBRBRRBRBR 169 | 2724 999702 170 | R 171 | 1 1000000 172 | RRRRRRRBRRBRRBRRRBBRBRRRBRRRRRBBRRRRRRRRBRRRRRRRBRRBBRRRRRRRBRRRRRBRRRBBRRRRRR 173 | 620 998061 174 | RRRBBRRRRBRBRBBRRBRBRBBBRRBRBRBRRRBBRRBRBBRBBB 175 | 5984 998478 176 | RRBRRRRBRBBBRRBRBRRRRRBRBRRRRRBBRBBRRRRBRRRRRBBBRBBRRRBRBBBRRRBBBBRBRBBBRRBR 177 | 7710 996798 178 | BRRBRRBBBBBBBB 179 | 5776 995886 180 | BRRRBRBRRBRBBRRBBBBBRRBBBBRBBRBBBBBRRRBRBBBBBBR 181 | 9262 994217 182 | BRRRRRBRRRRRRRRBRRRRRRRBRBRRRRRBBBRRRRRBRRR 183 | 4751 995313 184 | RRBBRRBRRRBBBRRBBRRBBRBRRBBBBBRRRRRRBBBRBBB 185 | 3227 991212 186 | BBBBBBRBBBBBBRBBBBBBBBBBBBBBRBBBBBBBBBRBBBBBBBBBBBBRBBBBBBBBBB 187 | 6756 991525 188 | RRBBBRBBBBRBRRBRRBBRRRBBBRRBBRBBBRBRRRBRRRBRRRBRRRRRRBRBRRRBBBBRRRRRRRRRRBBRRRRRRBRRRRRRBRRRRBRRBRRB 189 | 1 1000000 190 | B 191 | 1 1 192 | RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR 193 | 1 1000000 194 | BBBRBBBBBBBBBBBRBBBBBBBBRBRBBRBBBBBBB 195 | 6034 990729 196 | RRRBBRBRRBRBRBRRRRRBBBBBBRRBRRBRBRRBRBBRBRRBRBRRRRBRRBBBRRRRB 197 | 3223 998847 198 | BBBBBBBRBRRBBRRRBRBBBRBBBRB 199 | 7860 991878 200 | BRBBRBBBBBBBBBBBB 201 | 732 998145 202 | -------------------------------------------------------------------------------- /2016/Round E/Problem A/A-large-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | BBBRRBBRBBBRRBRRRRBRRBRBBBRRRR 3 | 4391 999999999999998016 4 | BRRRRRBRRRRBRRRRRRRRRRRBBRRRRRRRRRRRRBRRR 5 | 8125 999999999999997021 6 | RR 7 | 3031 999999999999995356 8 | RBBRRBRRRRRRBRRRRRRRRBRBRBRBRBBRRRBRRBRBBRRRBRRRRRRRBRRRRR 9 | 9911 999999999999990469 10 | B 11 | 1 1000000000000000000 12 | RRBBBBRBRBBRRBRRRRRRRBBRRRRRRRRBRRRRRR 13 | 4214 999999999999996987 14 | RBRRBRBRRBBRRBR 15 | 8502 999999999999996266 16 | RRBRBRRBRBRBBBBBBRRBBRRRRBBRRRRB 17 | 3925 999999999999997632 18 | BBRRBRBRBRBBBRRRBBRRBRRRRRRRRBRR 19 | 2108 999999999999996534 20 | BRBBBRRRBBBBRRRRRRBBRRRBRBRBBBRRBBBRBRRRBBRRBBRBBBBBBBBBBBRRRBRBRRRBRRBBBRRBBRBBRR 21 | 7275 999999999999994035 22 | RRRBBBRBBR 23 | 4787 999999999999996983 24 | RRRRRRBRRRRRRRRRRRRRRRRRRRRRBRRRRRBRRRRRRRBRRRRRRRRBBRRRRRRRRRRRRRRRRRRRRBRRRRRRBRRR 25 | 7587 999999999999998450 26 | BRRRRBBBBBBBRBRRRBRRBBRBBRRBRBRRBRBBRRRB 27 | 3721 999999999999999360 28 | BBBBBRBBBBBBBRBBBBBBBBRBBBBBBBBBBBBBBBBBBBBRBBBBBRBBBBBBRRBBBBRBBBBBBRBRBBRBBBRRBBBBRBRBBRBBBB 29 | 4840 999999999999995605 30 | BBRBBRBBBBBBBBRBRBRRRRBBBRBRBBRBBBBRRRBBBBBBBBBBBRRBRBBBRRRRBBBRRRBBBBRRRRRBRRBRRRBBRBBBRBBRBB 31 | 7723 999999999999995313 32 | RRBRRRBRBRRRRRBRRRRBRRRBBRRRBBBBRRRBRRBBBBRRRRRRB 33 | 2197 999999999999998434 34 | BRRRRRRRRRRBRRBBRBBRRBBBRRRRRRBRRBRBRBRRRRRRRRRRRRRRRRRRRRBBRRRBRRRR 35 | 8350 999999999999999732 36 | RBBRRBBBBRRBBBBBRBRRRRRBBRBBBBBBRBBBRBBBBBBRBBRRBBBRBBBBRR 37 | 6418 999999999999990811 38 | R 39 | 1 1 40 | RRRRRRRRRRRBRRRRRRBRRRRBRRRBRRB 41 | 1750 999999999999997395 42 | RRBBBRBBRBRBBBBBBRBBBRBBBBBBBRBRRBBBBBBBBBBBBB 43 | 2339 999999999999991478 44 | BRBRRBRRBBBRRRRRRRRRBBRRRRBRRRBRRRBRRRBRRBRRBR 45 | 4189 999999999999995049 46 | RBBRBBBBRBRBBBBBBBBBBBRRRBBRRRBRBBRRBBRBR 47 | 8558 999999999999991286 48 | BRBRBRRBBBRBR 49 | 2116 999999999999999543 50 | BBBRRRBRRRRRRRRBRBBRRRRRRBBRRRBRRRRRRBRRRRRRRBRRRRBRRRBBBBRBBBBRRBBRRR 51 | 1036 999999999999996615 52 | RRRRRRRRRRRRRBRRRRRRRRBBRRR 53 | 1408 999999999999998507 54 | BRBBBBBBRBRBRBBBRRRRBBRBRBBBBB 55 | 5973 999999999999996415 56 | BRRRRRRRRRRBRRRRRRR 57 | 3766 999999999999993396 58 | RRRRBBRRRBBRBBRRBRRRRRRRRBBBRBBRRRRBBBBRRBBRRBBRRRRRRBRRRBBRRBBRBRRRBRBRRRRRRRBRRBRRRRBRB 59 | 8468 999999999999990097 60 | RRRRRRBRBBRRRR 61 | 6070 999999999999997145 62 | BRBRRBRRRBBBBRRRBBBBRBRBRBRBRRBRBRRBBRBBBRRBRRBRRRBRBBBBRBBBBRBRRBBBRBRBBBRRBBRBBBBRRRRRBBBBBRBBRBRR 63 | 1 1000000000000000000 64 | RRBRRBBRBBBRBRBRBRBBRBRRBBBBRBRBRBBRBRRRRRRRRBRBBRRBBRRRRBRRRRRBRBRBBBBRRRRBBRRRRRRRRRBRBBRRR 65 | 301 999999999999997684 66 | BB 67 | 57 999999999999990541 68 | BRRBRRBRBRRRRBBRRRRRRRBBRRRRBRRRRRR 69 | 3501 999999999999999668 70 | RRBRBBRRRRRBBRBBRBBRRRBRRBRB 71 | 359 999999999999990123 72 | RBRBBBBRRBRBBBR 73 | 9122 999999999999995881 74 | RRRBRRBRBRRBRBRBBRRBBBRRBRRR 75 | 5253 999999999999992947 76 | RRR 77 | 8196 999999999999998732 78 | RBBRRRRRRRBBRRRRRRRRRRRRRRR 79 | 1764 999999999999998011 80 | RRRBBBBBRRBBRRR 81 | 1095 999999999999991670 82 | BBBBBRRBBBBRBRBBBRBBBBBBBRBBBBBBBBBBBBBBBBRBBBBB 83 | 266 999999999999996008 84 | BBBBBBBRBBBRBBBRRBBBRBBBBBBBBRBBBBBBRBRBBBBBRBBBBBBBRBBRBBBBBBBBBBBBBBBBBBBBBBBBBB 85 | 6720 999999999999994827 86 | BBRBBRRRBBRBBRRBRBBBBBRBRBBRBRRBRRBRBRBRBRBRRRBRBRRRRBRBBRRBBRRBRRBBR 87 | 6872 999999999999990986 88 | RBRBRRBBBBRRBRBRRRRRRRRRRBBRRRRBBBRRRBRRRRRRRRRRRRRRRBBRBRRRRRBRRRBRR 89 | 9712 999999999999994321 90 | RBRRRBRBBRBBBRRBRR 91 | 2674 999999999999997884 92 | BRBRRRRRRRBRRBRRBBBRBBRBBBRBBBRBBRRRBRRBBRRRRRBBRRR 93 | 3733 999999999999994916 94 | BBBBBRBBRRBRRRRRRRBBBBRBBBBRBRBBRRRRBBBBRBBBBRBBBBBRBRRBBBRRRBRRRRRRRBBRRBRBRBBBRRRBRBBBB 95 | 5356 999999999999990561 96 | BBBRBBRBRBRBRRBRBRBBRBRRBRRRBBBBRBBRBBRBBB 97 | 8306 999999999999997025 98 | RRBBRRRBBBRBBRRBBRBRBRBBRBBRRBBRBBBBBBRBBRRBRBRBBBRBRBRBB 99 | 6084 999999999999991649 100 | BBBRBBBRBBBBBRBBBBBRRRBBBBBBRBBBBBRBBBRBBBBBBBBRBBB 101 | 7635 999999999999992293 102 | BRBRRRRRBBRRRRBRRBRBRRBRBBRRBBRRBBRRBBRRRRB 103 | 4965 999999999999994719 104 | BBBRBBBBBRBBBBBBBBBBBRBBBBBBBBBBRBBRBBBBRBBBRBBBBBB 105 | 600 999999999999991365 106 | RRRBRRBRRRRBRBRRRRBRBRBBRRBBBRRB 107 | 1205 999999999999998927 108 | RRRRRRRRRRRRR 109 | 140 999999999999995975 110 | RBRRBBRRRRRBBRBBRRRRRRRBRRBRRBBBBBRRRBBRBRBRRBRBBBRBBRRRRRRRBBRRRRBBRRRR 111 | 2957 999999999999994647 112 | BRRRRRBRBRRRBBRRBRRBRBRRRRBRRRRRBBBBBBRBRRRRRBBBRRBBRRRRRRRBBBRBRRRRBBRBRRRRRBRRRR 113 | 6798 999999999999992546 114 | RRBBRBBBBBRBBBRRBRBRBBRBBRBBRRBBBRRBBBBBBBBBRBBBBBBRBRBRBBBBBBRBBRRBRBRBBBRRRRBBBBBRRBRBRRRRBBBRBBBB 115 | 6338 999999999999996066 116 | RRRRBBBBBBRBBBBBRRBRBBRRBRRRRBBBBRBRBRRBRBRRBBRBRBBBRBBBBRRRRBRRBRBBRRBBBR 117 | 1587 999999999999992620 118 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 119 | 1 1000000000000000000 120 | RBBRRRBBBBRBBBBBRBBBBBBRRRBB 121 | 7002 999999999999990913 122 | RRRRRRRRRBRRRRBBBBBBRBRBRBRBBRBBBR 123 | 128 999999999999998411 124 | RBRRBRBBBRBBBRBBRRBBBBBBBBBBBRRBBRRRRBBBBBBBRBRRBBBRBRBRBRRBBBBRRBBBRRBBRRRBBBRRRBRBBR 125 | 3846 999999999999994572 126 | B 127 | 7130 999999999999996217 128 | RBBRBRRRBBRBBBBBRBBBBRBBRBBBBBBBBRBBRBBBBRRBBRBRBBBBRRBBBRBBBRBBBRBBBBBBRBRRBBRBBBBRR 129 | 2382 999999999999990494 130 | BBBBBRBBBBBBBBRRRBBBBRBBBBBRBRBRBBBBBBRRBBBRBBBBBRBBRRBBBBRBBBBBRBRBBRBRBRRBBBBRBBB 131 | 764 999999999999991175 132 | RRRRRBRRRBRRRRRRRRRRBRBRRRRB 133 | 9872 999999999999996099 134 | BBRBBRRBBRBBBBBRRRBBBRBBBBRRRRBBRRBBBRRRBRBRRBBBBBBRBBR 135 | 958 999999999999990212 136 | RRRRRRBRRRRRRRRRRRRRRRRR 137 | 7637 999999999999990986 138 | RBRRRRBRRBBBRBRBRBBRBRRBRBBRRRBBRRRRBBRBRRBRRRRRRRR 139 | 9038 999999999999993183 140 | BBRRRRRRRRRRRBRBBRBRBRRRRBRRRBRBRBRBRRRRRRRBRRBRRRRRBBBRBRBBBRBRRRR 141 | 945 999999999999996405 142 | BBBRBBRBBRBBBBBBBBRBRBBBBBBBRBBBBBBBBBBBBBBBBBRBRBBRBBBBBBBBBBBRBRBBBRBBBBBBBBBBRBBBBBBBB 143 | 8707 999999999999994314 144 | BBBBBBBBB 145 | 7730 999999999999991815 146 | RBRBRBRRBRBBBRRRRBBBRBRRBBBRRRBRRRRBRRRBRBBBRBBBRBRBBBBBBRBBRRRRBBBRBBRBRBRRR 147 | 1040 999999999999991983 148 | RRBBBBBRRRBRBRBBRBRBBRRBBBRRBBBBRBBRBRBB 149 | 4660 999999999999994356 150 | RRRBRBBRRRRRRRBRBRBRRBBRRRRRBRBBBRBBBRRRRRBBRRBRR 151 | 602 999999999999991792 152 | BBBRBBBBBBBBBBBRBBRBBBBBBBBRBBBBRRBBBBBBBBBBBBBBBBBBBRBBBBBBBBBBBBBRBBBBBRBBBBRBBBBBBBRBBBBB 153 | 7425 999999999999999072 154 | BRBBBBBBBBBBBBBRBRBBBBBBBBRBBRRRBRRRBBRBRBRRBRBBRRRRBRRBBRBRRRBBBRBBBBRRBBBBBBBRBB 155 | 4463 999999999999990381 156 | RBBBBBBRBBRBBRRBRRBBRBRBB 157 | 6936 999999999999990968 158 | BBBBBBRBBBBRBBBBRBBBBBBBBBRBBBBBBBBBBBBBBRBBBBBBBBBBBBBBBBBBBBBBBBBRBBBRBBB 159 | 415 999999999999999400 160 | BRBRBRBRBBBBBBBBBBBBBBBBBBRBRBBBBBBBBRBRBBBBR 161 | 5752 999999999999990890 162 | RBBRBBRRR 163 | 8811 999999999999996330 164 | BBRBBBBB 165 | 7365 999999999999996931 166 | RRRRRBRRBBRRRRRRRRRRRRRBRRRRBRBRRRRRRBRBRRRRRRRRRBRRRRRRRRBR 167 | 3300 999999999999999285 168 | RBBBBRBBRRBBRBBBBBBBBBBBBBBBBRBBBRBBRBRBBBBBBBBBBRRBRBBBRRBRRRBBRBRRBRBR 169 | 2724 999999999999999702 170 | R 171 | 1 1000000000000000000 172 | RRRRRRRBRRBRRBRRRBBRBRRRBRRRRRBBRRRRRRRRBRRRRRRRBRRBBRRRRRRRBRRRRRBRRRBBRRRRRR 173 | 620 999999999999998061 174 | RRRBBRRRRBRBRBBRRBRBRBBBRRBRBRBRRRBBRRBRBBRBBB 175 | 5984 999999999999998478 176 | RRBRRRRBRBBBRRBRBRRRRRBRBRRRRRBBRBBRRRRBRRRRRBBBRBBRRRBRBBBRRRBBBBRBRBBBRRBR 177 | 7710 999999999999996798 178 | BRRBRRBBBBBBBB 179 | 5776 999999999999995886 180 | BRRRBRBRRBRBBRRBBBBBRRBBBBRBBRBBBBBRRRBRBBBBBBR 181 | 9262 999999999999994217 182 | BRRRRRBRRRRRRRRBRRRRRRRBRBRRRRRBBBRRRRRBRRR 183 | 4751 999999999999995313 184 | RRBBRRBRRRBBBRRBBRRBBRBRRBBBBBRRRRRRBBBRBBB 185 | 3227 999999999999991212 186 | BBBBBBRBBBBBBRBBBBBBBBBBBBBBRBBBBBBBBBRBBBBBBBBBBBBRBBBBBBBBBB 187 | 6756 999999999999991525 188 | RRBBBRBBBBRBRRBRRBBRRRBBBRRBBRBBBRBRRRBRRRBRRRBRRRRRRBRBRRRBBBBRRRRRRRRRRBBRRRRRRBRRRRRRBRRRRBRRBRRB 189 | 1 1000000000000000000 190 | B 191 | 1 1 192 | RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR 193 | 1 1000000000000000000 194 | BBBRBBBBBBBBBBBRBBBBBBBBRBRBBRBBBBBBB 195 | 6034 999999999999990729 196 | RRRBBRBRRBRBRBRRRRRBBBBBBRRBRRBRBRRBRBBRBRRBRBRRRRBRRBBBRRRRB 197 | 3223 999999999999998847 198 | BBBBBBBRBRRBBRRRBRBBBRBBBRB 199 | 7860 999999999999991878 200 | BRBBRBBBBBBBBBBBB 201 | 732 999999999999998145 202 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-small-attempt1.in: -------------------------------------------------------------------------------- 1 | 100 2 | 4 3 | 1332 4 | 4 5 | 9583 6 | 3 7 | 616 8 | 10 9 | 1029384756 10 | 98 11 | 12231141312113434434132233334443121324232122411113121111242214422133433324344411333413421141232313 12 | 92 13 | 55838488486585647737476537736533677585545456677378587846756358686744778858487678555757334364 14 | 100 15 | 3333332322222233323233232222223333323223233222333323322323232232223333222232233332233232232322322223 16 | 95 17 | 46654345344645536565354364546633345563535633363534356535536365453653436436354553456446366364536 18 | 7 19 | 9000555 20 | 90 21 | 663364546454535443554456433653635645534463636445363446634553656644445363454654456463665356 22 | 98 23 | 84467645563767569798935734977763888839863435859683673653635478843385647494434676988848775937875676 24 | 100 25 | 0987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321 26 | 3 27 | 211 28 | 96 29 | 684677774545343678455655494897833374998389463958466578358938773587688946749643543798838989747843 30 | 96 31 | 426433536133163442647722656336671215436551056422760334530013327720142347226014571642025646501772 32 | 100 33 | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 34 | 95 35 | 88594494494989666465874847647665689477857698467999666754948944764875784754755896887754787594877 36 | 95 37 | 36373388757838833865228287466263722676863347763574322664367526866877468822425626277466232633627 38 | 99 39 | 354445545434354545553433444444334334443454544333333343444443345355543433553534434444353535343454343 40 | 99 41 | 445444556466456644664455445466465645464565654655554454646545566545546556564454544465454664664565466 42 | 90 43 | 111112222111111111211122212222111111112211221121221121212112221211211111121211112211122222 44 | 97 45 | 6128555116128138654464417146851464451886375562856261736256682275362312172261276613487234262564384 46 | 94 47 | 2322233223332323322332232233322223222323222333332323322222333232233223333223233322232333332222 48 | 100 49 | 4346635755556636476534544436774673354367344375736667474464753376557466377676573457474474336533744463 50 | 3 51 | 112 52 | 91 53 | 7879798898978787788878977898978897777889978787979979898799978777988778979879998799899779789 54 | 99 55 | 337545556497959967936649376945377897734438539656364387368485543656388955994468436348363385353985438 56 | 93 57 | 565665655665565655666566666656555655556555666656665565566555655565565556565656666655655666666 58 | 99 59 | 444444444433333433443434444434434444444434334433334444343433334333333434344343444433444333344344344 60 | 94 61 | 6557676555655765656756776676665757765676655556665765577757757775667757675565567775566556565667 62 | 90 63 | 231322132313113321223131231323313232123223122113213211131311223132233223131112332212113233 64 | 3 65 | 110 66 | 2 67 | 00 68 | 2 69 | 01 70 | 100 71 | 4953256839924268983128257329172588911844921879697236587419133852756321531654483444469681533479411622 72 | 100 73 | 6293757398575767754219117727978878249583834948484995335726418411197978591415693874949211861377858264 74 | 90 75 | 443653274222622445324572647227766776346233276335435522533255327473357645645577743666277327 76 | 93 77 | 866548788574688745844484645546484746878845474858565745675455548578877474776446456665587646456 78 | 98 79 | 14350352010501243532542504325335325304041533540005100552502510350245253151122554044401311035103010 80 | 95 81 | 54344848435834873538448658768658877644576634463848684337744374838667635476574878585548347865558 82 | 97 83 | 6724532362437344764654262473327426645267252476432462666626636564426622664773756336755657772345237 84 | 90 85 | 453434445535535333455344353545543445343434534343345433545434533443535455433345544434433355 86 | 100 87 | 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 88 | 93 89 | 552223434352552533544522243242524235453424332544353235245253254352335445233422252224335452433 90 | 94 91 | 0000101010100011101101101100100101010000101111101111001101001100000000010000010000101101110101 92 | 91 93 | 5794499843798748775954565396968836835638334746794598883934783444873834856597769479936368558 94 | 97 95 | 8999898998988899998889888899998988899999888988989998889898888899889899998988898888888989889988989 96 | 91 97 | 1101101111111010100100101000001100111111011111001010011101111010000101111010010000001000100 98 | 97 99 | 2324222221000512610531062031222142601625214164422202600035210325310250130255136310020451623623663 100 | 97 101 | 3412311232443355255221433353216321361626451646123546132252515654545251323461213423265542421323165 102 | 100 103 | 0000000000111111111122222222223333333333444444444444444444443333333333222222222211111111110000000000 104 | 100 105 | 7643635563547635744567553453343456534653764453733374575753356653463437563334663647557735455634666655 106 | 94 107 | 2221012212022220000221211211212101121102221011102011002220201220001220010122221222220102002210 108 | 90 109 | 976969777976868969878678978978679999867689697987887889666669999679887979897976676988796986 110 | 98 111 | 37364657575374654657464757446346364456367657737755644355566353344666546457476665336655736566675643 112 | 90 113 | 887878766688788678766787667677778776876886866867677777667886676786767667686768888788777687 114 | 100 115 | 3234312245362634666413211551434351312635426363161321511164526344453622323655242654541213464466213442 116 | 97 117 | 4756696866555985557764989955579876659794789878758557748949865786579577669588955465889669454894776 118 | 100 119 | 7317321575460422231733170344143376306660423527167301171224763055142142415270477165412132757763521425 120 | 2 121 | 10 122 | 97 123 | 1231232344211343413312433341112131324233321121311244111321442112231143114232421222332344234334143 124 | 91 125 | 2636246774588762433246353645637768225325372778262344474668866472483355387874534428347636327 126 | 98 127 | 22122330221300312022222000300202002003030001231312312321221022000012213101131002120333021233011322 128 | 97 129 | 3563637553645453553445645447463456535763377335465675367655376676773556537545575566667337555573533 130 | 96 131 | 111001100011011001110000010010100000111001010010101010100110100000110100111011001000000010000011 132 | 90 133 | 644111067943681607851204617467653056614245769705452863329020561996389143541521223235216801 134 | 98 135 | 45445445445445454455455555444544545445544444544545444554554545544544545444445455544444455454445455 136 | 91 137 | 1122134242321413122434314214113221444343211142143334424213213331112141124234312142424223324 138 | 94 139 | 7178806421578251566436661875772233523684831008016443433606800634370273006173664442858753122767 140 | 15 141 | 222229888888811 142 | 98 143 | 56464454977454677958968948754687843363858456984348578484953567776799468795798958697754836333769999 144 | 95 145 | 01123322011103000212031120132102030000021221330131001100320023231221033200120310321111002201133 146 | 97 147 | 6666677777677667776676776676667777767667667777677776676767666777676766666777666666667667677776776 148 | 91 149 | 4044211231030403422431214213331224233431041442040111441410201422204402230201111030012123210 150 | 95 151 | 64434644355446665664443245625465625645356435223265453546346325324624366363322326344642243545465 152 | 90 153 | 332213321123321312112222131111113111311321122112123212333222212133311222123113123131321311 154 | 100 155 | 5488655747663846643373657467734444543544464875687858736866654484567643765767578853784448687473744378 156 | 98 157 | 37747766436435345777677867376643533776588748435836787536837737354348664754343476883543443885543777 158 | 92 159 | 22122112122211111221211122122121111211111111212111222212121211122121112121121212121111122111 160 | 99 161 | 533423278427628786673257832638325738754372272542862846245846644725856284288335342657262837235288486 162 | 92 163 | 31421434331123423423113311343223221333112334433421424331141123324333344124421313212234432322 164 | 94 165 | 4455445454444445554455444445544454455554454455444454554545544544555545445545455544544455545555 166 | 91 167 | 1123224442142413341123134244233123414211133112432311233312423344313114312323222233122313133 168 | 3 169 | 001 170 | 91 171 | 1221122212212112221211112122221211111222211122221211121212121221211122211121121122121212212 172 | 94 173 | 9878887788898777777887778889789899789888778797887999979779888988787977779879798898977787999799 174 | 100 175 | 1426937929453968597355354835543194517848842965573327454443554267875178831546871123776155739616775782 176 | 94 177 | 2333232223223232223322322332233333333233322323333322323232222332222233322223333333333222332332 178 | 98 179 | 02210000001022000010021011210222022202010022002212010200011112102212112112100121022201111101012012 180 | 100 181 | 8898998999898999988899888889899998999899889999889899889888989988888888899999999989888898889898888898 182 | 96 183 | 898666968989866777966699977976699769876867977766666877889698996766699766888799666997787797679696 184 | 5 185 | 19091 186 | 94 187 | 3232332222233332233322332322322323333223332222233232233332332323222333332233233222323322233222 188 | 98 189 | 76777767776767767666676677676766666666777776666777676667676667767777666777766666676666776777676676 190 | 92 191 | 78889988898988987899787997878989979788988887899788877798878997988978788978899988879987887888 192 | 100 193 | 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 194 | 100 195 | 2111342142444213332421143232222234421233343114242113414214443321444343341223311344324413114214413422 196 | 3 197 | 011 198 | 90 199 | 543534354335355444533453345554333533335445535345543343443445355334354354534555554544535344 200 | 97 201 | 6846733564648453836853754866776747648468457888575886647486866536358887448487765858456587374433345 202 | -------------------------------------------------------------------------------- /2018/Round H/Problem B/B-small-practice.in: -------------------------------------------------------------------------------- 1 | 100 2 | 4 3 | 1332 4 | 4 5 | 9583 6 | 3 7 | 616 8 | 10 9 | 1029384756 10 | 100 11 | 5323554121646233545624165556536142253331541461224246515413314131516646124633213431346351255243331622 12 | 99 13 | 455444566555466566645555446654446645544466564464544454554445556455455565554666466446666556455565464 14 | 100 15 | 8146222400584477547444645330888382832055768748617402632036323537474514622646180855452850113020323540 16 | 100 17 | 7889889787989877877798877787999788877788877899977898979877998989997877788998778899999898987778779779 18 | 96 19 | 543734335643443746776364663767454646746674746646563745475635776446736574363735437646376576576766 20 | 97 21 | 9776898669688678877978999796969999867868689988798967676986677688688787687778679967969999987776667 22 | 99 23 | 446665666646774474775475456545456746567544744564567644646544664476565655556455744655464756676454454 24 | 96 25 | 023021202322102332031333302211132231212322332313230123002232321333031211321121300332123203022210 26 | 94 27 | 0111021213030223300013132113232100210121302010201101220330201101012112313303110212033203303231 28 | 100 29 | 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 30 | 2 31 | 01 32 | 91 33 | 7776577576557656756676656665777667676657565575665775757577766675577767755565675556557765576 34 | 90 35 | 323223322232323322223222222333322223232233323332223333323322323332233332332332333232233323 36 | 95 37 | 24381571534455554044625166584221175474524508821882265011847822224660774327683602056047767837682 38 | 93 39 | 334333223332332242433234424242424322322444343433223223234342432342344443322243343243444434234 40 | 99 41 | 001011011100010001011000011001100111000010010100011010000101111001111010000010011111111000110000110 42 | 100 43 | 0000000000111111111122222222223333333333444444444444444444443333333333222222222211111111110000000000 44 | 98 45 | 56755577755566575775556655665776675565776556775666557676767576577566657667755555565655767566767557 46 | 90 47 | 411444412411101021232202014101044424334142422203334142044300401201313014320441410022201142 48 | 3 49 | 001 50 | 97 51 | 7073032024264045651352045752676471317266033302550665465745742325542467347524574207450154705257740 52 | 99 53 | 875746466547738487846752222223674422425844445476658547364322877667345367365577767435462453676727873 54 | 98 55 | 85444127332737773217663237744627671467254576741238532813236133385464355517147378125444723175888646 56 | 90 57 | 465544564546645565655454446646654566465545454655566666556456545456556566565655664545555454 58 | 99 59 | 777667666776766767767677676676677767767677777676667676666676777776666666766677676677667666776766667 60 | 94 61 | 3223323332222233332322222223332223222322233232232232323232332323232323332232233233333332222323 62 | 93 63 | 254868627873676453453428538228868852383532523746853877277377673842646465387864325887444263566 64 | 7 65 | 9000555 66 | 90 67 | 333322222233333232322232322232333232222222323232232322223332233332222333223322222322322323 68 | 90 69 | 989988998888999977998887977979799897777978989778989988877799888977788877889989989987778979 70 | 100 71 | 4158623592164742623718731234773298171561946968622936536775213367341513925653868867586747868165538114 72 | 99 73 | 788556958433785675889436549657994995878599897797833888995484843766676835956456437893445498598664797 74 | 98 75 | 66567564746556545546666777575556565565446547744666776445475547646475565656456564776654566464756556 76 | 90 77 | 123421131213431342432234422241414322212344134122143212322243444224332224122431123132113132 78 | 90 79 | 555556656666566556556666556565666555565666566556666655566656565665555566666555555565656655 80 | 100 81 | 6646664454576657655666575554744456465656675545767557457746547474667776677646775774664556456665455547 82 | 92 83 | 43313142355413312545541511233444355114342514315342152353211241321234151541525325223441531142 84 | 92 85 | 33222332243334224442343334234432222424334242243424232242224322444434332242442242333222242243 86 | 91 87 | 1313122131231122101300133131021001111313330301032323112320320332310332020303310221211323021 88 | 95 89 | 56665655655665555665655556555565566655665556565665566656556565555556655655555655655665665655665 90 | 91 91 | 0926540569408491500406257298020839379734245123462915645745892786124763154342941434950275899 92 | 91 93 | 4544444445444445545445445445445455445544554444554555445545454545455544445544545554555445454 94 | 96 95 | 444345523253542522444424342322434224425334242235453323552354544322234533545224423552434334435423 96 | 96 97 | 363126366661145161215541422166321751661467651172177337674676653542272577441456577652423232417156 98 | 99 99 | 697569795686567678799596898567766687789696776856686689656796969788975779699875777666557655898699759 100 | 95 101 | 53254635645566372254377767733476377356664347225553537742552643543664656746742425564347466637256 102 | 98 103 | 55435154315335422161242333621233333342231442326345616254412554115452246311323655456336666533422342 104 | 96 105 | 363176638488847758511663444861861785423678414571611765254266232345328626623634684862672548344132 106 | 96 107 | 899898988989888998889999899899898988899999998899899989899988888898889998899988989989888899888988 108 | 90 109 | 222221223323233121322311122112123112133212313231223111213312231113121213113113112121112312 110 | 100 111 | 6549657556865847769894859486454969776845858869684969565574556476948465895697896988744955479765498888 112 | 100 113 | 4522895119696263656669497222516794646992955642477379527639476359938337777754421719812343884255452475 114 | 98 115 | 67669999768878698878969788886689779699787996979967876899677686986798777768889897898777979878787878 116 | 100 117 | 5337436354365563553567736645543377535564335537757575434465337556445463374675377336744343476457577763 118 | 97 119 | 7787767678687667868766686687777866767767868787686778877776676877877866867888687786876877867666866 120 | 5 121 | 19091 122 | 92 123 | 14323322234122423323322433213322132344431423334321231142343144223424434441324113333434442341 124 | 95 125 | 33242525174775745431276231145712772217676723671164476332156314371511473234157651554144644154661 126 | 91 127 | 7568857856676887666585585765758865788887868877578865777758885787885777578558565785777777878 128 | 100 129 | 0987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210987654321 130 | 93 131 | 586734277386625614159447374819768414744733915148542623416262659879531775193983841419561889197 132 | 3 133 | 110 134 | 100 135 | 4538676143939961618762447419166999729191762183663836211827952686433324423989341616957325653176653626 136 | 90 137 | 443412304430214101001031200140044021401342120210022121214432004110123223301130304220203221 138 | 100 139 | 3334223444233234324234433334444342324243434423332344332233323242323342444224244223333423342244243224 140 | 99 141 | 521856127226747762154272573543328860161704325402420144513572476523464773660424438027003158585514482 142 | 92 143 | 22452476546654366472272774733662634754264642626757226753226347427665553672723642345566227257 144 | 15 145 | 222229888888811 146 | 95 147 | 99898798887988887777778898997987999787889998888988979977788788787979779799777988898989887787997 148 | 90 149 | 264756664212272347525662217214722555652333257761165217252762273535232312645425147666672625 150 | 99 151 | 779899789778787979979788887977979998988877988798888979989789779798887797897778889977898988788979889 152 | 97 153 | 1214514123231545144445525532553222412313451552252413552111115345214551515251441412151352313111243 154 | 100 155 | 7677537657525657522734555726265233224746437342454352635432755663575573225326626463533464765323232272 156 | 91 157 | 7056140657617184943661559185488847512833749767170600011188172550497449249865884832280331311 158 | 100 159 | 1634575867515726767418641447852738121646536215163756665884123835526837471784327268161254251313788366 160 | 3 161 | 011 162 | 99 163 | 121333222412421142424141221311443242243312333133313344221434213232111342213341324414344312443212441 164 | 100 165 | 7267448573423756875513556258268671652843267646557664411788537253571884367315231236676162746653145855 166 | 2 167 | 00 168 | 98 169 | 97586858678955966978658868887959596796876678799798995655759968579659697888859665786897778596958786 170 | 90 171 | 959778667864848879859498556946978447756976689979957496488665678759796888656545676658758684 172 | 100 173 | 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 174 | 100 175 | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 176 | 99 177 | 115241431141255444323245154514435354542452532354334425343344113552211132215421142112511442151533335 178 | 93 179 | 441535543123475226421352121711744346717114163447664547323113743647454154634337176766471156217 180 | 96 181 | 000210210021110000112110122210221120210121110210012100012111200022120010121001102211220120011000 182 | 2 183 | 10 184 | 3 185 | 112 186 | 99 187 | 546546654446555464444544445545455456565544444464466564455666555555456444664444555664645566554464465 188 | 90 189 | 676777766667676667776776677776767666776766667677766766766767677667667766677777676666667776 190 | 92 191 | 77667666666767676667767677776666766676676666677767677677666767777767777767767777776767777676 192 | 97 193 | 3136416161252533514132441342153551531321634114666264562614242635662666213325214333353255232146431 194 | 3 195 | 211 196 | 91 197 | 5765766657656777876887857668858555686578557877758775766575655778855886855577687876876685588 198 | 97 199 | 2112221211121112122121121111212111211121211111122121122212122121122122111121221111122211112112211 200 | 91 201 | 1863444112371167567647277416124315567783848552186752857757663576746834467152888511644427824 202 | --------------------------------------------------------------------------------