Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 2034 | Rayan Programming Contest 2024 - Selection (Codeforces Round 989, Div. 1 + Div. 2) | FINISHED | False | 10800 | 43428323 | Nov. 30, 2024, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 77 ) | G2 | Simurgh's Watch (Hard Version) | PROGRAMMING | greedy implementation |
The only difference between the two versions of the problem is whether overlaps are considered at all points or only at integer points. The legendary Simurgh , a mythical bird, is responsible for keeping watch over vast lands, and for this purpose, she has enlisted (n) vigilant warriors. Each warrior is alert during a specific time segment (l_i, r_i), where (l_i) is the start time (included) and (r_i) is the end time (included), both positive integers. One of Simurgh's trusted advisors, Zal , is concerned that if multiple warriors are stationed at the same time and all wear the same color, the distinction between them might be lost, causing confusion in the watch. To prevent this, whenever multiple warriors are on guard at the same integer moment, there must be at least one color which is worn by exactly one warrior. So the task is to determine the minimum number of colors required and assign a color (c_i) to each warrior's segment (l_i, r_i) such that, for every (integer) time (t) contained in at least one segment, there exists one color which belongs to exactly one segment containing (t). The first line contains a single integer (t) ((1 \leq t \leq 10^4)) — the number of test cases. For each test case: The first line contains an integer (n) ((1 \leq n \leq 2 \cdot 10^5)) — the number of warriors stationed by Simurgh. The next (n) lines each contain two integers (l_i) and (r_i) ((1 \leq l_i \leq r_i \leq 10^9)) — the start and end times of the warrior's watch segment. The sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case: Output the minimum number of colors (k) needed. Then, output a line of (n) integers (c_i) ((1 \leq c_i \leq k)), where each (c_i) is the color assigned to the (i)-th warrior. We can represent each warrior's watch segment as an interval on the X-axis; In test case 1, the intervals can be colored as shown be |
| Rayan 2024 Selection Round Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 294090902 | orzdevinwang | G2 | Nov. 30, 2024, 5:31 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 390 | 167628800 | ||
| 294096375 | maroonrk | G2 | Nov. 30, 2024, 6:29 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 452 | 69939200 | ||
| 294091710 | LMydd0225 | G2 | Nov. 30, 2024, 5:33 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 1078 | 150630400 | ||
| 294102835 | Benq | G2 | Nov. 30, 2024, 7:17 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 1327 | 110284800 | ||
| 294099899 | rainboy | G2 | Nov. 30, 2024, 6:55 p.m. | OK | GNU C11 | TESTS | 40 | 999 | 11161600 |
Back to search problems