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' n people came to the festival and decided to dance a few round dances. There are at least 2 people in the round dance and each person has exactly two neighbors. If there are 2 people in the round dance then they have the same neighbor on each side. You decided to find out exactly how many dances there were. But each participant of the holiday remembered exactly one neighbor. Your task is to determine what the minimum and maximum number of round dances could be. For example, if there were 6 people at the holiday, and the numbers of the neighbors they remembered are equal [2, 1, 4, 3, 6, 5] , then the minimum number of round dances is 1 : The first line contains a positive number t ( 1 <= t <= 10^4 ) -- the number of test cases. The following is a description of the test cases. The first line of the description of each test case contains a positive number n ( 2 <= n <= 2 cdot 10^5 ) -- the number of people at the holiday. The second line of the description of each test case contains n integers a_i ( 1 <= a_i <= n, a_i neq i ) -- the number of the neighbor that the i th person remembered. It is guaranteed that the test cases are correct and corresponds to at least one division of people into round dances. It is guaranteed that the sum of n for all test cases does not exceed 2 cdot 10^5 . For each test case, output two integers -- the minimum and maximum number of round dances that could be. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
206540085 |
AutumnMist |
E |
May 19, 2023, 4:42 p.m. |
OK |
C# 10 |
TESTS |
11 |
93 |
16896000 |
|
|
206553678 |
Alfafox |
E |
May 19, 2023, 5:31 p.m. |
OK |
C# 10 |
TESTS |
11 |
139 |
18022400 |
|
|
206576323 |
mban259 |
E |
May 20, 2023, 12:14 a.m. |
OK |
C# 10 |
TESTS |
13 |
264 |
58265600 |
|
|
206554540 |
tahtarovserver |
E |
May 19, 2023, 5:39 p.m. |
OK |
C# 8 |
TESTS |
11 |
311 |
58777600 |
|
|
206577928 |
Ice_teapoy |
E |
May 20, 2023, 1:08 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
31 |
11980800 |
|
|
206539463 |
rangbaaaz |
E |
May 19, 2023, 4:41 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
46 |
1638400 |
|
|
206537068 |
back_in_business |
E |
May 19, 2023, 4:35 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
46 |
1843200 |
|
|
206578528 |
solitude3freedom |
E |
May 20, 2023, 1:24 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
61 |
2457600 |
|
|
206535503 |
Pig_God |
E |
May 19, 2023, 4:32 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
1024000 |
|
|
206546015 |
sweet_summer |
E |
May 19, 2023, 4:59 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
3174400 |
|
|
206535613 |
c0nf11c7 |
E |
May 19, 2023, 4:32 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
3584000 |
|
|
206545364 |
Jaskaran9669 |
E |
May 19, 2023, 4:56 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
7987200 |
|
|
206557834 |
wuorbs |
E |
May 19, 2023, 6:11 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
24678400 |
|
|
206534645 |
INFINIDY1729 |
E |
May 19, 2023, 4:30 p.m. |
OK |
GNU C++14 |
TESTS |
11 |
62 |
49664000 |
|
|
206554573 |
aldgebu |
E |
May 19, 2023, 5:39 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
46 |
921600 |
|
|
206573015 |
nonrice |
E |
May 19, 2023, 10:18 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
46 |
1638400 |
|
|
206547581 |
Pavlot |
E |
May 19, 2023, 5:09 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
46 |
2457600 |
|
|
206539262 |
Neelarghya_Kundu |
E |
May 19, 2023, 4:40 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
46 |
3174400 |
|
|
206535988 |
cfdqwqdfc |
E |
May 19, 2023, 4:33 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
46 |
3379200 |
|
|
206568852 |
Practice1106 |
E |
May 19, 2023, 8:37 p.m. |
OK |
GNU C++17 |
TESTS |
13 |
46 |
4198400 |
|
|
206545745 |
you_are_so_talented |
E |
May 19, 2023, 4:58 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
46 |
21811200 |
|
|
206540261 |
Mhamad_aboaljood |
E |
May 19, 2023, 4:43 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
61 |
1638400 |
|
|
206534036 |
Rafael_Y |
E |
May 19, 2023, 4:28 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
61 |
1638400 |
|
|
206548143 |
no_oneplb |
E |
May 19, 2023, 5:12 p.m. |
OK |
GNU C++17 |
TESTS |
11 |
61 |
3174400 |
|
|
206568596 |
chappy1 |
E |
May 19, 2023, 8:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
46 |
3174400 |
|
|
206539156 |
Mostafa_Moharram |
E |
May 19, 2023, 4:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
46 |
3276800 |
|
|
206541674 |
Rikidd |
E |
May 19, 2023, 4:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
46 |
3379200 |
|
|
206545935 |
vermouthson |
E |
May 19, 2023, 4:59 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
46 |
5836800 |
|
|
206554125 |
SU00YU |
E |
May 19, 2023, 5:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
46 |
6451200 |
|
|
206533997 |
Achaoooo |
E |
May 19, 2023, 4:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
46 |
12083200 |
|
|
206576268 |
jcccc |
E |
May 20, 2023, 12:13 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
61 |
3993600 |
|
|
206575585 |
Rania |
E |
May 19, 2023, 11:46 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
61 |
5632000 |
|
|
206541219 |
smart_work |
E |
May 19, 2023, 4:45 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
62 |
5324800 |
|
|
206547294 |
Hangbust |
E |
May 19, 2023, 5:07 p.m. |
OK |
GNU C++17 (64) |
TESTS |
11 |
77 |
3993600 |
|
|
206553337 |
International_River |
E |
May 19, 2023, 5:27 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
819200 |
|
|
206546247 |
CrazyCoder00 |
E |
May 19, 2023, 5 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
819200 |
|
|
206577961 |
Thallium54 |
E |
May 20, 2023, 1:09 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
31 |
1638400 |
|
|
206572603 |
_FireGhost_ |
E |
May 19, 2023, 10:06 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
31 |
1638400 |
|
|
206562667 |
ARITRASEN_2003 |
E |
May 19, 2023, 7:08 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
1638400 |
|
|
206547719 |
ForgotDream_CHN |
E |
May 19, 2023, 5:10 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
1638400 |
|
|
206535591 |
darkdulgi |
E |
May 19, 2023, 4:32 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
1638400 |
|
|
206534577 |
AshrafSustS19 |
E |
May 19, 2023, 4:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
11 |
31 |
1638400 |
|
|
206578311 |
mehrunesartem |
E |
May 20, 2023, 1:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
31 |
2457600 |
|
|
206571863 |
SCOR_PION |
E |
May 19, 2023, 9:46 p.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
31 |
2457600 |
|
|
206541179 |
liangjiahui11 |
E |
May 19, 2023, 4:45 p.m. |
OK |
Go |
TESTS |
11 |
295 |
61542400 |
|
|
206550038 |
henrychenOutlook |
E |
May 19, 2023, 5:14 p.m. |
OK |
Java 11 |
TESTS |
11 |
233 |
0 |
|
|
206547443 |
minibin |
E |
May 19, 2023, 5:08 p.m. |
OK |
Java 11 |
TESTS |
11 |
234 |
0 |
|
|
206534958 |
kribri |
E |
May 19, 2023, 4:31 p.m. |
OK |
Java 11 |
TESTS |
11 |
389 |
25907200 |
|
|
206542059 |
leoncn |
E |
May 19, 2023, 4:47 p.m. |
OK |
Java 11 |
TESTS |
11 |
421 |
34508800 |
|
|
206556962 |
biu_biu_biu |
E |
May 19, 2023, 6:02 p.m. |
OK |
Java 11 |
TESTS |
11 |
451 |
0 |
|
|
206571575 |
devansh_123 |
E |
May 19, 2023, 9:38 p.m. |
OK |
Java 11 |
TESTS |
13 |
639 |
32460800 |
|
|
206555459 |
radianite2003 |
E |
May 19, 2023, 5:48 p.m. |
OK |
Java 11 |
TESTS |
11 |
748 |
63897600 |
|
|
206538703 |
pushkar.lonkar21 |
E |
May 19, 2023, 4:39 p.m. |
OK |
Java 11 |
TESTS |
11 |
748 |
78643200 |
|
|
206566211 |
Yousef_Badr |
E |
May 19, 2023, 7:56 p.m. |
OK |
Java 11 |
TESTS |
13 |
795 |
44851200 |
|
|
206542263 |
pakkapapad |
E |
May 19, 2023, 4:47 p.m. |
OK |
Java 11 |
TESTS |
11 |
795 |
77619200 |
|
|
206569355 |
amanjindal231 |
E |
May 19, 2023, 8:48 p.m. |
OK |
Java 17 |
TESTS |
13 |
483 |
1331200 |
|
|
206575480 |
kamranm |
E |
May 19, 2023, 11:42 p.m. |
OK |
Java 17 |
TESTS |
13 |
530 |
208486400 |
|
|
206540939 |
r3hab.rs |
E |
May 19, 2023, 4:44 p.m. |
OK |
Java 17 |
TESTS |
11 |
842 |
97587200 |
|
|
206562465 |
charles2307 |
E |
May 19, 2023, 7:05 p.m. |
OK |
Java 17 |
TESTS |
11 |
857 |
97792000 |
|
|
206544626 |
_AKR_ |
E |
May 19, 2023, 4:53 p.m. |
OK |
Java 17 |
TESTS |
11 |
966 |
34713600 |
|
|
206550070 |
partymaker |
E |
May 19, 2023, 5:14 p.m. |
OK |
Java 17 |
TESTS |
11 |
1045 |
82432000 |
|
|
206538941 |
zopchur |
E |
May 19, 2023, 4:40 p.m. |
OK |
Java 17 |
TESTS |
11 |
1153 |
83353600 |
|
|
206536384 |
ning1ing |
E |
May 19, 2023, 4:34 p.m. |
OK |
Java 17 |
TESTS |
11 |
1201 |
81305600 |
|
|
206541456 |
jimmyd211 |
E |
May 19, 2023, 4:45 p.m. |
OK |
Java 17 |
TESTS |
11 |
1263 |
141414400 |
|
|
206539715 |
jimmyd211 |
E |
May 19, 2023, 4:42 p.m. |
OK |
Java 17 |
TESTS |
11 |
1278 |
141312000 |
|
|
206548221 |
bloodsid |
E |
May 19, 2023, 5:13 p.m. |
OK |
Java 8 |
TESTS |
11 |
124 |
1843200 |
|
|
206545961 |
ND_ |
E |
May 19, 2023, 4:59 p.m. |
OK |
Java 8 |
TESTS |
11 |
202 |
15667200 |
|
|
206549925 |
ND_ |
E |
May 19, 2023, 5:13 p.m. |
OK |
Java 8 |
TESTS |
11 |
218 |
15667200 |
|
|
206552975 |
QUITTING |
E |
May 19, 2023, 5:24 p.m. |
OK |
Java 8 |
TESTS |
11 |
233 |
3891200 |
|
|
206546753 |
ND_ |
E |
May 19, 2023, 5:04 p.m. |
OK |
Java 8 |
TESTS |
11 |
233 |
15667200 |
|
|
206546541 |
ND_ |
E |
May 19, 2023, 5:02 p.m. |
OK |
Java 8 |
TESTS |
11 |
233 |
15667200 |
|
|
206566299 |
javaisbetter |
E |
May 19, 2023, 7:58 p.m. |
OK |
Java 8 |
TESTS |
13 |
373 |
65536000 |
|
|
206550313 |
ND_ |
E |
May 19, 2023, 5:16 p.m. |
OK |
Java 8 |
TESTS |
11 |
421 |
15667200 |
|
|
206565686 |
javaisbetter |
E |
May 19, 2023, 7:48 p.m. |
OK |
Java 8 |
TESTS |
13 |
639 |
68915200 |
|
|
206572736 |
lpychemistry |
E |
May 19, 2023, 10:09 p.m. |
OK |
Java 8 |
TESTS |
13 |
670 |
74035200 |
|
|
206553529 |
Exusiai1 |
E |
May 19, 2023, 5:29 p.m. |
OK |
MS C++ 2017 |
TESTS |
11 |
187 |
10547200 |
|
|
206547478 |
moreda |
E |
May 19, 2023, 5:08 p.m. |
OK |
MS C++ 2017 |
TESTS |
11 |
234 |
6041600 |
|
|
206542045 |
G_D |
E |
May 19, 2023, 4:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
11 |
249 |
7680000 |
|
|
206553214 |
Exusiai1 |
E |
May 19, 2023, 5:26 p.m. |
OK |
MS C++ 2017 |
TESTS |
11 |
280 |
26624000 |
|
|
206537937 |
sashatorba12022008 |
E |
May 19, 2023, 4:37 p.m. |
OK |
MS C++ 2017 |
TESTS |
11 |
296 |
22528000 |
|
|
206540232 |
rmhasan |
E |
May 19, 2023, 4:43 p.m. |
OK |
PyPy 3 |
TESTS |
11 |
452 |
18124800 |
|
|
206562985 |
brokie |
E |
May 19, 2023, 7:12 p.m. |
OK |
PyPy 3 |
TESTS |
11 |
857 |
46182400 |
|
|
206536213 |
jay_adhikrut |
E |
May 19, 2023, 4:33 p.m. |
OK |
PyPy 3 |
TESTS |
11 |
935 |
39628800 |
|
|
206565613 |
sixthcore |
E |
May 19, 2023, 7:47 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
249 |
32768000 |
|
|
206556918 |
eugenpaul77 |
E |
May 19, 2023, 6:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
264 |
29491200 |
|
|
206565592 |
Gorgontes |
E |
May 19, 2023, 7:47 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
280 |
30617600 |
|
|
206534013 |
drugkeeper |
E |
May 19, 2023, 4:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
280 |
31948800 |
|
|
206571100 |
RobinFromTheHood |
E |
May 19, 2023, 9:26 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
311 |
31539200 |
|
|
206572742 |
timmyfeng |
E |
May 19, 2023, 10:09 p.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
327 |
28057600 |
|
|
206553418 |
Tanz |
E |
May 19, 2023, 5:28 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
327 |
54681600 |
|
|
206552363 |
SoleProprietor |
E |
May 19, 2023, 5:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
342 |
29593600 |
|
|
206545528 |
AndreiZherder |
E |
May 19, 2023, 4:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
358 |
19251200 |
|
|
206546823 |
layzer |
E |
May 19, 2023, 5:04 p.m. |
OK |
PyPy 3-64 |
TESTS |
11 |
374 |
59392000 |
|
|
206534192 |
alsrjs0725 |
E |
May 19, 2023, 4:29 p.m. |
OK |
Python 3 |
TESTS |
11 |
187 |
27033600 |
|
|
206553350 |
pranjal_99 |
E |
May 19, 2023, 5:27 p.m. |
OK |
Python 3 |
TESTS |
11 |
217 |
27033600 |
|
|
206541335 |
wavezhu |
E |
May 19, 2023, 4:45 p.m. |
OK |
Python 3 |
TESTS |
11 |
514 |
84684800 |
|
|
206559363 |
Raul09062000 |
E |
May 19, 2023, 6:27 p.m. |
OK |
Python 3 |
TESTS |
11 |
873 |
91136000 |
|
|
206543586 |
Viper35 |
E |
May 19, 2023, 4:49 p.m. |
OK |
Python 3 |
TESTS |
11 |
951 |
78336000 |
|
|
206560289 |
andri_trap |
E |
May 19, 2023, 6:38 p.m. |
OK |
Python 3 |
TESTS |
11 |
966 |
109772800 |
|
|
206559333 |
dnzc |
E |
May 19, 2023, 6:27 p.m. |
OK |
Python 3 |
TESTS |
11 |
1029 |
109568000 |
|
|
206534079 |
jimini23kjm |
E |
May 19, 2023, 4:29 p.m. |
OK |
Python 3 |
TESTS |
11 |
1060 |
80281600 |
|
|
206543007 |
RyoSci |
E |
May 19, 2023, 4:48 p.m. |
OK |
Python 3 |
TESTS |
11 |
1418 |
95027200 |
|
|
206542304 |
Flash31 |
E |
May 19, 2023, 4:47 p.m. |
OK |
Python 3 |
TESTS |
11 |
1825 |
231219200 |
|
|
remove filters
Back to search problems