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 |
|---|---|---|---|---|---|---|
| 339 | Codeforces Round 197 (Div. 2) | FINISHED | False | 7200 | 398874623 | Aug. 26, 2013, 3:30 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 583 ) | E | Three Swaps | PROGRAMMING | constructive algorithms dfs and similar greedy | 2200 |
Xenia the horse breeder has n ( n > 1) horses that stand in a row. Each horse has its own unique number. Initially, the i -th left horse has number i . That is, the sequence of numbers of horses in a row looks as follows (from left to right): 1, 2, 3, ... , n . Xenia trains horses before the performance. During the practice sessions, she consistently gives them commands. Each command is a pair of numbers l , r (1 ≤ l < r ≤ n ) . The command l , r means that the horses that are on the l -th, ( l + 1) -th, ( l + 2) -th, ... , r -th places from the left must be rearranged. The horses that initially stand on the l -th and r -th places will swap. The horses on the ( l + 1) -th and ( r - 1) -th places will swap. The horses on the ( l + 2) -th and ( r - 2) -th places will swap and so on. In other words, the horses that were on the segment l , r change their order to the reverse one. For example, if Xenia commanded l = 2, r = 5 , and the sequence of numbers of horses before the command looked as (2, 1, 3, 4, 5, 6), then after the command the sequence will be (2, 5, 4, 3, 1, 6). We know that during the practice Xenia gave at most three commands of the described form. You have got the final sequence of numbers of horses by the end of the practice. Find what commands Xenia gave during the practice. Note that you do not need to minimize the number of commands in the solution, find any valid sequence of at most three commands. The first line contains an integer n (2 ≤ n ≤ 1000) — the number of horses in the row. The second line contains n distinct integers a 1 , a 2 , ..., a n (1 ≤ a i ≤ n ) , where a i is the number of the i -th left horse in the row after the practice. The first line should contain integer k (0 ≤ k ≤ 3) — the number of commads Xenia gave during the practice. In each of the next k lines print two integers. In the i -th line print numbers l i , r i (1 ≤ l i < r i ≤ n ) — Xenia's i -th command during the practice. It is guaranteed that a solution ex |
| Codeforces Round #197 — Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 59960382 | rainboy | E | Sept. 3, 2019, 5:47 p.m. | OK | GNU C11 | TESTS | 42 | 60 | 0 | 2200 | |
| 48051807 | reku | E | Jan. 7, 2019, 9:37 a.m. | OK | GNU C++11 | TESTS | 42 | 62 | 0 | 2200 | |
| 61953349 | cuizhuyefei | E | Oct. 6, 2019, 4:47 a.m. | OK | GNU C++11 | TESTS | 42 | 62 | 0 | 2200 | |
| 62360814 | Edennn | E | Oct. 11, 2019, 12:26 p.m. | OK | GNU C++11 | TESTS | 42 | 156 | 0 | 2200 | |
| 65542054 | JCC_ | E | Nov. 22, 2019, 3:51 p.m. | OK | GNU C++11 | TESTS | 42 | 186 | 0 | 2200 | |
| 62360987 | Edennn | E | Oct. 11, 2019, 12:28 p.m. | OK | GNU C++11 | TESTS | 42 | 186 | 0 | 2200 | |
| 57894614 | lopare | E | July 28, 2019, 1:03 p.m. | OK | GNU C++11 | TESTS | 42 | 186 | 0 | 2200 | |
| 51613956 | cheetose | E | March 21, 2019, 11:42 a.m. | OK | GNU C++11 | TESTS | 42 | 186 | 0 | 2200 | |
| 67582345 | Demon-Cyborg | E | Dec. 25, 2019, 6:44 a.m. | OK | GNU C++11 | TESTS | 42 | 186 | 0 | 2200 | |
| 48936975 | luogu_bot2 | E | Jan. 25, 2019, 2:42 p.m. | OK | GNU C++11 | TESTS | 42 | 312 | 1024000 | 2200 | |
| 56730409 | Hongzy | E | July 9, 2019, 12:40 a.m. | OK | GNU C++11 | TESTS | 42 | 372 | 0 | 2200 | |
| 48676602 | pikmike | E | Jan. 21, 2019, 11:45 a.m. | OK | GNU C++14 | TESTS | 42 | 62 | 204800 | 2200 | |
| 60370818 | NRK7 | E | Sept. 11, 2019, 1:40 a.m. | OK | GNU C++14 | TESTS | 42 | 186 | 0 | 2200 | |
| 67953702 | mota_haathi | E | Dec. 30, 2019, 8:44 a.m. | OK | GNU C++14 | TESTS | 42 | 186 | 204800 | 2200 | |
| 67973373 | imbr92 | E | Dec. 30, 2019, 3:53 p.m. | OK | GNU C++14 | TESTS | 42 | 248 | 0 | 2200 | |
| 53734264 | RobeZH | E | May 4, 2019, 8:40 a.m. | OK | GNU C++14 | TESTS | 42 | 278 | 0 | 2200 | |
| 67267041 | ElangBondol | E | Dec. 20, 2019, 6:37 a.m. | OK | GNU C++14 | TESTS | 42 | 280 | 0 | 2200 | |
| 50677204 | Sorting | E | March 2, 2019, 9:46 a.m. | OK | GNU C++14 | TESTS | 42 | 404 | 204800 | 2200 | |
| 49877651 | anjn98 | E | Feb. 13, 2019, 4:38 p.m. | OK | GNU C++14 | TESTS | 42 | 498 | 204800 | 2200 | |
| 55097207 | prince367 | E | June 4, 2019, 5:52 p.m. | OK | GNU C++14 | TESTS | 42 | 530 | 409600 | 2200 | |
| 57904982 | m1sch3f | E | July 28, 2019, 5:15 p.m. | OK | GNU C++17 | TESTS | 42 | 60 | 0 | 2200 | |
| 55386971 | tap_tapii | E | June 10, 2019, 7:54 a.m. | OK | GNU C++17 | TESTS | 42 | 62 | 204800 | 2200 | |
| 51355418 | BackOnTrack | E | March 16, 2019, 3:43 a.m. | OK | GNU C++17 | TESTS | 42 | 62 | 204800 | 2200 | |
| 69641317 | limabeans | E | Jan. 27, 2020, 9:02 p.m. | OK | GNU C++17 | TESTS | 42 | 92 | 0 | 2200 | |
| 56980711 | hjk1030 | E | July 13, 2019, 1:48 p.m. | OK | GNU C++17 | TESTS | 42 | 124 | 0 | 2200 | |
| 54659758 | ruo | E | May 26, 2019, 10:11 a.m. | OK | GNU C++17 | TESTS | 42 | 124 | 0 | 2200 | |
| 49693325 | karansiwach360 | E | Feb. 10, 2019, 12:28 p.m. | OK | GNU C++17 | TESTS | 42 | 154 | 409600 | 2200 | |
| 63705616 | vjudge2 | E | Oct. 29, 2019, 8:19 a.m. | OK | GNU C++17 | TESTS | 42 | 156 | 102400 | 2200 | |
| 55835743 | sinus_070 | E | June 20, 2019, 3:15 p.m. | OK | GNU C++17 | TESTS | 42 | 156 | 204800 | 2200 | |
| 55835767 | sinus_070 | E | June 20, 2019, 3:15 p.m. | OK | GNU C++17 | TESTS | 42 | 186 | 204800 | 2200 | |
| 59960381 | Dukkha | E | Sept. 3, 2019, 5:47 p.m. | OK | Java 8 | TESTS | 42 | 310 | 0 | 2200 | |
| 58043197 | TheDarBear | E | July 30, 2019, 8:53 p.m. | OK | Java 8 | TESTS | 42 | 466 | 0 | 2200 | |
| 63763290 | pajenegod | E | Oct. 30, 2019, 5:06 a.m. | OK | PyPy 2 | TESTS | 42 | 310 | 1433600 | 2200 |
Back to search problems