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 |
1951
|
Codeforces Global Round 25 |
FINISHED |
False |
10800 |
24765863 |
April 6, 2024, 2:35 p.m. |
Problems
B"There are m baskets placed along a circle, numbered from 1 to m in clockwise order (basket m is next to basket 1 ). Furthermore, there are n balls, where ball i is initially placed in basket a_i , and no basket contains more than one ball. Alice is allowed to perform the following operation, which always takes exactly one second whether you move/throw a ball or not: She repeats this operation until there is exactly one ball left. Calculate the expected time needed (in seconds) for Alice to end the process. It can be proven that the answer can be represented as a rational number frac{p}{q} with coprime p and q . You need to output p cdot q^{-1} bmod 10^9 + 7 . It can be proven that 10^9 + 7 nmid q . Each test contains multiple test cases. The first line contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains two integers n and m ( 1 <= n <= 3 cdot 10^5, n <= m <= 10^9 ) -- the number of balls and the number of baskets. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= m , a_i 's are pairwise distinct) -- the initial position of each ball. It is guaranteed that the sum of n over all test cases does not exceed 3 cdot 10^5 . For each test case, print one integer: the expected amount of time (in seconds) Alice needs to end the process, modulo 10^9 + 7 . In the first test case, Alice could have proceeded as follows (we define a_i = -1 if ball i has been thrown out): The answer for the second test case is 14 (note that these two balls are next to each other). The answer for the third test case is 35 . The answer for the fourth test case is frac{220}{3} . In the fifth test case, as there is only one ball initially, the answer is 0 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
255396207 |
honglan0301 |
G |
April 7, 2024, 12:06 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
22 |
296 |
2457600 |
|
|
255422457 |
Legitimity |
G |
April 7, 2024, 5:59 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
124 |
3379200 |
|
|
255414636 |
Ronaldo_siuuuu |
G |
April 7, 2024, 4:57 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
155 |
2457600 |
|
|
255398193 |
le0n |
G |
April 7, 2024, 12:43 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
156 |
4096000 |
|
|
255363524 |
Amoo_Safar |
G |
April 6, 2024, 6:18 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
171 |
12083200 |
|
|
255357645 |
ppavic |
G |
April 6, 2024, 5:29 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
186 |
2457600 |
|
|
255407721 |
Crystally |
G |
April 7, 2024, 3:28 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
187 |
4096000 |
|
|
255405425 |
lgswdn |
G |
April 7, 2024, 2:50 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
202 |
4915200 |
|
|
255357407 |
feeder1 |
G |
April 6, 2024, 5:28 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
202 |
8089600 |
|
|
255359983 |
frodakcin |
G |
April 6, 2024, 5:34 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
328 |
24268800 |
|
|
255401366 |
tokusakurai |
G |
April 7, 2024, 1:42 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
343 |
0 |
|
|
255404842 |
D_F_S |
G |
April 7, 2024, 2:41 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
77 |
3379200 |
|
|
255355080 |
maspy |
G |
April 6, 2024, 5:22 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
108 |
6348800 |
|
|
255364727 |
A_G |
G |
April 6, 2024, 6:24 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
0 |
|
|
255401350 |
JettyOller |
G |
April 7, 2024, 1:42 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
102400 |
|
|
255363236 |
jiangly |
G |
April 6, 2024, 6:16 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
102400 |
|
|
255366954 |
dl720125 |
G |
April 6, 2024, 6:38 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
614400 |
|
|
255358262 |
AlternatingCurrent |
G |
April 6, 2024, 5:30 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
1228800 |
|
|
255407360 |
xukai |
G |
April 7, 2024, 3:22 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
124 |
56115200 |
|
|
255388975 |
paula |
G |
April 6, 2024, 10:06 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
140 |
0 |
|
|
255378475 |
risujiroh |
G |
April 6, 2024, 8:13 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
22 |
140 |
102400 |
|
|
255375453 |
rainboy |
G |
April 6, 2024, 7:45 p.m. |
OK |
GNU C11 |
TESTS |
22 |
155 |
1331200 |
|
|
255359274 |
Tlatoani |
G |
April 6, 2024, 5:33 p.m. |
OK |
Kotlin 1.9 |
TESTS |
22 |
624 |
35942400 |
|
|
remove filters
Back to search problems