#P15583. [KTSC 2026] 通信网络 2 / Communication Network 2
[KTSC 2026] 通信网络 2 / Communication Network 2
Background
Note: You can get more sample tests in the attachments.
Problem Description
There is an undirected graph with vertices, numbered . There are no self-loops in this graph. Initially, the graph has no edges.
You are given edge sets . For , at time , take the XOR (symmetric difference) of and the current edge set of the graph. In other words, let the current edge set be , and for every :
- If is in , delete from .
- Otherwise, add to .
For a non-negative integer and two vertices , we say that are connected at time if and only if at time there exists a path connecting and . In particular, if , then by definition this statement is always true for any .
Furthermore, for integers and two vertices , we say that are connected during the time interval if and only if are connected at every time .
There are queries. Each query gives . Return the number of vertices such that are connected during the time interval (, , ).
Implementation Details
This is a functional interactive problem. You do not need to, and should not, implement the main function.
You should implement the following function:
vector<int> count_computers(int N, int T, int Q, vector<vector<array<int, 2>>> E, vector<array<int, 3>> F)
- : an array storing the edge sets. The size of is . Each is a non-empty edge array representing the set . Each edge is given as an array of size , with elements in order, representing an edge connecting vertices and .
- : an array storing the queries. The size of is . For any , represents the -th query. Each query is given as an array of size , with elements in order, where is a vertex and is a time interval.
- Return an array of size . For any , is the answer to the -th query.
- This function is called exactly once.
Your source code must not call any input/output functions.
Input Format
The input format of the sample grader program is as follows. denotes the size of the set , and .
- Line : .
- For all :
- Line : .
- Line (): (the two endpoints of the -th edge in ).
- Line (): (each element of ).
Output Format
The sample grader program outputs the answers in the following format:
- Line (): .
4 5 7
2
0 1
1 2
2
2 3
1 3
2
0 1
0 3
4
0 1
1 2
0 3
2 3
1
1 3
1 1 1
2 2 2
3 3 3
0 0 5
2 1 3
1 1 4
3 2 3
3
4
4
1
3
2
4
Hint
Constraints
- .
- .
- .
- is an edge set, and all edges inside it are pairwise distinct.
- Let , then .
- For every edge given in the input, .
- For every query given in the input, .
Subtasks
| ID | Score | Limit |
|---|---|---|
| For all queries, | ||
| For all edges given in , | ||
| No additional constraints |
Sample
Consider the following call.
count_computers(4, 5, 7, [[[0, 1], [1, 2]], [[2, 3], [1, 3]], [[0, 1], [0, 3]], [[0, 1], [1, 2], [0, 3], [2, 3]], [[1, 3]], [[1, 1], [2, 2], [3, 3], [0, 0], [0, 5]], [[2, 1, 3], [1, 1, 4], [3, 2, 3]]])
There are vertices in the graph.
At each time, the graph is as follows:
- At time : edges.
- At time : edges: .
- At time : edges: .
- At time : edges: .
- At time : edges: .
- At time : edge: .
A total of queries are given:
- Query : At time , vertex is connected to the set .
- Query : At time , vertex is connected to the set .
- Query : At time , vertex is connected to the set .
- Query : Since there are no edges at time , from time to , vertex is only connected to vertex .
- Query : From time to , vertex is connected to the set .
- Query : From time to , vertex is connected to the set .
- Query : From time to , vertex is connected to the set .
Therefore, the function should return .
You can get more sample tests in the attachments.
Translated by ChatGPT 5