Problem 3: Squawk Virus
https://open.kattis.com/problems/squawk
In this problem, you are tasked with figuring out how many "squawks" have built up in a graph, given a starting node and a time. This problem becomes significantly easier when we notice one thing: the size of the input! With input this small, this devolves into a simulation problem.
The value of a node i at time j is: value[i][j] = ∑ value[k][i-1], where k is a neighbor of i. At the end, we simply sum up all of the squawks generated at time t.
On Implementation:
Keep a two dimensional array, with one dimension representing the amount of squawks, and the other representing time. Then, you can use 3 for loops to sum up the amount of squawks per neighbour for a given node at a given time.
Watch out for integer overflow!
Last updated