| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 30 초 (추가 시간 없음) | 2048 MB | 3 | 3 | 3 | 100.000% |
A region consists of $N$ cities, numbered from $1$ to $N$. These cities may establish treaties, which indicate their willingness to collaborate with each other.
An alliance is a group of cities where each city is connected to every other city in the group through one or more treaties. The size of an alliance is the number of cities that belong to that alliance.
Each treaty has a length, representing the number of pages used to draft it. To reduce bureaucracy, cities will occasionally remove the longest active treaty (i.e., the one with the highest page count).
Beyond administrative matters, the cities also engage in dodgeball rounds between alliances. A dodgeball round follows the following rules:
You must determine the minimum possible total unfairness score by optimally pairing the alliances.
You must support $Q$ queries of the following types:
a: Add a treaty between cities $u$ and $v$ with $p$ pages.r: Remove the longest treaty (the one with the highest page count). All page counts are unique.d: Compute the minimum unfairness score for a dodgeball round based on the current alliances.Queries of type d must be answered immediately upon request, before processing any further queries.
The program should read:
a $u$ $v$ $p$rdFor each query of type d, the program should immediately output the corresponding answer before processing further queries. You must also flush the output immediately, e.g.:
std::cout << std::endl;print("", flush=True)a query| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 9 | $N \le 10, Q \le 20$ |
| 2 | 10 | $N \le 2000, Q \le 4000$ |
| 3 | 6 | At most 10 |
| 4 | 17 | For each |
| 5 | 14 | Treaties are created in increasing page count order |
| 6 | 26 | Treaties are created in decreasing page count order |
| 7 | 18 | No additional constraints |
3 5 a 1 2 1 a 2 3 2 d r d
3 1
When the first dodgeball tournament is played, cities $1$, $2$, and $3$ are all in one alliance of size $3$, so they play against an empty alliance of size $0$, giving $|3-0| = 3$.
Then the treaty between cities $2$ and $3$ is removed. The alliances become $\{1,2\}$ and $\{3\}$, giving an unfairness score of $|2-1| = 1$.
6 10 a 2 3 10 a 1 2 5 a 3 4 8 d r d a 4 5 1 a 3 6 7 r d
4 0 2
In the first round, alliances have sizes $4$, $1$, and $1$, giving total unfairness $4$.
In the second round, alliances have sizes $2$, $2$, $1$, and $1$, giving total unfairness $0$.
In the third round, there are three alliances of size $2$, giving total unfairness $2$.
Olympiad > Nordic Olympiad in Informatics > 2025 A번