LogoLogo
  • CP Gymnasium
  • Week 3 Math / Number Theory
    • Week 3 Math / Number Theory
      • Problem 1: Tetration
      • Problem 2: Peragrams
      • Problem 3: Veci
      • Problem 4: Architecture
      • Problem 5: Joint Attack
      • Problem 6: How Many Digits?
      • Problem 7: Abstract Painting
  • Week 4 Array / Greedy
    • Week 4 Array / Greedy
      • Problem 1: Vaccine Efficacy
      • Problem 2: Frosh Week
      • Problem 3: Inquiry
      • Problem 4: Bank Queue
      • Problem 5: Log Land
  • Week 6 Sorting / Binary Search
    • Week 6 Sorting / Binary Search
      • Problem 1: Falling Apart
      • Problem 2: Synchronizing Lists
      • Problem 3: Distributing Ballot Boxes
      • Problem 4: Financial Planning
      • Problem 5: Big Boxes
  • Week 7 Dynamic Programming
    • Week 7 Dynamic Programming
      • Problem 1: Ocean's Anti-11
      • Problem 2: Batmanacci
      • Problem 3: Radio Commercials
      • Problem 4: Welcome to Code Jam (Hard)
      • Problem 5: Honeycomb Walk
  • Week 8 Graph Traversals
    • Week 8 Graph Traversals
      • Problem 1: Reachable Roads
      • Problem 2: Money Matters
      • Problem 3: Squawk Virus
      • Problem 4: Beehives
      • Problem 5: Running MoM
      • Problem 6: Amanda Lounges
Powered by GitBook
On this page
  1. Week 8 Graph Traversals
  2. Week 8 Graph Traversals

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!

PreviousProblem 2: Money MattersNextProblem 4: Beehives

Last updated 4 years ago