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.
Problems
B'Given a cyclic array a of size n , where a_i is the value of a in the i -th position, there may be repeated values. Let us define that a permutation of a is equal to another permutation of a if and only if their values are the same for each position i or we can transform them to each other by performing some cyclic rotation. Let us define for a cyclic array b its number of components as the number of connected components in a graph, where the vertices are the positions of b and we add an edge between each pair of adjacent positions of b with equal values (note that in a cyclic array the first and last position are also adjacents). Find the expected value of components of a permutation of a if we select it equiprobably over the set of all the different permutations of a . The input consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 10^5 ) -- the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 10^6 ) -- the size of the cyclic array a . The second line of each test case contains n integers, the i -th of them is the value a_i ( 1 <= a_i <= n ). It is guaranteed that the sum of n over all test cases does not exceed 10^6 . It is guaranteed that the total number of different permutations of a is not divisible by M For each test case print a single integer -- the expected value of components of a permutation of a if we select it equiprobably over the set of all the different permutations of a modulo 998 ,244 ,353 . Formally, let M = 998 ,244 ,353 . It can be shown that the answer can be expressed as an irreducible fraction frac{p}{q} , where p and q are integers and q not equiv 0 pmod{M} . Output the integer equal to p cdot q^{-1} bmod M '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
144257183 |
zeliboba |
E |
Jan. 27, 2022, 6:57 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
358 |
47308800 |
|
|
144271331 |
eecs |
E |
Jan. 28, 2022, 1:26 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
374 |
30412800 |
|
|
144235613 |
gisp_zjz |
E |
Jan. 27, 2022, 4:08 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
404 |
30412800 |
|
|
144254785 |
dlalswp25 |
E |
Jan. 27, 2022, 6:35 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
436 |
42803200 |
|
|
144234581 |
Eric_hooo |
E |
Jan. 27, 2022, 4:06 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
499 |
30412800 |
|
|
144270464 |
Y25t |
E |
Jan. 28, 2022, 12:54 a.m. |
OK |
GNU C++14 |
TESTS |
46 |
561 |
30412800 |
|
|
144246143 |
I_love_chtholly |
E |
Jan. 27, 2022, 4:31 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
764 |
46489600 |
|
|
144226268 |
ABitstOCHASTIC |
E |
Jan. 27, 2022, 3:49 p.m. |
OK |
GNU C++14 |
TESTS |
46 |
780 |
28262400 |
|
|
144215907 |
Miracle0viiiiiv |
E |
Jan. 27, 2022, 3:31 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
358 |
20070400 |
|
|
144269119 |
bthero |
E |
Jan. 27, 2022, 11:46 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
374 |
24166400 |
|
|
144255964 |
fanache99 |
E |
Jan. 27, 2022, 6:46 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
389 |
30412800 |
|
|
144255019 |
fanache99 |
E |
Jan. 27, 2022, 6:37 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
389 |
30412800 |
|
|
144282880 |
sp40016 |
E |
Jan. 28, 2022, 5:16 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
405 |
33075200 |
|
|
144263907 |
prateek_tripathi |
E |
Jan. 27, 2022, 8:38 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
405 |
33075200 |
|
|
144254486 |
YaoBIG |
E |
Jan. 27, 2022, 6:33 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
405 |
34508800 |
|
|
144279304 |
hotwords |
E |
Jan. 28, 2022, 4:22 a.m. |
OK |
GNU C++17 |
TESTS |
46 |
421 |
23347200 |
|
|
144267692 |
YaoBIG |
E |
Jan. 27, 2022, 10:30 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
421 |
26419200 |
|
|
144219804 |
Radewoosh |
E |
Jan. 27, 2022, 3:38 p.m. |
OK |
GNU C++17 |
TESTS |
46 |
421 |
32256000 |
|
|
144226514 |
QAQAutoMaton |
E |
Jan. 27, 2022, 3:50 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
186 |
36249600 |
|
|
144284481 |
lgmlessgo |
E |
Jan. 28, 2022, 5:38 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
202 |
23449600 |
|
|
144245901 |
gs18115 |
E |
Jan. 27, 2022, 4:30 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
233 |
23654400 |
|
|
144217838 |
ecnerwala |
E |
Jan. 27, 2022, 3:34 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
249 |
26112000 |
|
|
144234962 |
hitonanode |
E |
Jan. 27, 2022, 4:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
249 |
35225600 |
|
|
144283704 |
triple__a |
E |
Jan. 28, 2022, 5:27 a.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
249 |
61849600 |
|
|
144244985 |
MAOoo_Love_Molly |
E |
Jan. 27, 2022, 4:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
264 |
29388800 |
|
|
144243068 |
Xellos |
E |
Jan. 27, 2022, 4:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
264 |
49459200 |
|
|
144210990 |
tourist |
E |
Jan. 27, 2022, 3:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
342 |
23449600 |
|
|
144203824 |
jtnydv25 |
E |
Jan. 27, 2022, 3:13 p.m. |
OK |
GNU C++17 (64) |
TESTS |
46 |
342 |
27443200 |
|
|
144238591 |
Vercingetorix |
E |
Jan. 27, 2022, 4:14 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
93 |
71782400 |
|
|
144237570 |
maspy |
E |
Jan. 27, 2022, 4:12 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
140 |
35942400 |
|
|
144224358 |
jiangly |
E |
Jan. 27, 2022, 3:45 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
187 |
28057600 |
|
|
144223532 |
Elegia |
E |
Jan. 27, 2022, 3:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
217 |
23449600 |
|
|
144228274 |
ksun48 |
E |
Jan. 27, 2022, 3:53 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
218 |
30105600 |
|
|
144259233 |
atoiz |
E |
Jan. 27, 2022, 7:19 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
218 |
31436800 |
|
|
144256043 |
antekb |
E |
Jan. 27, 2022, 6:47 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
249 |
37376000 |
|
|
144257067 |
antekb |
E |
Jan. 27, 2022, 6:56 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
264 |
29388800 |
|
|
144240392 |
physics0523 |
E |
Jan. 27, 2022, 4:18 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
264 |
50380800 |
|
|
144244809 |
Rubikun |
E |
Jan. 27, 2022, 4:28 p.m. |
OK |
GNU C++20 (64) |
TESTS |
46 |
280 |
35635200 |
|
|
144232631 |
conqueror_of_tourist |
E |
Jan. 27, 2022, 4:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
46 |
1169 |
141209600 |
|
|
144272327 |
sansen |
E |
Jan. 28, 2022, 1:57 a.m. |
OK |
Rust 2021 |
TESTS |
46 |
109 |
45568000 |
|
|
144239145 |
Egor |
E |
Jan. 27, 2022, 4:15 p.m. |
OK |
Rust 2021 |
TESTS |
46 |
249 |
63180800 |
|
|
remove filters
Back to search problems