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 |
|---|---|---|---|---|---|---|
| 785 | Codeforces Round 404 (Div. 2) | FINISHED | False | 7800 | 286815323 | March 15, 2017, 3:05 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2200 ) | E | Anton and Permutation | PROGRAMMING | brute force data structures | 2300 |
Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers { a 1 , a 2 , ..., a n } , in which every number from 1 to n appears exactly once. One day Anton got a new permutation and started to play with it. He does the following operation q times: he takes two elements of the permutation and swaps these elements. After each operation he asks his friend Vanya, how many inversions there are in the new permutation. The number of inversions in a permutation is the number of distinct pairs ( i , j ) such that 1 ≤ i < j ≤ n and a i > a j . Vanya is tired of answering Anton's silly questions. So he asked you to write a program that would answer these questions instead of him. Initially Anton's permutation was {1, 2, ..., n } , that is a i = i for all i such that 1 ≤ i ≤ n . The first line of the input contains two integers n and q (1 ≤ n ≤ 200 000, 1 ≤ q ≤ 50 000) — the length of the permutation and the number of operations that Anton does. Each of the following q lines of the input contains two integers l i and r i (1 ≤ l i , r i ≤ n ) — the indices of elements that Anton swaps during the i -th operation. Note that indices of elements that Anton swaps during the i -th operation can coincide. Elements in the permutation are numbered starting with one. Output q lines. The i -th line of the output is the number of inversions in the Anton's permutation after the i -th operation. Consider the first sample. After the first Anton's operation the permutation will be {1, 2, 3, 5, 4} . There is only one inversion in it: (4, 5) . After the second Anton's operation the permutation will be {1, 5, 3, 2, 4} . There are four inversions: (2, 3) , (2, 4) , (2, 5) and (3, 4) . After the third Anton's operation the permutation will be {1, 4, 3, 2, 5} . There are three inversions: (2, 3) , (2, 4) and (3, 4) . After the fourth Anton's operation the permutation doesn't change, so there are still three inversi |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 25676332 | rainboy | E | March 20, 2017, 8:37 p.m. | OK | GNU C | TESTS | 50 | 358 | 363110400 | 2300 | |
| 25673574 | rainboy | E | March 20, 2017, 5:49 p.m. | OK | GNU C | TESTS | 50 | 1606 | 3481600 | 2300 | |
| 25647499 | jkxjkx1031 | E | March 19, 2017, 1:44 p.m. | OK | GNU C | TESTS | 50 | 2292 | 3481600 | 2300 | |
| 25668791 | SpoonsAN | E | March 20, 2017, 2:38 p.m. | OK | GNU C++ | TESTS | 50 | 311 | 409395200 | 2300 | |
| 40982016 | ReaLNero1 | E | July 30, 2018, 6:14 p.m. | OK | GNU C++ | TESTS | 50 | 327 | 401612800 | 2300 | |
| 40398062 | Strayor_vor | E | July 16, 2018, 6:20 a.m. | OK | GNU C++ | TESTS | 50 | 685 | 82534400 | 2300 | |
| 25761560 | vjudge2 | E | March 24, 2017, 2:38 a.m. | OK | GNU C++ | TESTS | 50 | 717 | 10649600 | 2300 | |
| 25790201 | ljh2000 | E | March 25, 2017, 6:54 a.m. | OK | GNU C++ | TESTS | 50 | 717 | 13516800 | 2300 | |
| 31165689 | vjudge3 | E | Oct. 9, 2017, 11:32 a.m. | OK | GNU C++ | TESTS | 50 | 733 | 3993600 | 2300 | |
| 25672044 | Jaihk662 | E | March 20, 2017, 5:10 p.m. | OK | GNU C++ | TESTS | 50 | 748 | 6246400 | 2300 | |
| 25671648 | Jaihk662 | E | March 20, 2017, 4:51 p.m. | OK | GNU C++ | TESTS | 50 | 748 | 8601600 | 2300 | |
| 25670665 | Jaihk662 | E | March 20, 2017, 4:06 p.m. | OK | GNU C++ | TESTS | 50 | 748 | 8601600 | 2300 | |
| 31164263 | vjudge3 | E | Oct. 9, 2017, 10:18 a.m. | OK | GNU C++ | TESTS | 50 | 748 | 9420800 | 2300 | |
| 62421028 | mrsrz | E | Oct. 12, 2019, 12:58 p.m. | OK | GNU C++11 | TESTS | 50 | 202 | 2457600 | 2300 | |
| 61047048 | Ging_ | E | Sept. 22, 2019, 4:59 a.m. | OK | GNU C++11 | TESTS | 50 | 280 | 35328000 | 2300 | |
| 25661876 | DSSGSRA | E | March 20, 2017, 8:47 a.m. | OK | GNU C++11 | TESTS | 50 | 342 | 388505600 | 2300 | |
| 25683064 | RockyB | E | March 21, 2017, 7:40 a.m. | OK | GNU C++11 | TESTS | 50 | 373 | 407142400 | 2300 | |
| 25757202 | Arg_007 | E | March 23, 2017, 7:52 p.m. | OK | GNU C++11 | TESTS | 50 | 420 | 4710400 | 2300 | |
| 64957851 | POWERRR | E | Nov. 15, 2019, 4:17 a.m. | OK | GNU C++11 | TESTS | 50 | 421 | 2867200 | 2300 | |
| 64895664 | POWERRR | E | Nov. 14, 2019, 4:29 p.m. | OK | GNU C++11 | TESTS | 50 | 436 | 2867200 | 2300 | |
| 49076231 | Memory_of_winter | E | Jan. 28, 2019, 3:19 a.m. | OK | GNU C++11 | TESTS | 50 | 467 | 2252800 | 2300 | |
| 50098176 | vjudge4 | E | Feb. 18, 2019, 1:43 p.m. | OK | GNU C++11 | TESTS | 50 | 468 | 2252800 | 2300 | |
| 53564914 | luogu_bot4 | E | April 30, 2019, 11:54 a.m. | OK | GNU C++11 | TESTS | 50 | 498 | 2457600 | 2300 | |
| 25773714 | RelyOnTheTruth | E | March 24, 2017, 1:09 p.m. | OK | GNU C++14 | TESTS | 50 | 311 | 403558400 | 2300 | |
| 40613598 | zendo | E | July 21, 2018, 4:19 p.m. | OK | GNU C++14 | TESTS | 50 | 436 | 407244800 | 2300 | |
| 40613560 | zendo | E | July 21, 2018, 4:17 p.m. | OK | GNU C++14 | TESTS | 50 | 467 | 407244800 | 2300 | |
| 25819693 | _FengChang_ | E | March 26, 2017, 1 p.m. | OK | GNU C++14 | TESTS | 50 | 499 | 19968000 | 2300 | |
| 25763404 | _FengChang_ | E | March 24, 2017, 5:19 a.m. | OK | GNU C++14 | TESTS | 50 | 499 | 19968000 | 2300 | |
| 25730102 | _FengChang_ | E | March 23, 2017, 10:04 a.m. | OK | GNU C++14 | TESTS | 50 | 499 | 82022400 | 2300 | |
| 40613552 | zendo | E | July 21, 2018, 4:17 p.m. | OK | GNU C++14 | TESTS | 50 | 546 | 407244800 | 2300 | |
| 40613590 | zendo | E | July 21, 2018, 4:19 p.m. | OK | GNU C++14 | TESTS | 50 | 561 | 407244800 | 2300 | |
| 31863522 | suibaka | E | Oct. 29, 2017, 10:39 a.m. | OK | GNU C++14 | TESTS | 50 | 607 | 361574400 | 2300 | |
| 45991189 | w446506278 | E | Nov. 20, 2018, 9:58 a.m. | OK | GNU C++14 | TESTS | 50 | 639 | 243712000 | 2300 | |
| 50096769 | vjudge4 | E | Feb. 18, 2019, 1:06 p.m. | OK | GNU C++17 | TESTS | 50 | 327 | 426393600 | 2300 | |
| 50095108 | vjudge1 | E | Feb. 18, 2019, 12:22 p.m. | OK | GNU C++17 | TESTS | 50 | 327 | 441651200 | 2300 | |
| 50264524 | vjudge2 | E | Feb. 21, 2019, 3:40 a.m. | OK | GNU C++17 | TESTS | 50 | 342 | 442470400 | 2300 | |
| 50095646 | chasedeath | E | Feb. 18, 2019, 12:39 p.m. | OK | GNU C++17 | TESTS | 50 | 343 | 426393600 | 2300 | |
| 50094985 | vjudge3 | E | Feb. 18, 2019, 12:19 p.m. | OK | GNU C++17 | TESTS | 50 | 358 | 425676800 | 2300 | |
| 50095585 | Ameiyo | E | Feb. 18, 2019, 12:37 p.m. | OK | GNU C++17 | TESTS | 50 | 373 | 441651200 | 2300 | |
| 50095124 | vjudge2 | E | Feb. 18, 2019, 12:22 p.m. | OK | GNU C++17 | TESTS | 50 | 374 | 425676800 | 2300 | |
| 50095771 | chasedeath | E | Feb. 18, 2019, 12:43 p.m. | OK | GNU C++17 | TESTS | 50 | 374 | 426393600 | 2300 | |
| 50097248 | vjudge3 | E | Feb. 18, 2019, 1:17 p.m. | OK | GNU C++17 | TESTS | 50 | 374 | 442470400 | 2300 | |
| 50093387 | vjudge4 | E | Feb. 18, 2019, 11:36 a.m. | OK | GNU C++17 | TESTS | 50 | 389 | 121036800 | 2300 | |
| 25674261 | Dukkha | E | March 20, 2017, 6:27 p.m. | OK | Java 8 | TESTS | 50 | 545 | 447078400 | 2300 | |
| 25705635 | donli | E | March 22, 2017, 7:41 a.m. | OK | Java 8 | TESTS | 50 | 592 | 447078400 | 2300 | |
| 25656802 | JialinOuyang | E | March 19, 2017, 11:07 p.m. | OK | Java 8 | TESTS | 50 | 858 | 447078400 | 2300 | |
| 25707354 | mahdim1000 | E | March 22, 2017, 9:26 a.m. | OK | Java 8 | TESTS | 50 | 1404 | 21606400 | 2300 | |
| 25670789 | Dukkha | E | March 20, 2017, 4:11 p.m. | OK | Java 8 | TESTS | 50 | 1981 | 21196800 | 2300 | |
| 26870257 | RP_9 | E | May 5, 2017, 1:47 a.m. | OK | Java 8 | TESTS | 50 | 2043 | 424652800 | 2300 | |
| 27627640 | U_Square | E | June 7, 2017, 7:32 a.m. | OK | Java 8 | TESTS | 50 | 3041 | 424448000 | 2300 | |
| 27097766 | roberto_firmino | E | May 13, 2017, 10:03 p.m. | OK | Java 8 | TESTS | 50 | 3104 | 528896000 | 2300 | |
| 27831877 | aya_cool | E | June 16, 2017, 7:06 p.m. | OK | Java 8 | TESTS | 50 | 3743 | 528896000 | 2300 | |
| 50092464 | vjudge5 | E | Feb. 18, 2019, 11:09 a.m. | OK | MS C++ | TESTS | 50 | 1123 | 1638400 | 2300 | |
| 26698752 | hsmmouse | E | April 27, 2017, 8:57 a.m. | OK | MS C++ | TESTS | 50 | 1169 | 3788800 | 2300 | |
| 50093308 | vjudge4 | E | Feb. 18, 2019, 11:34 a.m. | OK | MS C++ | TESTS | 50 | 2496 | 2457600 | 2300 | |
| 25771912 | Yurik | E | March 24, 2017, 12:09 p.m. | OK | MS C++ | TESTS | 50 | 3962 | 10137600 | 2300 | |
| 25756808 | P___ | E | March 23, 2017, 7:33 p.m. | OK | MS C++ | TESTS | 50 | 3993 | 4198400 | 2300 |
Back to search problems