samedi 25 avril 2020

How to construct a graph with given constraint of size and time?

I am unable to find a method to construct a graph which has n row and m column. And it has 'k' edges with the weight of order 10^18 and all other edges with the weight of order 10^6. In this graph, I have to find all path from a fixed node to a variable node such that its product is divisible by a number X (X is of order 10^19).

The constraint of size is 246MB and time is 3s.
The problem I am facing is how to construct such a big graph that does not cause overflow as size do not exceed 246 MB as in worst case m*n = 10^12 element. If we assume all are 4byte than the total size of the array will 10^12 * 4 byte which is much larger.
link to problem : https://www.hackerearth.com/challenges/competitive/april-circuits-20/algorithm/avoid-corona-paths-32f67235/

Aucun commentaire:

Enregistrer un commentaire