Read this first — it is the point of the contest
A grid is a graph. A dependency list is a graph. A set of flights is a graph. Once you see the nodes and edges, the algorithm is already chosen for you.
| What you are asked | What to use |
|---|---|
| Can I reach it? Are these connected? | DFS or BFS |
| Shortest path, unweighted | BFS |
| Shortest path, weighted, positive | Dijkstra |
| Is there a cycle? Valid ordering? | Topological sort (Kahn's algorithm) |
| Level by level | BFS, processing one level at a time |
from collections import deque
def bfs(start, neighbours):
seen = {start}
queue = deque([start])
while queue:
node = queue.popleft()
for nxt in neighbours(node):
if nxt not in seen:
seen.add(nxt)
queue.append(nxt)
return seen
This week is the hardest set so far. Read the brief, then attempt them in order.
Contest points are awarded for solutions written in the editor. We record how much of each submission was typed versus pasted — a pasted solution still counts as solved for your own learning, but it does not score here. This is stated up front so nobody is caught out.
Nobody on the board yet
Earn XP by finishing lessons, solving problems and reviewing — the first people to do so appear here.