-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jfsscsclub/2023-Solutions
- Loading branch information
1 parent
594e13e
commit 53a45b2
Showing
7 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CCC 2016 | ||
Note that these are only accessible if you are a student of the Peel District School Board and are logged into your school Google account. Otherwise, you will not have access. | ||
## Slide Decks | ||
- [S2](https://docs.google.com/presentation/d/1c3o4cSQfKFScKp3BfXM0b216HOMg3hURkNv4HBU2Ppc/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CCC 2022 | ||
Note that these are only accessible if you are a student of the Peel District School Board and are logged into your school Google account. Otherwise, you will not have access. | ||
## Slide Decks | ||
- [S2](https://docs.google.com/presentation/d/1c3o4cSQfKFScKp3BfXM0b216HOMg3hURkNv4HBU2Ppc/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CCC 2023 | ||
Note that these are only accessible if you are a student of the Peel District School Board and are logged into your school Google account. Otherwise, you will not have access. | ||
## Slide Decks | ||
- [S1/J4, S2, S3](https://docs.google.com/presentation/d/1ZOA_IlWxJPJdOiX4Cxhhy1WOK-nyPMLahiBfGsJwEmM/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# CCC '23 J4/S1 - Aritro Saha | ||
c = int(input()) | ||
|
||
# Gathering input, True represents a black triangle and False represents a white triangle | ||
row1 = [bool(int(triangle)) for triangle in input().split()] | ||
row2 = [bool(int(triangle)) for triangle in input().split()] | ||
|
||
# The maximum tape that we need is the number of black triangles * the edges per triangle (3) | ||
tape = (row1.count(True) + row2.count(True)) * 3 | ||
|
||
# Checking for left-right adjacency in both rows | ||
for i in range(c - 1): | ||
if row1[i] and row1[i + 1]: | ||
tape -= 2 # Subtract 2 because one edge on both adjacent triangles aren't needed | ||
|
||
if row2[i] and row2[i + 1]: | ||
tape -= 2 | ||
|
||
# Checking for top-bottom adjacency | ||
for i in range(c): | ||
# If the triangles are pointing into each other, they don't share an edge | ||
# Referring to the diagram, this only happens on even triangle columns (starting at 0) | ||
if row1[i] and row2[i] and i % 2 == 0: | ||
tape -= 2 | ||
|
||
print(tape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CCC '23 S2 - Roy Zhang | ||
N = int(input()) | ||
hills = [int(i) for i in input().split(" ")] | ||
|
||
# initialize grid | ||
grid = [] | ||
for i in range(N): | ||
grid.append([0] * N) | ||
|
||
# solve | ||
ans = [float('infinity')] * N | ||
ans[0] = 0 | ||
for j in range(1, N): | ||
for i in range(j - 1, -1, -1): | ||
grid[i][j] = grid[i + 1][j - 1] + abs(hills[i] - hills[j]) | ||
if grid[i][j] < ans[j - i]: | ||
ans[j - i] = grid[i][j] | ||
|
||
print(" ".join(str(i) for i in ans)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# CCC '23 S3 - Roy Zhang | ||
import math | ||
|
||
NMRC = input().split(" ") | ||
N, M, R, C = int(NMRC[0]), int(NMRC[1]), int(NMRC[2]), int(NMRC[3]) | ||
|
||
# initialize grid | ||
grid = [] | ||
for i in range(N): | ||
grid.append([0] * M) | ||
|
||
# impossible case | ||
if (R == N and C % 2 != 0 and M % 2 == 0) or (C == M and R % 2 != 0 and N % 2 == 0): | ||
print("IMPOSSIBLE") | ||
else: | ||
# col palindromes | ||
count = 0 | ||
if C % 2 == 1 and M % 2 == 1: | ||
for i in range(N): | ||
grid[i][M//2] = 'a' | ||
C -= 1 | ||
count += 1 | ||
|
||
# col palindromes | ||
for j in range(C): | ||
for i in range(N): | ||
if j % 2 == 0: | ||
col_coord = math.ceil(j / 2) | ||
else: | ||
col_coord = M - math.ceil(j / 2) | ||
grid[i][col_coord] = "a" | ||
|
||
# row palindromes | ||
for i in range(R): | ||
if i == 0: | ||
grid[i] = ['a'] * M | ||
else: | ||
for j in range(M): | ||
if grid[i][j]: continue | ||
if grid[i][M - j - 1]: | ||
grid[i][j] = grid[i][M - j - 1] | ||
else: | ||
grid[i][j] = 'b' | ||
|
||
# remaining cells | ||
for i in range(N): | ||
for j in range(M): | ||
if grid[i][j]: continue | ||
if i == 0: | ||
grid[i][j] = 'f' | ||
if not grid[i][M - j - 1]: | ||
grid[i][M - j - 1] = 'g' | ||
elif i % 2 == 0: | ||
grid[i][j] = 'c' | ||
if not grid[i][M - j - 1]: | ||
grid[i][M - j - 1] = 'd' | ||
else: | ||
grid[i][j] = 'd' | ||
if not grid[i][M - j - 1]: | ||
grid[i][M - j - 1] = 'c' | ||
|
||
# special cases | ||
if C + count == M and R == 0: | ||
for i in range(N): | ||
grid[i][-1] = "e" | ||
|
||
elif C + count == M and R != 0: | ||
for i in range((N - R) // 2): | ||
grid[i][0] = "e" | ||
grid[N - i - 1][0] = 'e' | ||
|
||
# print ans | ||
for row in grid: | ||
print("".join(str(i) for i in row)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters