CSES - Download

A network has nn computers and there are connecting links between them. Each link can be used for sending a certain number of bits per second from one computer to the other.

Your task is to find out what is the maximum number of bits per second that can be send from a given computer to another.

In a file download.py, implement the class Download with the following methods:

  • add_link adds a connecting link from a computer aa to a computer bb capable of moving xx bits per second
  • max_data returns the maximum bit rate from a computer aa to a computer bb
class Download:
    def __init__(self, n):
        # TODO

    def add_link(self, a, b, x):
        # TODO

    def max_data(self, a, b):
        # TODO

if __name__ == "__main__":
    download = Download(4)

    print(download.max_data(1, 4)) # 0

    download.add_link(1, 2, 5)
    download.add_link(2, 4, 6)
    download.add_link(1, 4, 2)
    print(download.max_data(1, 4)) # 7

    download.add_link(1, 3, 4)
    download.add_link(3, 2, 2)
    print(download.max_data(1, 4)) # 8