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
Iris has a tree rooted at vertex (1). Each vertex has a value of (\mathtt 0) or (\mathtt 1). Let's consider a leaf of the tree (the vertex (1) is never considered a leaf) and define its weight . Construct a string formed by the values of the vertices on the path starting at the root and ending in this leaf. Then the weight of the leaf is the difference between the number of occurrences of (\mathtt{10}) and (\mathtt{01}) substrings in it. Take the following tree as an example. Green vertices have a value of (\mathtt 1) while white vertices have a value of (\mathtt 0). Let's calculate the weight of the leaf (5): the formed string is (\mathtt{10110}). The number of occurrences of substring (\mathtt{10}) is (2), the number of occurrences of substring (\mathtt{01}) is (1), so the difference is (2 - 1 = 1). Let's calculate the weight of the leaf (6): the formed string is (\mathtt{101}). The number of occurrences of substring (\mathtt{10}) is (1), the number of occurrences of substring (\mathtt{01}) is (1), so the difference is (1 - 1 = 0). The score of a tree is defined as the number of leaves with non-zero weight in the tree. But the values of some vertices haven't been decided and will be given to you as (?). Filling the blanks would be so boring, so Iris is going to invite Dora to play a game. On each turn, one of the girls chooses any of the remaining vertices with value (?) and changes its value to (\mathtt{0}) or (\mathtt{1}), with Iris going first . The game continues until there are no vertices with value (\mathtt{?}) left in the tree. Iris aims to maximize the score of the tree, while Dora aims to minimize that. Assuming that both girls play optimally, please determine the final score of the tree. Each test consists of multiple test cases. The first line contains a single integer (t) ((1 \leq t \leq 5\cdot 10^4)) — the nu |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
278798952 |
mban259 |
A |
Aug. 30, 2024, 3:08 p.m. |
OK |
C# 10 |
TESTS |
19 |
327 |
21401600 |
|
|
|
278788705 |
wcdr |
A |
Aug. 30, 2024, 2:54 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
77 |
8704000 |
|
|
|
278785600 |
OctaneC8H18 |
A |
Aug. 30, 2024, 2:51 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
109 |
614400 |
|
|
|
278867427 |
ca_09_04 |
A |
Aug. 30, 2024, 10:52 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
102400 |
|
|
|
278834404 |
jamil314 |
A |
Aug. 30, 2024, 4:33 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
102400 |
|
|
|
278863578 |
abhi-bnsl |
A |
Aug. 30, 2024, 9:25 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
102400 |
|
|
|
278881100 |
vbsinha |
A |
Aug. 31, 2024, 4:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
102400 |
|
|
|
278871283 |
vrooooom |
A |
Aug. 31, 2024, 12:59 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
102400 |
|
|
|
278781243 |
Piokemon |
A |
Aug. 30, 2024, 2:46 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
512000 |
|
|
|
278795421 |
britishcat |
A |
Aug. 30, 2024, 3:03 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
512000 |
|
|
|
278791271 |
CSHwang |
A |
Aug. 30, 2024, 2:57 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
19 |
124 |
512000 |
|
|
|
278791221 |
asgcd |
A |
Aug. 30, 2024, 2:57 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
77 |
102400 |
|
|
|
278794651 |
shiomusubi496 |
A |
Aug. 30, 2024, 3:02 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
77 |
716800 |
|
|
|
278784448 |
xu826281112 |
A |
Aug. 30, 2024, 2:49 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
77 |
6758400 |
|
|
|
278867675 |
viveksingh912 |
A |
Aug. 30, 2024, 10:59 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
93 |
102400 |
|
|
|
278875830 |
Hyperlink_Blocked |
A |
Aug. 31, 2024, 2:43 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
93 |
102400 |
|
|
|
278887511 |
He_XY |
A |
Aug. 31, 2024, 5:22 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
93 |
716800 |
|
|
|
278861579 |
NotFound |
A |
Aug. 30, 2024, 8:50 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
108 |
102400 |
|
|
|
278874184 |
random_user_az |
A |
Aug. 31, 2024, 2:10 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
108 |
102400 |
|
|
|
278870700 |
dqu212 |
A |
Aug. 31, 2024, 12:43 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
108 |
102400 |
|
|
|
278783177 |
PieArmy |
A |
Aug. 30, 2024, 2:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
19 |
108 |
307200 |
|
|
|
278787560 |
ImmortaLimit |
A |
Aug. 30, 2024, 2:53 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
77 |
24371200 |
|
|
|
278785114 |
cmk666 |
A |
Aug. 30, 2024, 2:50 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
93 |
3072000 |
|
|
|
278786976 |
kotamanegi |
A |
Aug. 30, 2024, 2:52 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
102400 |
|
|
|
278791302 |
RED_INSIDE |
A |
Aug. 30, 2024, 2:57 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
102400 |
|
|
|
278787374 |
erray |
A |
Aug. 30, 2024, 2:53 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
102400 |
|
|
|
278783668 |
Dominater069 |
A |
Aug. 30, 2024, 2:49 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
102400 |
|
|
|
278785984 |
Fido_Puppy |
A |
Aug. 30, 2024, 2:51 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
512000 |
|
|
|
278793743 |
orz |
A |
Aug. 30, 2024, 3 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
921600 |
|
|
|
278853051 |
Salmon2653 |
A |
Aug. 30, 2024, 6:56 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
124 |
3174400 |
|
|
|
278824419 |
gxy001 |
A |
Aug. 30, 2024, 4:02 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
19 |
125 |
4096000 |
|
|
|
278783774 |
KumaTachiRen |
A |
Aug. 30, 2024, 2:49 p.m. |
OK |
C# 8 |
TESTS |
19 |
265 |
25702400 |
|
|
|
278787463 |
hos.lyric |
A |
Aug. 30, 2024, 2:53 p.m. |
OK |
D |
TESTS |
19 |
233 |
3072000 |
|
|
|
278791677 |
Gassa |
A |
Aug. 30, 2024, 2:58 p.m. |
OK |
D |
TESTS |
19 |
327 |
10956800 |
|
|
|
278802718 |
ghj1222 |
A |
Aug. 30, 2024, 3:14 p.m. |
OK |
GNU C11 |
TESTS |
19 |
281 |
8294400 |
|
|
|
278784273 |
Lilypad |
A |
Aug. 30, 2024, 2:49 p.m. |
OK |
Java 21 |
TESTS |
19 |
671 |
19148800 |
|
|
|
278808006 |
dusty.and.rusty |
A |
Aug. 30, 2024, 3:23 p.m. |
OK |
Java 21 |
TESTS |
19 |
718 |
23961600 |
|
|
|
278791933 |
danbanica |
A |
Aug. 30, 2024, 2:58 p.m. |
OK |
Java 8 |
TESTS |
19 |
327 |
0 |
|
|
|
278788822 |
rowechen |
A |
Aug. 30, 2024, 2:54 p.m. |
OK |
Java 8 |
TESTS |
19 |
499 |
16486400 |
|
|
|
278865668 |
profchi |
A |
Aug. 30, 2024, 10:07 p.m. |
OK |
Java 8 |
TESTS |
19 |
546 |
30105600 |
|
|
|
278814960 |
Tlatoani |
A |
Aug. 30, 2024, 3:37 p.m. |
OK |
Kotlin 1.9 |
TESTS |
19 |
406 |
204800 |
|
|
|
278790536 |
bcollet |
A |
Aug. 30, 2024, 2:56 p.m. |
OK |
PyPy 2 |
TESTS |
19 |
390 |
15360000 |
|
|
|
278787635 |
sos89756 |
A |
Aug. 30, 2024, 2:53 p.m. |
OK |
PyPy 3 |
TESTS |
19 |
515 |
12390400 |
|
|
|
278842432 |
eepsilon |
A |
Aug. 30, 2024, 5:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
186 |
8908800 |
|
|
|
278795026 |
cybsbbb |
A |
Aug. 30, 2024, 3:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
218 |
9523200 |
|
|
|
278792085 |
hxu10 |
A |
Aug. 30, 2024, 2:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
234 |
8294400 |
|
|
|
278791834 |
petamingks |
A |
Aug. 30, 2024, 2:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
234 |
9523200 |
|
|
|
278792560 |
toam |
A |
Aug. 30, 2024, 2:59 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
281 |
9420800 |
|
|
|
278859436 |
Wizard_of_Orz |
A |
Aug. 30, 2024, 8:18 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
312 |
27750400 |
|
|
|
278797818 |
tassei903 |
A |
Aug. 30, 2024, 3:06 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
342 |
28262400 |
|
|
|
278801440 |
Mukundan314 |
A |
Aug. 30, 2024, 3:12 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
343 |
34816000 |
|
|
|
278819405 |
Alex239 |
A |
Aug. 30, 2024, 3:48 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
390 |
27852800 |
|
|
|
278787389 |
yupooh |
A |
Aug. 30, 2024, 2:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
19 |
390 |
33792000 |
|
|
|
278789832 |
Jimanbanashi |
A |
Aug. 30, 2024, 2:55 p.m. |
OK |
Python 2 |
TESTS |
19 |
515 |
9011200 |
|
|
|
278873104 |
Extile |
A |
Aug. 31, 2024, 1:46 a.m. |
OK |
Python 3 |
TESTS |
19 |
437 |
2457600 |
|
|
|
278875467 |
another_asian |
A |
Aug. 31, 2024, 2:36 a.m. |
OK |
Python 3 |
TESTS |
19 |
484 |
1024000 |
|
|
|
278882338 |
Nirmal-Nanera |
A |
Aug. 31, 2024, 4:22 a.m. |
OK |
Python 3 |
TESTS |
19 |
499 |
18534400 |
|
|
|
278791755 |
andrey.m |
A |
Aug. 30, 2024, 2:58 p.m. |
OK |
Rust 2021 |
TESTS |
19 |
264 |
17305600 |
|
|
|
278790723 |
toor |
A |
Aug. 30, 2024, 2:57 p.m. |
OK |
Rust 2021 |
TESTS |
19 |
1202 |
102400 |
|
|
|
278836924 |
aditya_coder7 |
A |
Aug. 30, 2024, 4:42 p.m. |
OK |
Scala |
TESTS |
19 |
1999 |
26214400 |
|
|
remove filters
Back to search problems