Graphs and Graphs
Time limit1sMemory limit1024 MB
Given a line Ax + By = C, add a directed edge from x to y for every integer point (x, y) with 1 to 10 on the line, then print each vertex's out-neighbors.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
Dagwak heard in his informatics class that graphs would be covered, so he decided to study ahead. But he ended up studying graphs on the coordinate plane instead of graph theory.
Dagwak drew the line given by the equation on the coordinate plane. He wants to turn this graph into a directed graph made of vertices and edges. There are 10 vertices, numbered 1 through 10 with distinct integers. Initially the graph has no edges. For two integers and between 1 and 10 inclusive, if the line passes through the point , Dagwak adds exactly one edge from vertex to vertex . An edge whose start and end are the same vertex can also be added.
Print the new graph that Dagwak builds through this process.
Input
The first line contains the coefficients , , and of the equation , separated by spaces.
, , and are integers, and and are never both 0.
Output
Print 10 lines. On the i-th line, print the numbers of the vertices that can be reached from vertex i by passing through exactly one edge, in ascending order, separated by spaces. If there are none, print 0 instead.