Skip to content

pihedron/nzoi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NZOI Solutions

This project contains solutions to some of the problems on the NZOI Training Website.

Languages

I solved most of the problems using Python, but for some of them I used C#, JavaScript, or Java. It is better to use Java or C++ because they are the standard choice for the International Olympiad in Informatics.

Time Complexity

For some graph problems like Sunsprint, Python is not fast enough to complete all subtasks. Each folder may contain a README.md file for guidance on the problem.

Common Algorithms

Dijkstra

def dijkstra(adj, n, start, end):
    heap = [(0, start)]
    visited = [False] * n
    dist = [10 ** 9 for _ in range(n)]
    dist[start] = 0
    while heap:
        (d, u) = heapq.heappop(heap)
        if visited[u]:
            continue
        visited[u] = True
        if u == end:
            break
        for (v, w) in adj[u]:
            if visited[v]:
                continue
            d = dist[u] + w
            if dist[v] > d:
                dist[v] = d
                heapq.heappush(heap, (dist[v], v))
    return dist[end]

About

New Zealand Olympiad in Informatics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published