Skip to content

Commit

Permalink
Update as of 15 December 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellDash332 committed Dec 14, 2024
1 parent 5ed4ceb commit 16de35e
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down Expand Up @@ -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)]()|
Expand Down Expand Up @@ -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)]()|
Expand Down Expand Up @@ -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)]()|
Expand Down
56 changes: 55 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2>
Kattis Solutions
</h2>
<p id="last-updated">
Last updated: 14 December 2024
Last updated: 15 December 2024
</p>
<p>
Note that the tables below are auto-generated using
Expand Down Expand Up @@ -10905,6 +10905,24 @@ <h2>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/crammingforfinals">
Cramming for Finals
</a>
</td>
<td>
crammingforfinals
</td>
<td>
8.0
</td>
<td>
<a href="https://raw.githubusercontent.com/RussellDash332/kattis/main/src/Cramming for Finals/crammingforfinals.py">
<img alt="py" src="images/python.png"/>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/crane">
Expand Down Expand Up @@ -16587,6 +16605,24 @@ <h2>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/exponentiallyfun">
Exponentially Fun Problem
</a>
</td>
<td>
exponentiallyfun
</td>
<td>
7.5
</td>
<td>
<a href="https://raw.githubusercontent.com/RussellDash332/kattis/main/src/Exponentially Fun Problem/exponentiallyfun.py">
<img alt="py" src="images/python.png"/>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/exponial">
Expand Down Expand Up @@ -28518,6 +28554,24 @@ <h2>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/longwalk">
Long Walk
</a>
</td>
<td>
longwalk
</td>
<td>
5.2
</td>
<td>
<a href="https://raw.githubusercontent.com/RussellDash332/kattis/main/src/Long Walk/longwalk.py">
<img alt="py" src="images/python.png"/>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://open.kattis.com/problems/loopycabdrivers">
Expand Down
28 changes: 28 additions & 0 deletions src/Cramming for Finals/crammingforfinals.py
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions src/Exponentially Fun Problem/exponentiallyfun.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions src/Long Walk/longwalk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
n, m, *a = map(int, open(0).read().split()); z = 2*n*(m-1); N = 1<<n
for i in range(m-1):
v1 = a[i]+N; c1 = 0
while v1%2==0: v1 //= 2; c1 += 1
v2 = a[i+1]+N; c2 = 0
while v2%2==0: v2 //= 2; c2 += 1
s = 0; v1, v2 = a[i]+N, a[i+1]+N; d = abs(c1-c2)
if c1 > c2: v2 = (a[i+1]<<d)%N+N
else: v1 = (a[i]<<d)%N+N
while v1%2==v2%2 and v1 > 1: s += 1; v1 //= 2; v2 //= 2
z += d-2*s
print(z)

0 comments on commit 16de35e

Please sign in to comment.