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"The country has n cities and n xe2 x80 x89- xe2 x80 x891 bidirectional roads, it is possible to get from every city to any other one if you move only along the roads. The cities are numbered with integers from 1 to n inclusive. All the roads are initially bad, but the government wants to improve the state of some roads. We will assume that the citizens are happy about road improvement if the path from the capital located in city x to any other city contains at most one bad road. Your task is -- for every possible x determine the number of ways of improving the quality of some roads in order to meet the citizens' condition. As those values can be rather large, you need to print each value modulo 1 xe2 x80 x89000 xe2 x80 x89000 xe2 x80 x89007 (109 xe2 x80 x89+ xe2 x80 x897). The first line of the input contains a single integer n (2 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892 xc2 xb7105) -- the number of cities in the country. Next line contains n xe2 x80 x89- xe2 x80 x891 positive integers p2, xe2 x80 x89p3, xe2 x80 x89p4, xe2 x80 x89..., xe2 x80 x89pn (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89pi xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i xe2 x80 x89- xe2 x80 x891) -- the description of the roads in the country. Number pi means that the country has a road connecting city pi and city i. Print n integers a1, xe2 x80 x89a2, xe2 x80 x89..., xe2 x80 x89an, where ai is the sought number of ways to improve the quality of the roads modulo 1 xe2 x80 x89000 xe2 x80 x89000 xe2 x80 x89007 (109 xe2 x80 x89+ xe2 x80 x897), if the capital of the country is at city number i."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
11031237 |
Gassa |
D |
May 7, 2015, 6:04 p.m. |
OK |
D |
TESTS |
42 |
343 |
17305600 |
|
2300 |
11034384 |
Gassa |
D |
May 7, 2015, 7:04 p.m. |
OK |
D |
TESTS |
42 |
374 |
17100800 |
|
2300 |
11034425 |
Gassa |
D |
May 7, 2015, 7:05 p.m. |
OK |
D |
TESTS |
42 |
374 |
17100800 |
|
2300 |
11483598 |
greatsaiyanman |
D |
June 7, 2015, 8:22 a.m. |
OK |
FPC |
TESTS |
42 |
436 |
11571200 |
|
2300 |
11253861 |
FrostStar |
D |
May 24, 2015, 12:18 p.m. |
OK |
FPC |
TESTS |
42 |
451 |
24064000 |
|
2300 |
11484409 |
_The_Mastermind_ |
D |
June 7, 2015, 9:30 a.m. |
OK |
FPC |
TESTS |
42 |
452 |
9216000 |
|
2300 |
11484081 |
greatsaiyanman |
D |
June 7, 2015, 9:02 a.m. |
OK |
FPC |
TESTS |
42 |
452 |
10854400 |
|
2300 |
12786107 |
Astreb |
D |
Aug. 31, 2015, 8:57 a.m. |
OK |
FPC |
TESTS |
42 |
467 |
16896000 |
|
2300 |
11485142 |
ghostriderhp99 |
D |
June 7, 2015, 10:25 a.m. |
OK |
FPC |
TESTS |
42 |
468 |
12800000 |
|
2300 |
11253869 |
vjudge2 |
D |
May 24, 2015, 12:19 p.m. |
OK |
FPC |
TESTS |
42 |
468 |
24064000 |
|
2300 |
11493630 |
bachpro |
D |
June 8, 2015, 3:31 a.m. |
OK |
FPC |
TESTS |
42 |
483 |
11366400 |
|
2300 |
12152975 |
seek |
D |
July 21, 2015, 6:27 p.m. |
OK |
FPC |
TESTS |
42 |
483 |
13721600 |
|
2300 |
11037173 |
AbstractKangaroo |
D |
May 8, 2015, 1:42 a.m. |
OK |
FPC |
TESTS |
42 |
499 |
20787200 |
|
2300 |
13721742 |
Lightning34 |
D |
Oct. 19, 2015, 4:46 a.m. |
OK |
GNU C++ |
TESTS |
42 |
93 |
7782400 |
|
2300 |
31728723 |
skylee |
D |
Oct. 26, 2017, 5:04 a.m. |
OK |
GNU C++ |
TESTS |
42 |
93 |
7987200 |
|
2300 |
31729035 |
skylee |
D |
Oct. 26, 2017, 5:27 a.m. |
OK |
GNU C++ |
TESTS |
42 |
108 |
7065600 |
|
2300 |
31729221 |
skylee |
D |
Oct. 26, 2017, 5:37 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
7065600 |
|
2300 |
31729134 |
skylee |
D |
Oct. 26, 2017, 5:33 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
7065600 |
|
2300 |
40986648 |
ReaLNero1 |
D |
July 30, 2018, 8:40 p.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
7987200 |
|
2300 |
13925181 |
vjtest |
D |
Oct. 29, 2015, 1:05 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
11980800 |
|
2300 |
13925141 |
vjtest |
D |
Oct. 29, 2015, 12:59 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
11980800 |
|
2300 |
13466674 |
cyxhahaha |
D |
Oct. 7, 2015, 5:43 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
11980800 |
|
2300 |
11440293 |
rxdoi |
D |
June 5, 2015, 4:28 a.m. |
OK |
GNU C++ |
TESTS |
42 |
109 |
14233600 |
|
2300 |
60448076 |
rainboy |
D |
Sept. 12, 2019, 2:52 p.m. |
OK |
GNU C11 |
TESTS |
42 |
779 |
13619200 |
|
2300 |
11039514 |
MinakoKojima |
D |
May 8, 2015, 8:28 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
6348800 |
|
2300 |
11054215 |
MinakoKojima |
D |
May 9, 2015, 11:15 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
6348800 |
|
2300 |
11054089 |
MinakoKojima |
D |
May 9, 2015, 11 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
6348800 |
|
2300 |
27683413 |
vjudge1 |
D |
June 9, 2017, 6:27 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
14540800 |
|
2300 |
11055701 |
peterpan |
D |
May 9, 2015, 2:37 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
14950400 |
|
2300 |
32563809 |
superguymj |
D |
Nov. 23, 2017, 12:08 a.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
17510400 |
|
2300 |
13917318 |
yeahpeng |
D |
Oct. 28, 2015, 3:04 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
19148800 |
|
2300 |
17216060 |
SssssssssssssbbbBBBB |
D |
April 7, 2016, 4:29 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
124 |
42086400 |
|
2300 |
23923008 |
Ragdoll |
D |
Jan. 18, 2017, 1:26 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
139 |
14028800 |
|
2300 |
11055775 |
peterpan |
D |
May 9, 2015, 2:49 p.m. |
OK |
GNU C++11 |
TESTS |
42 |
139 |
14950400 |
|
2300 |
62329804 |
animeFORever |
D |
Oct. 10, 2019, 8:07 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
139 |
12902400 |
|
2300 |
45262709 |
skylee |
D |
Nov. 4, 2018, 3:29 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
155 |
7270400 |
|
2300 |
54762948 |
vjudge5 |
D |
May 28, 2019, 4:19 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
155 |
15257600 |
|
2300 |
35977252 |
vjudge2 |
D |
March 5, 2018, 9:15 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
155 |
15564800 |
|
2300 |
62754993 |
chuducanhchy |
D |
Oct. 17, 2019, 4:02 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
155 |
16076800 |
|
2300 |
35740290 |
kuppu |
D |
Feb. 26, 2018, 5:31 p.m. |
OK |
GNU C++14 |
TESTS |
42 |
170 |
19558400 |
|
2300 |
36405983 |
kut_kjb1994 |
D |
March 19, 2018, 8:48 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
171 |
11366400 |
|
2300 |
33072847 |
Powerslave |
D |
Dec. 10, 2017, 5:30 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
171 |
17920000 |
|
2300 |
31440454 |
YaKon4ick |
D |
Oct. 17, 2017, 6:31 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
171 |
18022400 |
|
2300 |
36406994 |
kut_kjb1994 |
D |
March 19, 2018, 9:46 a.m. |
OK |
GNU C++14 |
TESTS |
42 |
171 |
18636800 |
|
2300 |
55106984 |
Balerion |
D |
June 5, 2019, 3:36 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
124 |
15257600 |
|
2300 |
47146468 |
YenSean |
D |
Dec. 17, 2018, 2:57 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
140 |
12083200 |
|
2300 |
41158458 |
crathva |
D |
Aug. 3, 2018, 1:43 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
155 |
11264000 |
|
2300 |
58677301 |
fsshakkhor |
D |
Aug. 12, 2019, 5:07 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
155 |
18534400 |
|
2300 |
55107054 |
vjudge4 |
D |
June 5, 2019, 3:40 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
156 |
15257600 |
|
2300 |
35975373 |
Davood |
D |
March 5, 2018, 7:19 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
156 |
17920000 |
|
2300 |
59394509 |
rareone0602 |
D |
Aug. 24, 2019, 9:47 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
156 |
18944000 |
|
2300 |
67524499 |
wxbxcxuxnxy |
D |
Dec. 24, 2019, 1:32 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
156 |
19353600 |
|
2300 |
62543870 |
Hasti_K |
D |
Oct. 14, 2019, 5:22 a.m. |
OK |
GNU C++17 |
TESTS |
42 |
156 |
21401600 |
|
2300 |
40714817 |
PEDY4000 |
D |
July 24, 2018, 6:29 p.m. |
OK |
GNU C++17 |
TESTS |
42 |
171 |
15360000 |
|
2300 |
11034131 |
uwi |
D |
May 7, 2015, 6:58 p.m. |
OK |
Java 7 |
TESTS |
42 |
218 |
8294400 |
|
2300 |
11033864 |
uwi |
D |
May 7, 2015, 6:52 p.m. |
OK |
Java 7 |
TESTS |
42 |
218 |
8396800 |
|
2300 |
12574817 |
ACLhj |
D |
Aug. 17, 2015, 12:02 p.m. |
OK |
Java 7 |
TESTS |
42 |
295 |
204800 |
|
2300 |
11272748 |
tehqin |
D |
May 26, 2015, 3:12 a.m. |
OK |
Java 7 |
TESTS |
42 |
482 |
60825600 |
|
2300 |
11035536 |
edorundo |
D |
May 7, 2015, 8:05 p.m. |
OK |
Java 7 |
TESTS |
42 |
530 |
107622400 |
|
2300 |
13216795 |
alibaba |
D |
Sept. 25, 2015, 10:31 a.m. |
OK |
Java 7 |
TESTS |
42 |
826 |
88371200 |
|
2300 |
11036340 |
pashka |
D |
May 7, 2015, 9:58 p.m. |
OK |
Java 7 |
TESTS |
42 |
1232 |
48332800 |
|
2300 |
11038852 |
A.Elahi |
D |
May 8, 2015, 6:49 a.m. |
OK |
Java 8 |
TESTS |
42 |
280 |
10956800 |
|
2300 |
56056015 |
Taran_1407 |
D |
June 25, 2019, 11:43 p.m. |
OK |
Java 8 |
TESTS |
42 |
343 |
33382400 |
|
2300 |
11026157 |
Petr |
D |
May 7, 2015, 5:05 p.m. |
OK |
Java 8 |
TESTS |
42 |
389 |
0 |
|
2300 |
11026386 |
Lewin |
D |
May 7, 2015, 5:08 p.m. |
OK |
Java 8 |
TESTS |
42 |
390 |
63692800 |
|
2300 |
11504442 |
Roberio |
D |
June 9, 2015, 2:18 a.m. |
OK |
Java 8 |
TESTS |
42 |
405 |
46592000 |
|
2300 |
11027808 |
mmaxio |
D |
May 7, 2015, 5:22 p.m. |
OK |
Java 8 |
TESTS |
42 |
420 |
34099200 |
|
2300 |
60448077 |
Dukkha |
D |
Sept. 12, 2019, 2:52 p.m. |
OK |
Java 8 |
TESTS |
42 |
468 |
11161600 |
|
2300 |
16874279 |
Sumeet.Varma |
D |
March 22, 2016, 4:24 p.m. |
OK |
Java 8 |
TESTS |
42 |
498 |
78745600 |
|
2300 |
11537366 |
vyxaryx |
D |
June 11, 2015, 7:55 p.m. |
OK |
Java 8 |
TESTS |
42 |
499 |
128409600 |
|
2300 |
26483868 |
sweiss |
D |
April 18, 2017, 8:39 p.m. |
OK |
Java 8 |
TESTS |
42 |
514 |
83148800 |
|
2300 |
11051766 |
og.kostya |
D |
May 9, 2015, 5:10 a.m. |
OK |
MS C# |
TESTS |
42 |
374 |
34406400 |
|
2300 |
11039458 |
azukun |
D |
May 8, 2015, 8:22 a.m. |
OK |
MS C# |
TESTS |
42 |
374 |
51609600 |
|
2300 |
11035010 |
haitao |
D |
May 7, 2015, 7:30 p.m. |
OK |
MS C# |
TESTS |
42 |
842 |
44851200 |
|
2300 |
11051729 |
og.kostya |
D |
May 9, 2015, 4:58 a.m. |
OK |
MS C# |
TESTS |
42 |
1356 |
36249600 |
|
2300 |
11051743 |
og.kostya |
D |
May 9, 2015, 5:03 a.m. |
OK |
MS C# |
TESTS |
42 |
1357 |
36352000 |
|
2300 |
11362497 |
zhouwenkai |
D |
May 31, 2015, 3:22 a.m. |
OK |
MS C++ |
TESTS |
42 |
156 |
13209600 |
|
2300 |
11028725 |
Milanin |
D |
May 7, 2015, 5:33 p.m. |
OK |
MS C++ |
TESTS |
42 |
171 |
11571200 |
|
2300 |
44656375 |
unknown000 |
D |
Oct. 21, 2018, 1:12 p.m. |
OK |
MS C++ |
TESTS |
42 |
187 |
16076800 |
|
2300 |
44656339 |
vjudge4 |
D |
Oct. 21, 2018, 1:12 p.m. |
OK |
MS C++ |
TESTS |
42 |
187 |
16076800 |
|
2300 |
11100251 |
AnnKats93 |
D |
May 14, 2015, 4:04 p.m. |
OK |
MS C++ |
TESTS |
42 |
187 |
16486400 |
|
2300 |
11336057 |
sister_what_hate_most |
D |
May 28, 2015, 4:53 p.m. |
OK |
MS C++ |
TESTS |
42 |
187 |
19251200 |
|
2300 |
18759235 |
Sandmann |
D |
June 27, 2016, 10:57 p.m. |
OK |
MS C++ |
TESTS |
42 |
187 |
26419200 |
|
2300 |
11029086 |
Alex7 |
D |
May 7, 2015, 5:37 p.m. |
OK |
MS C++ |
TESTS |
42 |
202 |
17305600 |
|
2300 |
11035858 |
AleksanderBalobanov |
D |
May 7, 2015, 8:42 p.m. |
OK |
MS C++ |
TESTS |
42 |
218 |
22016000 |
|
2300 |
11047400 |
Lint |
D |
May 8, 2015, 4:03 p.m. |
OK |
MS C++ |
TESTS |
42 |
234 |
20070400 |
|
2300 |
69986818 |
pajenegod |
D |
Feb. 1, 2020, 6:04 p.m. |
OK |
PyPy 2 |
TESTS |
42 |
623 |
61440000 |
|
2300 |
69986959 |
pajenegod |
D |
Feb. 1, 2020, 6:06 p.m. |
OK |
PyPy 2 |
TESTS |
42 |
654 |
63897600 |
|
2300 |
35887052 |
______u______ |
D |
March 3, 2018, 1:57 p.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35886744 |
______n______ |
D |
March 3, 2018, 1:51 p.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35885940 |
_____k_____ |
D |
March 3, 2018, 1:38 p.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35885798 |
_____i_____ |
D |
March 3, 2018, 1:36 p.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35874854 |
______h______ |
D |
March 3, 2018, 8:03 a.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35874627 |
______k______ |
D |
March 3, 2018, 7:57 a.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35874195 |
______i______ |
D |
March 3, 2018, 7:46 a.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
35872374 |
______M______ |
D |
March 3, 2018, 7:10 a.m. |
OK |
Python 2 |
TESTS |
42 |
1247 |
46592000 |
|
2300 |
11034709 |
Gassa |
D |
May 7, 2015, 7:16 p.m. |
OK |
Python 2 |
TESTS |
42 |
1263 |
42188800 |
|
2300 |
68302699 |
sansen |
D |
Jan. 6, 2020, 7:31 a.m. |
OK |
Rust |
TESTS |
42 |
156 |
17817600 |
|
2300 |
remove filters
Back to search problems