From 16de35eba405280550d124700fd8bebbe3d84f03 Mon Sep 17 00:00:00 2001 From: RussellDash332 Date: Sun, 15 Dec 2024 05:03:52 +0800 Subject: [PATCH] Update as of 15 December 2024 --- README.md | 5 +- docs/index.html | 56 ++++++++++++++++++- src/Cramming for Finals/crammingforfinals.py | 28 ++++++++++ .../exponentiallyfun.py | 19 +++++++ src/Long Walk/longwalk.py | 12 ++++ 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 src/Cramming for Finals/crammingforfinals.py create mode 100644 src/Exponentially Fun Problem/exponentiallyfun.py create mode 100644 src/Long Walk/longwalk.py diff --git a/README.md b/README.md index 7f26b323..ba849329 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Kattis Solutions ![Visitors](https://count.getloli.com/get/@RussellDash332) -## Total problems solved: 2773 +## Total problems solved: 2776 Note that the tables below are auto-generated using [autokattis](https://github.com/RussellDash332/autokattis). @@ -608,6 +608,7 @@ For more Python data structure implementations, head over to [pytils](https://gi |[Cracker Barrel Game](https://open.kattis.com/problems/crackerbarrel)| crackerbarrel |4.3|[![py](images/python.png)]()| |[Cracking RSA](https://open.kattis.com/problems/crackingrsa)| crackingrsa |2.0|[![cpp](images/cpp.png)]()| |[Cracking the Code](https://open.kattis.com/problems/crackingthecode)| crackingthecode |5.8|[![py](images/python.png)](src/Cracking%20the%20Code/crackingthecode.py)| +|[Cramming for Finals](https://open.kattis.com/problems/crammingforfinals)| crammingforfinals |8.0|[![py](images/python.png)](src/Cramming%20for%20Finals/crammingforfinals.py)| |[Crane Balancing](https://open.kattis.com/problems/crane)| crane |4.9|[![py](images/python.png)]()| |[Crane](https://open.kattis.com/problems/crane2)| crane2 |5.1|[![py](images/python.png)]()| |[Cranes](https://open.kattis.com/problems/cranes)| cranes |4.0|[![py](images/python.png)]()| @@ -920,6 +921,7 @@ For more Python data structure implementations, head over to [pytils](https://gi |[Expected Earnings](https://open.kattis.com/problems/expectedearnings)| expectedearnings |1.8|[![py](images/python.png)]()| |[Expeditious Cubing](https://open.kattis.com/problems/expeditiouscubing)| expeditiouscubing |5.1|[![py](images/python.png)]()| |[Explosion Exploit](https://open.kattis.com/problems/explosion)| explosion |4.9|[![py](images/python.png)]()| +|[Exponentially Fun Problem](https://open.kattis.com/problems/exponentiallyfun)| exponentiallyfun |7.5|[![py](images/python.png)](src/Exponentially%20Fun%20Problem/exponentiallyfun.py)| |[Exponial](https://open.kattis.com/problems/exponial)| exponial |5.3|[![py](images/python.png)]()| |[Eye of Sauron](https://open.kattis.com/problems/eyeofsauron)| eyeofsauron |1.5|[![py](images/python.png)]()| |[Factor-Free Tree](https://open.kattis.com/problems/factorfree)| factorfree |5.8|[![py](images/python.png)]()| @@ -1578,6 +1580,7 @@ For more Python data structure implementations, head over to [pytils](https://gi |[Longest Prime Sum](https://open.kattis.com/problems/longestprimesum)| longestprimesum |2.4|[![py](images/python.png)]()| |[Longest Increasing Subsequence](https://open.kattis.com/problems/longincsubseq)| longincsubseq |4.9|[![py](images/python.png)](src/Longest%20Increasing%20Subsequence/longincsubseq.py)| |[Long Swaps](https://open.kattis.com/problems/longswaps)| longswaps |3.6|[![py](images/python.png)]()| +|[Long Walk](https://open.kattis.com/problems/longwalk)| longwalk |5.2|[![py](images/python.png)](src/Long%20Walk/longwalk.py)| |[Loopy Cab Drivers](https://open.kattis.com/problems/loopycabdrivers)| loopycabdrivers |6.2|[![py](images/python.png)](src/Loopy%20Cab%20Drivers/loopycabdrivers.py)| |[Loopy Transit](https://open.kattis.com/problems/loopytransit)| loopytransit |3.6|[![py](images/python.png)]()| |[Loo Rolls](https://open.kattis.com/problems/loorolls)| loorolls |2.1|[![py](images/python.png)]()| diff --git a/docs/index.html b/docs/index.html index 3bf1e6ea..0e5caef7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -33,7 +33,7 @@

Kattis Solutions

- Last updated: 14 December 2024 + Last updated: 15 December 2024

Note that the tables below are auto-generated using @@ -10905,6 +10905,24 @@

+ + + + Cramming for Finals + + + + crammingforfinals + + + 8.0 + + + + py + + + @@ -16587,6 +16605,24 @@

+ + + + Exponentially Fun Problem + + + + exponentiallyfun + + + 7.5 + + + + py + + + @@ -28518,6 +28554,24 @@

+ + + + Long Walk + + + + longwalk + + + 5.2 + + + + py + + + diff --git a/src/Cramming for Finals/crammingforfinals.py b/src/Cramming for Finals/crammingforfinals.py new file mode 100644 index 00000000..ef20f52f --- /dev/null +++ b/src/Cramming for Finals/crammingforfinals.py @@ -0,0 +1,28 @@ +import sys; input = sys.stdin.readline; from random import * +R = set(); V = 1001; r, c, d, n = map(int, input().split()); p = [-1]*(d+1); P = [[*map(lambda x: int(x)-1, input().split())] for _ in range(n)] +for i in range(d+1): + for j in range(d+1): + if i*i+j*j<=d*d: p[i] = j +while len(R) < r: + i = randint(0, r-1) + if i in R: continue + R.add(i); m = {} + for x, y in P: + if abs(x-i) > d: continue + f = p[abs(x-i)]; s = max(y-f, 0); e = min(y+f+1, c) + if s < e: + if s not in m: m[s] = 0 + if e not in m: m[e] = 0 + m[s] += 1; m[e] -= 1 + if x == i: + if y not in m: m[y] = 0 + if y+1 not in m: m[y+1] = 0 + m[y] -= 1001; m[y+1] += 1001 + g = q = 0; v = 1001 + for x in sorted(m): + if q != x and g >= 0: v = min(v, g) + g += m[x]; q = x + if v == 0: break + V = min(V, v) + if V == 0: break +print(V) \ No newline at end of file diff --git a/src/Exponentially Fun Problem/exponentiallyfun.py b/src/Exponentially Fun Problem/exponentiallyfun.py new file mode 100644 index 00000000..c81c93f4 --- /dev/null +++ b/src/Exponentially Fun Problem/exponentiallyfun.py @@ -0,0 +1,19 @@ +M = 10**9+7; n = int(input()); r = 1 +spf = list(range(n+1)); primes = []; p = 2 +while p <= n: + if spf[p] == p: + primes.append(p) + for i in range(p*p, n+1, p): + if spf[i] == i: spf[i] = p + if p == 2: p -= 1 + p += 2 +dp = [float('inf')]*(n+1) +for p in primes: + if p <= n: dp[p] = p +for i in range(4, n+1): + for p in primes: + if p > i: break + dp[i] = min(dp[i], dp[i-p]*p) +while n%3: n -= 2; r *= 2; r %= M +r *= pow(3, n//3, M); r %= M +print(dp[-1], r) \ No newline at end of file diff --git a/src/Long Walk/longwalk.py b/src/Long Walk/longwalk.py new file mode 100644 index 00000000..384a582a --- /dev/null +++ b/src/Long Walk/longwalk.py @@ -0,0 +1,12 @@ +n, m, *a = map(int, open(0).read().split()); z = 2*n*(m-1); N = 1< c2: v2 = (a[i+1]< 1: s += 1; v1 //= 2; v2 //= 2 + z += d-2*s +print(z) \ No newline at end of file