Router 1
Time limit2sMemory limit512 MB
Print either a star-shaped router with one internal hub or a fully connected bipartite router, depending on whether N*N exceeds P_lim.
- Level
Easy3 of 10
- Topics
- Graph, Implementation, Simulation
- Solved
- No attempts yet
Problem
Henry and Hetty were hired by a networking company. Their first project is a new router, the Connect Ethernet Operating Interface, built from:
- input nodes, numbered from to ;
- output nodes, numbered from to ;
- internal nodes, numbered from to ;
- unidirectional direct connections, each joining two distinct nodes.
A node can send data to a node (equivalently, can receive data from ) if one of the following holds:
- ;
- there is a node such that can send data to and a direct connection runs from to .
If can send data to and , the data path from to is the set of direct connections with , and .
A router works properly when all of the following hold:
- every input node can send data to every output node;
- every input node can receive data only from itself;
- every output node can send data only to itself;
- for any two nodes and with , if can send data to , then cannot send data to ;
- for any two nodes and with , if can send data to , then the data path from to is unique. In particular, any two nodes are joined by at most one direct connection.
The power needed to operate node is , where is the number of input nodes that can send data to and is the number of output nodes that can receive data from . Writing for the total number of nodes, the maximum power used by the router is .
You are given , and . Build a router that works properly, has exactly input nodes and output nodes, uses at most direct connections, has , and uses at most nodes in total. Several routers meet such a specification, so the output section fixes the single one you must print.
Input
One line with three integers , and : the number of input nodes and of output nodes, the largest number of direct connections allowed, and the largest power the router may use (, , ).
It is guaranteed that and that the router described in the output section uses at most direct connections.
Output
Print the router picked by the rule below.
If , print the router with one internal node. It has nodes and direct connections: first the connections for in increasing order of , then the connections for in increasing order of .
Otherwise print the router with no internal node. It has nodes and direct connections, namely for every pair , sorted by increasing and, for equal , by increasing.
The first line holds and separated by a space. Each of the next lines holds two integers and , meaning a direct connection from node to node was built.