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 |
|---|---|---|---|---|---|---|
| 2115 | Codeforces Round 1028 (Div. 1) | FINISHED | False | 7200 | 27703523 | May 31, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 3945 ) | B | Gellyfish and Camellia Japonica | PROGRAMMING | constructive algorithms dfs and similar dp graphs greedy |
Gellyfish has an array of (n) integers (c_1, c_2, \ldots, c_n). In the beginning, (c = a_1, a_2, \ldots, a_n). Gellyfish will make (q) modifications to (c). For (i = 1,2,\ldots,q), Gellyfish is given three integers (x_i), (y_i), and (z_i) between (1) and (n). Then Gellyfish will set (c_{z_i} := \min(c_{x_i}, c_{y_i})). After the (q) modifications, (c = b_1, b_2, \ldots, b_n). Now Flower knows the value of (b) and the value of the integers (x_i), (y_i), and (z_i) for all (1 \leq i \leq q), but she doesn't know the value of (a). Flower wants to find any possible value of the array (a) or report that no such (a) exists. If there are multiple possible values of the array (a), you may output any of them. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains two integers (n) and (q) ((1 \leq n, q \leq 3 \cdot 10^5)) — the size of the array and the number of modifications. The second line of each test case contains (n) integers (b_1, b_2, \ldots, b_n) ((1 \leq b_i \leq 10^9)) — the value of the array (c) after the (q) modifications. The following (q) lines each contain three integers (x_i), (y_i), and (z_i) ((1 \leq x_i, y_i, z_i \leq n)) — describing the (i)-th modification. It is guaranteed that the sum of (n) and the sum of (q) over all test cases does not exceed (3 \cdot 10^5). For each test case, if (a) exists, output (n) integers (a_1, a_2, \ldots, a_n) ((0 \leq a_i \leq 10^9)) in a single line. Otherwise, output "-1" in a single line. If there are multiple solutions, print any of them. In the first test case, based on the given sequence of modifications, we know that (b_1 = a_1) and (b_2 = \min(a_1, a_2)). Therefore, it |
| Codeforces Round 1028 (Div.1, Div.2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 322314781 | tfgs | B | May 31, 2025, 7:40 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 281 | 11878400 | ||
| 322304191 | ArgintLaAnu | B | May 31, 2025, 6:08 p.m. | OK | C++17 (GCC 7-32) | TESTS | 17 | 296 | 4710400 | ||
| 322336318 | _O_v_O_ | B | June 1, 2025, 3:36 a.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 296 | 7270400 | ||
| 322316434 | doraji_muchim | B | May 31, 2025, 8:01 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 296 | 9420800 | ||
| 322260526 | 0gur4ik | B | May 31, 2025, 3:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 15 | 311 | 2355200 | ||
| 322330145 | kingofpineapples | B | June 1, 2025, 1:54 a.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 311 | 3481600 | ||
| 322252726 | potato167 | B | May 31, 2025, 3:35 p.m. | OK | C++17 (GCC 7-32) | TESTS | 15 | 311 | 3584000 | ||
| 322308535 | man_of_learning | B | May 31, 2025, 6:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 311 | 4812800 | ||
| 322310131 | IamNewbie | B | May 31, 2025, 6:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 18 | 311 | 7270400 | ||
| 322301227 | cescmentation_folch | B | May 31, 2025, 5:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 17 | 312 | 3481600 | ||
| 322247091 | beta99999 | B | May 31, 2025, 3:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 93 | 3686400 | ||
| 322219704 | shiomusubi496 | B | May 31, 2025, 3 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 109 | 11366400 | ||
| 322332324 | EternalJourney | B | June 1, 2025, 2:36 a.m. | OK | C++20 (GCC 13-64) | TESTS | 19 | 218 | 3584000 | ||
| 322307254 | Shahrad_Mirzaei | B | May 31, 2025, 6:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 218 | 19456000 | ||
| 322289636 | fisher199 | B | May 31, 2025, 4:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 233 | 3584000 | ||
| 322308980 | undercat | B | May 31, 2025, 6:42 p.m. | OK | C++20 (GCC 13-64) | TESTS | 18 | 234 | 3584000 | ||
| 322263218 | sjm150 | B | May 31, 2025, 3:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 234 | 3584000 | ||
| 322328037 | Little_Sheep_Yawn | B | June 1, 2025, 12:51 a.m. | OK | C++20 (GCC 13-64) | TESTS | 19 | 234 | 3891200 | ||
| 322246659 | Kustov_Vadim_533 | B | May 31, 2025, 3:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 234 | 7270400 | ||
| 322284709 | Agreb | B | May 31, 2025, 4:20 p.m. | OK | C++20 (GCC 13-64) | TESTS | 15 | 249 | 3481600 | ||
| 322235213 | adamant | B | May 31, 2025, 3:15 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 92 | 20582400 | ||
| 322214140 | yosupo | B | May 31, 2025, 2:55 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 124 | 3686400 | ||
| 322218946 | furry | B | May 31, 2025, 2:59 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 124 | 10444800 | ||
| 322199524 | maspy | B | May 31, 2025, 2:44 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 124 | 14233600 | ||
| 322283368 | koizy | B | May 31, 2025, 4:18 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 140 | 3788800 | ||
| 322338260 | cooluo | B | June 1, 2025, 4:04 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 19 | 171 | 32665600 | ||
| 322251260 | cooluo | B | May 31, 2025, 3:33 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 15 | 186 | 32768000 | ||
| 322334115 | lcyxds | B | June 1, 2025, 3:01 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 19 | 233 | 8499200 | ||
| 322315453 | Jsonhwrd | B | May 31, 2025, 7:49 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 18 | 233 | 10854400 | ||
| 322345030 | risujiroh | B | June 1, 2025, 5:32 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 19 | 234 | 3584000 | ||
| 322245587 | pengin_2000 | B | May 31, 2025, 3:26 p.m. | OK | GNU C11 | TESTS | 15 | 249 | 7270400 | ||
| 322211190 | Dominion948 | B | May 31, 2025, 2:53 p.m. | OK | Go | TESTS | 15 | 577 | 45772800 | ||
| 322281720 | sahasrad | B | May 31, 2025, 4:15 p.m. | OK | Java 21 | TESTS | 15 | 1124 | 63078400 | ||
| 322263138 | golions | B | May 31, 2025, 3:48 p.m. | OK | Java 8 | TESTS | 15 | 483 | 14233600 | ||
| 322313415 | kasiru_69 | B | May 31, 2025, 7:24 p.m. | OK | Java 8 | TESTS | 18 | 936 | 43827200 | ||
| 322276346 | jueviolegrace | B | May 31, 2025, 4:07 p.m. | OK | Java 8 | TESTS | 15 | 1234 | 39014400 | ||
| 322271977 | omdeshmukh1906 | B | May 31, 2025, 4 p.m. | OK | Java 8 | TESTS | 15 | 1702 | 19558400 | ||
| 322321127 | darnley | B | May 31, 2025, 9:17 p.m. | OK | Kotlin 1.9 | TESTS | 19 | 968 | 39321600 | ||
| 322231858 | darnley | B | May 31, 2025, 3:12 p.m. | OK | Kotlin 1.9 | TESTS | 15 | 999 | 39628800 | ||
| 322213579 | conqueror_of_tourist | B | May 31, 2025, 2:55 p.m. | OK | PyPy 3-64 | TESTS | 15 | 359 | 46182400 | ||
| 322303778 | samchen123 | B | May 31, 2025, 6:05 p.m. | OK | PyPy 3-64 | TESTS | 17 | 421 | 58982400 | ||
| 322221482 | Kira_Dev | B | May 31, 2025, 3:02 p.m. | OK | PyPy 3-64 | TESTS | 15 | 452 | 57036800 | ||
| 322251647 | harurun4635 | B | May 31, 2025, 3:33 p.m. | OK | PyPy 3-64 | TESTS | 15 | 453 | 68915200 | ||
| 322272011 | ckuhn222 | B | May 31, 2025, 4 p.m. | OK | PyPy 3-64 | TESTS | 15 | 468 | 58572800 | ||
| 322235003 | dyppp | B | May 31, 2025, 3:15 p.m. | OK | PyPy 3-64 | TESTS | 15 | 499 | 63488000 | ||
| 322216039 | toam | B | May 31, 2025, 2:57 p.m. | OK | PyPy 3-64 | TESTS | 15 | 499 | 64102400 | ||
| 322303251 | accelerate_nju | B | May 31, 2025, 6:02 p.m. | OK | PyPy 3-64 | TESTS | 17 | 499 | 66457600 | ||
| 322282826 | tassei903 | B | May 31, 2025, 4:17 p.m. | OK | PyPy 3-64 | TESTS | 15 | 515 | 71987200 | ||
| 322302833 | accelerate_nju | B | May 31, 2025, 6 p.m. | OK | PyPy 3-64 | TESTS | 17 | 531 | 67174400 | ||
| 322301436 | Jimanbanashi | B | May 31, 2025, 5:52 p.m. | OK | Python 2 | TESTS | 17 | 1218 | 53862400 |
Back to search problems