시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 15 | 9 | 9 | 60.000% |
Alice is living in JOI Kingdom. She will invite Bob, who is living in Republic of IOI. Before she invites him, she is planning to send the airline route map of JOI Kingdom to him. JOI Kingdom is an island country consisting of N islands, numbered from 0 to N−1. There are M airline routes in JOI Kingdom. For each i (0 ≤ i ≤ M−1), the (i + 1)-th airline route connects the island Ai and the island Bi, in both directions. No two airline routes connect the same two islands. She must use a special telegraph machine operated by JOI Kingdom. She can send an undirected graph using the telegraph machine. However, when she uses it, the numbers of the vertices and the number of the edges will be shuffled randomly.
Precisely, the information will be sent as follows. Let G be the graph sent by Alice. (Let V be the number of vertices of G, and U the number of edges of G.)
Note that only a simple graph can be sent using this telegraph machine. Here, a simple graph means a graph without multiple edges and self-loops.
In other words, she can send a graph satisfying the following conditions: (Ci, Di) , (Cj, Dj) and (Ci, Di) , (Dj, Cj) are satisfied for every i, j (0 ≤ i < j ≤ U − 1), and Ci, Di is satisfied for every i (0 ≤ i ≤ U − 1).
Alice wants to send the airline route map of JOI Kingdom to Bob using a graph with minimum number of vertices.
In order to help communication between Alice and Bob, write the following two programs:
You need to submit two files.
The first file is Alice.cpp
. This file outputs information of the graph sent by Alice. It should implement the following function. The program should include Alicelib.h
.
void Alice( int N, int M, int A[], int B[] )
N
is the number of islands of JOI Kingdom.M
is the number of airline routes in JOI Kingdom.A[]
, B[]
are sequences of length M describing the airline route map of JOI Kingdom.Using the following functions, the function Alice
outputs information of the graph G sent by Alice.
void InitG( int V, int U )
V
is the number of vertices of G. The parameter V
should be an integer between 1 and 1500, inclusive. If the call to this function has parameters outside this range, your program is considered as Wrong Answer [1].U
is the number of edges of G. The parameter U
should be an integer between 0 and V(V − 1)/2, inclusive. If the call to this function has parameters outside this range, your program is considered as Wrong Answer [2].void MakeG( int pos, int C, int D )
pos
is the number of the edge specified by the call. The parameter pos
should be an integer between 0 and U − 1, inclusive. If the call to this function has parameters outside this range, your program is considered as Wrong Answer [3]. This function should not be called more than once with the same parameter pos. If this function is called more than once with the same parameter, your program is considered as Wrong Answer [4].C
and D
are the vertices of the edge pos of the graph G. C
and D
should be integers between 0 and V − 1, inclusive. Also, C
≠ D
should be satisfied. If C
or D
does not satisfy these conditions, your program is considered as Wrong Answer [5].Here, U and V are the integers specified by InitG
.
In the function Alice
, after calling the function InitG
once, the function MakeG
should be called exactly U times. If the function InitG
is called twice, your program is considered as Wrong Answer [6]. If the function MakeG
is called before the function InitG
is called, your program is considered as Wrong Answer [7]. If InitG
is not called when the function Alice
terminates, or, the function MakeG
is not called U times, your program is considered as Wrong Answer [8]. When the function Alice
terminates, if the graph G described by Alice
is not a simple graph, your program is considered as Wrong Answer [9].
If the call to the function Alice
is considered Wrong Answer, your program is terminated immediately.
The second file is Bob.cpp
. This file outputs, given information of the graph G received by Bob, the airline route map of JOI Kingdom. It should implement the following function. The program should include Boblib.h
.
void Bob( int V, int U, int C[], int D[] )
V
is the number of vertices of the graph G.U
is the number of edges of the graph G.C[]
, D[]
are sequences of length U describing the edges of the graph G.Using the following functions, the function Bob
recovers the airline route map of JOI Kingdom, and outputs information of the airline route map.
void InitMap( int N, int M )
N
is the recovered number of islands in JOI Kingdom. N
is an integer which should be equal to the actual number of islands in JOI Kingdom. If they are not equal, your program is considered as Wrong Answer [10].M
is the recovered number of airline routes in JOI Kingdom. M
is an integer which should be equal to the actual number of airline routes in JOI Kingdom. If they are not equal, your program is considered as Wrong Answer [11].void MakeMap( int A, int B )
A
and B
mean there is an airline route connecting the island A
and the island B
. A
and B
are integers between 0 and N − 1, inclusive. Also, A
≠ B
should be satisfied. If A
or B
does not satisfy these conditions, your program is considered as Wrong Answer [12]. If there does not exist an airline route connecting the island A
and the island B
in JOI Kingdom, your program is considered as Wrong Answer [13]. The airline route described by a call to this function should be different from the airline routes of previous calls. When MakeMap( A, B )
is called, if either MakeMap( A, B )
or MakeMap( B, A )
was already called before, your program is considered as Wrong Answer [14].Here, N is the integer value specified by InitMap
.
In the function Bob
, after calling the function InitMap
once, the function MakeMap
should be called exactly M times. If the function InitMap
is called twice, your program is considered as Wrong Answer [15]. If the function MakeMap
is called before the function InitMap
is called, your program is considered as Wrong Answer [16]. If InitMap
is not called when the function Bob
terminates, or, the function MakeMap
is not called M times, your program is considered as Wrong Answer [17]. Here, M is the integer value specified by InitMap
.
If the call to the function Bob
is considered Wrong Answer, your program is terminated immediately.
The sample grader reads the following data from the standard input.
When the program terminates successfully, the sample grader writes the following information to the standard output. (The quotation mark is not written actually.)
Wrong Answer [1]
” and terminates.Alice
and Bob
are not considered as Wrong Answer, the sample grader writes “Accepted.
” It also outputs the value of V.If your program is considered as several types of Wrong Answer, the sample grader reports only one of them.
Here is a sample input for sample grader and corresponding function calls.
Sample Input 1 | Sample Calls | |||
---|---|---|---|---|
Call | Return | Call | Return | |
4 3 0 1 0 2 0 3 |
Alice(...) |
|||
InitG(4,3) |
||||
(none) | ||||
MakeG(0,0,1) |
||||
(none) | ||||
MakeG(1,0,2) |
||||
(none) | ||||
MakeG(2,0,3) |
||||
(none) | ||||
(none) | ||||
Bob(...) |
||||
InitMap(4,3) |
||||
(none) | ||||
MakeMap(0,1) |
||||
(none) | ||||
MakeMap(0,2) |
||||
(none) | ||||
MakeMap(0,3) |
||||
(none) | ||||
(none) |
In this case, the parameters given to the functions Alice(...)
, Bob(...)
are as follows.
Parameters | Alice(...) |
Bob(...) |
---|---|---|
N |
4 | |
M |
3 | |
V |
4 | |
U |
3 | |
A |
{0, 0, 0} | |
B |
{1, 2, 3} | |
C |
{2, 2, 2} | |
D |
{3, 0, 1} |
번호 | 배점 | 제한 |
---|---|---|
1 | 22 | N ≤ 10. |
2 | 15 | N ≤ 40. |
3 | 63 | There are no additional constraints. |
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)