※ Use C++17.
This is a two-step problem.
Yudam wants to secretly deliver one edge to Dadas.
The process acting as Yudam receives a simple connected undirected graph with vertices and an edge that does not belong to . Yudam adds to and must assign a direction to every edge of the resulting graph.
The judge applies the directions returned by Yudam. It then independently renumbers all vertices and all edges in an arbitrary order. A fresh process acting as Dadas receives only the resulting simple connected directed graph. Dadas does not know any original vertex or edge number.
Dadas must return the current number of the edge added by Yudam.
No memory, file, global variable, or other state is shared between the two processes. The only information Yudam may pass to Dadas is the oriented graph itself. The strategy must succeed for every renumbering of the vertices and edges.
Include the provided header using and implement the functions yoodam and dadas. Do not implement main. The judge calls the two functions once each in separate processes.
Input
You must implement the following two functions.
std::string yoodam(
int N,
std::vector<int> U,
std::vector<int> V,
int a,
int b
);
int dadas(
int N,
std::vector<int> X,
std::vector<int> Y
);
The function yoodam is called first in the process acting as Yudam.
Let . For each (), edge connects and . The parameters and are the vertex numbers of the two endpoints of the edge to be added. In other words, , and the edge connecting vertices and does not belong to .
The function dadas is then called in a fresh process acting as Dadas.
Let . For each (), current edge is directed from to . The vertex numbers and edge numbers are independently renumbered in arbitrary orders after the call to yoodam.
Output
The function yoodam must return a binary string of length .
For , if , orient edge from to ; if , orient it from to .
If , orient the added edge from to ; if , orient it from to .
The function dadas must return the current number of the edge added by Yudam. The return value must be an integer from to .
Constraints
- For each judge case,
yoodamanddadasare each called once in separate processes. - .
- .
- ().
- is a simple connected undirected graph.
- .
- Edge does not belong to .
- .
- ().
Subtasks
Samples
Sample grader
The attached sample_grader.cpp calls the submitted yoodam function, applies the returned directions, and renumbers the vertices and edges using a fixed deterministic shuffle. It then calls dadas in the same execution.
The input format of the sample grader is as follows.
The sample grader prints the following values.
- : if the value returned by
yoodamhas a valid format and ; otherwise, . - : the actual current edge number of the added edge after the vertex and edge renumbering. It is if the value returned by
yoodamhas an invalid format. - : the value returned by
dadas. It is if the value returned byyoodamhas an invalid format.
In this example, the current number of the added edge is , and dadas also returns , so the first printed value is .
In the actual judge, yoodam and dadas run in separate processes, and the vertex and edge renumbering may differ from the sample grader. Therefore, a solution that shares state between the two functions through global variables, static variables, files, or similar mechanisms will not work in the actual judge.