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 |
|---|---|---|---|---|---|---|
| 2233 | Educational Codeforces Round 191 (Rated for Div. 2) | FINISHED | False | 7200 | 4807472 | June 9, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 3432 ) | D | Goods on the Shelf | PROGRAMMING | brute force data structures two pointers |
In a supermarket, goods of the same type are usually placed next to each other so that the shelf looks neat and it is easier for customers to find what they need. The shelf is described by an array (a) of (n) elements, where (a_i) is the type of the good at position (i). We will say that the shelf is arranged correctly if for every two positions (i) and (j) such that (1 \le i \lt j \le n) and (a_i = a_j), the following condition holds: for each (k) from (i) to (j), it is true that (a_k = a_i). In other words, goods of each type on the shelf must form one contiguous block. You are allowed to choose two different positions at most once and swap the goods at these positions. You may also choose not to perform any swap. Determine whether it is possible to make the shelf arranged correctly after that. 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 an integer (n) ((2 \le n \le 2 \cdot 10^{5})) — the number of goods on the shelf. The second line of each test case contains (n) integers (a_{i}) ((1 \le a_{i} \le 10^{9})), where (a_{i}) denotes the type of the good at position (i). Additional input constraints: the sum of (n) over all test cases does not exceed (2 \cdot 10^{5}). For each test case, output one of the following: NO , if it is impossible to arrange the shelf correctly; YES , if it is possible to make the shelf arranged correctly with at most one swap of two goods. You may output the answer in any case. For example, " YeS ", " YES ", " NO ", " nO " will also be accepted. In the first example, you can swap the goods at positions (1) and (2), after which the shelf will look like this: (2, 1, 1). In the second example, the shelf is already arranged correctly. In the third example, it is impossible to a |
| 154371 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 378132909 | anas_ahamad | D | June 10, 2026, 11:11 p.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 78 | 512000 | ||
| 378082549 | zzzjjj | D | June 10, 2026, 12:21 p.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 93 | 0 | ||
| 378090523 | hs9026431305 | D | June 10, 2026, 1:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 109 | 102400 | ||
| 378064438 | iyu0 | D | June 10, 2026, 10:17 a.m. | OK | C++17 (GCC 7-32) | TESTS | 51 | 109 | 2457600 | ||
| 378013948 | raycantcode | D | June 9, 2026, 7:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 51 | 109 | 15257600 | ||
| 378134311 | xiaodubaozi | D | June 11, 2026, 12:20 a.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 125 | 921600 | ||
| 378031471 | zz_zhao | D | June 10, 2026, 4:28 a.m. | OK | C++17 (GCC 7-32) | TESTS | 51 | 125 | 6860800 | ||
| 378109504 | hhhccc | D | June 10, 2026, 4:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 125 | 8089600 | ||
| 378095573 | wenxuesen | D | June 10, 2026, 2:21 p.m. | OK | C++17 (GCC 7-32) | TESTS | 52 | 140 | 2867200 | ||
| 377996077 | Shiv202020 | D | June 9, 2026, 4:34 p.m. | OK | C++17 (GCC 7-32) | TESTS | 51 | 140 | 3481600 | ||
| 378085495 | testGemi | D | June 10, 2026, 12:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 52 | 93 | 0 | ||
| 377995920 | Himanshu3480 | D | June 9, 2026, 4:34 p.m. | OK | C++20 (GCC 13-64) | TESTS | 51 | 93 | 26521600 | ||
| 378063693 | AshrafYousry | D | June 10, 2026, 10:10 a.m. | OK | C++20 (GCC 13-64) | TESTS | 51 | 109 | 0 | ||
| 377995535 | Bhavishitha_Raparthi | D | June 9, 2026, 4:34 p.m. | OK | C++20 (GCC 13-64) | TESTS | 51 | 109 | 102400 | ||
| 378043639 | creesh_krx | D | June 10, 2026, 7:09 a.m. | OK | C++20 (GCC 13-64) | TESTS | 51 | 109 | 204800 | ||
| 378082009 | silver_fir | D | June 10, 2026, 12:16 p.m. | OK | C++20 (GCC 13-64) | TESTS | 52 | 109 | 1638400 | ||
| 378091984 | UncleEvy | D | June 10, 2026, 1:48 p.m. | OK | C++20 (GCC 13-64) | TESTS | 52 | 109 | 2457600 | ||
| 378104390 | adityashukla.sun | D | June 10, 2026, 3:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 52 | 109 | 2560000 | ||
| 378019670 | BLACK0X80 | D | June 9, 2026, 9:54 p.m. | OK | C++20 (GCC 13-64) | TESTS | 51 | 109 | 3276800 | ||
| 378138310 | doclabinhduong | D | June 11, 2026, 2:46 a.m. | OK | C++20 (GCC 13-64) | TESTS | 52 | 109 | 3481600 | ||
| 378099946 | YGsuan | D | June 10, 2026, 3:05 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 52 | 78 | 0 | ||
| 378033849 | iamgreedy | D | June 10, 2026, 5:05 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 51 | 78 | 0 | ||
| 378007908 | Mechem-SEAW | D | June 9, 2026, 6:20 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 51 | 78 | 3379200 | ||
| 378049958 | Cyrillya | D | June 10, 2026, 8:07 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 51 | 78 | 6758400 | ||
| 378126777 | deffriann | D | June 10, 2026, 8:04 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 52 | 93 | 0 | ||
| 378116478 | aWFtYXJtYW4 | D | June 10, 2026, 5:52 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 52 | 93 | 0 | ||
| 378044550 | link1k | D | June 10, 2026, 7:18 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 51 | 93 | 0 | ||
| 378136051 | Tet0 | D | June 11, 2026, 1:33 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 52 | 93 | 204800 | ||
| 378128097 | ClutchBoyTim | D | June 10, 2026, 8:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 52 | 93 | 1228800 | ||
| 378051695 | benett_shines | D | June 10, 2026, 8:22 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 51 | 93 | 3379200 | ||
| 378115579 | abhishek.mahto2025 | D | June 10, 2026, 5:44 p.m. | OK | Java 21 | TESTS | 52 | 453 | 26828800 | ||
| 378092773 | NpHardcore_05 | D | June 10, 2026, 1:55 p.m. | OK | Java 21 | TESTS | 52 | 562 | 39936000 | ||
| 378106224 | GuLLu05 | D | June 10, 2026, 4:12 p.m. | OK | Java 21 | TESTS | 52 | 625 | 57856000 | ||
| 378015961 | hg_2005 | D | June 9, 2026, 8:15 p.m. | OK | Java 21 | TESTS | 51 | 671 | 10752000 | ||
| 377995359 | KartikeyThawait19 | D | June 9, 2026, 4:33 p.m. | OK | Java 21 | TESTS | 51 | 718 | 7270400 | ||
| 378026360 | AdityaPandey208 | D | June 10, 2026, 2:52 a.m. | OK | Java 21 | TESTS | 51 | 718 | 26726400 | ||
| 378059962 | neilchetty | D | June 10, 2026, 9:37 a.m. | OK | Java 21 | TESTS | 51 | 765 | 84275200 | ||
| 378065016 | BitSage | D | June 10, 2026, 10:21 a.m. | OK | Java 21 | TESTS | 51 | 859 | 32256000 | ||
| 378026396 | Satabarto_Sarkar | D | June 10, 2026, 2:53 a.m. | OK | Java 21 | TESTS | 51 | 1234 | 57241600 | ||
| 378063136 | InvariantCut | D | June 10, 2026, 10:05 a.m. | OK | Java 21 | TESTS | 51 | 1562 | 55500800 | ||
| 378067176 | _iv | D | June 10, 2026, 10:43 a.m. | OK | Kotlin 2.2 | TESTS | 51 | 1296 | 41369600 | ||
| 378077830 | EmeraldBeast | D | June 10, 2026, 11:37 a.m. | OK | PyPy 3-64 | TESTS | 52 | 265 | 56627200 | ||
| 378065003 | mer_on_fire | D | June 10, 2026, 10:21 a.m. | OK | PyPy 3-64 | TESTS | 51 | 265 | 56627200 | ||
| 378031552 | cfs.py | D | June 10, 2026, 4:29 a.m. | OK | PyPy 3-64 | TESTS | 51 | 265 | 66252800 | ||
| 378056903 | K-423 | D | June 10, 2026, 9:09 a.m. | OK | PyPy 3-64 | TESTS | 51 | 296 | 64921600 | ||
| 378043603 | Pulkit_gupta | D | June 10, 2026, 7:09 a.m. | OK | PyPy 3-64 | TESTS | 51 | 375 | 38400000 | ||
| 378037467 | chmpro | D | June 10, 2026, 5:53 a.m. | OK | PyPy 3-64 | TESTS | 51 | 406 | 87859200 | ||
| 378115433 | Seriy0904 | D | June 10, 2026, 5:42 p.m. | OK | PyPy 3-64 | TESTS | 52 | 437 | 79974400 | ||
| 378020436 | Theoreticalminima | D | June 9, 2026, 10:24 p.m. | OK | PyPy 3-64 | TESTS | 51 | 515 | 113561600 | ||
| 378051337 | madras | D | June 10, 2026, 8:20 a.m. | OK | PyPy 3-64 | TESTS | 51 | 531 | 52633600 | ||
| 378055160 | Monqieur | D | June 10, 2026, 8:54 a.m. | OK | PyPy 3-64 | TESTS | 51 | 562 | 75673600 | ||
| 378118385 | cfs.py | D | June 10, 2026, 6:10 p.m. | OK | Python 3 | TESTS | 52 | 343 | 86323200 | ||
| 378055386 | Monqieur | D | June 10, 2026, 8:56 a.m. | OK | Python 3 | TESTS | 51 | 921 | 91136000 | ||
| 378123851 | danusha777 | D | June 10, 2026, 7:13 p.m. | OK | Python 3 | TESTS | 52 | 1421 | 79052800 | ||
| 377997724 | vinit1234 | D | June 9, 2026, 4:43 p.m. | OK | Python 3 | TESTS | 51 | 1859 | 103526400 | ||
| 378067758 | bitmap4 | D | June 10, 2026, 10:49 a.m. | OK | Python 3 | TESTS | 51 | 1953 | 52428800 | ||
| 378060741 | Arlan007 | D | June 10, 2026, 9:43 a.m. | OK | Rust 2024 | TESTS | 51 | 390 | 21196800 |
Back to search problems