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'Eikooc and Sushi play a game. The game is played on a tree having n nodes numbered 1 to n . Recall that a tree having n nodes is an undirected, connected graph with n-1 edges. They take turns alternately moving a token on the tree. Eikooc makes the first move, placing the token on any node of her choice. Sushi makes the next move, followed by Eikooc, followed by Sushi, and so on. In each turn after the first, a player must move the token to a node u such that Here x oplus y denotes the bitwise XOR operation on integers x and y . Both the players play optimally. The player who is unable to make a move loses. The following are examples which demonstrate the rules of the game. Before the game begins, Eikooc decides to sneakily relabel the nodes of the tree in her favour. Formally, a relabeling is a permutation p of length n (sequence of n integers wherein each integer from 1 to n occurs exactly once) where p_i denotes the new numbering of node i . She wants to maximize the number of nodes she can choose in the first turn which will guarantee her a win. Help Eikooc find any relabeling which will help her do so. The first line contains a single integer t~(1 <= t <= 10^5) -- the number of test cases. The description of each test case is as follows. The first line of each test case contains an integer n~(1 <= n <= 2 cdot 10^5) -- the number of nodes in the tree. The next n-1 lines contain two integers u and v (1 <= u, v <= n; u neq v) -- denoting an edge between nodes u and v . It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case print any suitable relabeling -- a permutation of length n which maximizes the number of nodes that can be chosen in the first turn that guarantee a win for Eikooc. If there are multiple such relabelings, you'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
135203604 |
cunzai_zsy0531 |
D |
Nov. 13, 2021, 12:43 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
93 |
15155200 |
|
2100 |
135210645 |
L7-56 |
D |
Nov. 13, 2021, 3:17 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
124 |
8601600 |
|
2100 |
135209178 |
E-ray |
D |
Nov. 13, 2021, 2:51 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
9420800 |
|
2100 |
135209529 |
jane1231 |
D |
Nov. 13, 2021, 2:57 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
11059200 |
|
2100 |
135210530 |
JXZhou |
D |
Nov. 13, 2021, 3:15 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
13619200 |
|
2100 |
135207704 |
Pepsi__Cola |
D |
Nov. 13, 2021, 2:24 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
15360000 |
|
2100 |
135207526 |
Pepsi__Cola |
D |
Nov. 13, 2021, 2:21 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
15360000 |
|
2100 |
135203763 |
KING_OF_TURTLE |
D |
Nov. 13, 2021, 12:48 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
60108800 |
|
2100 |
135165370 |
zulk |
D |
Nov. 12, 2021, 4:23 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
156 |
11161600 |
|
2100 |
135163036 |
woshihcw |
D |
Nov. 12, 2021, 4:18 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
156 |
13721600 |
|
2100 |
135164423 |
YHT_CC |
D |
Nov. 12, 2021, 4:21 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
62 |
15257600 |
|
2100 |
135209845 |
MollyXu |
D |
Nov. 13, 2021, 3:03 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
124 |
10752000 |
|
2100 |
135217803 |
B1ngFeng |
D |
Nov. 13, 2021, 5:15 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
139 |
8806400 |
|
2100 |
135168409 |
Nijoin_Hazuki |
D |
Nov. 12, 2021, 4:30 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
139 |
11366400 |
|
2100 |
135213724 |
et3_tsy3.0 |
D |
Nov. 13, 2021, 4:11 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
140 |
17510400 |
|
2100 |
135179759 |
empathy117 |
D |
Nov. 12, 2021, 5:46 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
155 |
13004800 |
|
2100 |
135167084 |
peterwuyihong |
D |
Nov. 12, 2021, 4:27 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
155 |
17305600 |
|
2100 |
135209075 |
spike_ |
D |
Nov. 13, 2021, 2:50 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
155 |
36044800 |
|
2100 |
135212398 |
alif_cse_ju |
D |
Nov. 13, 2021, 3:50 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
170 |
12902400 |
|
2100 |
135195099 |
Proofy |
D |
Nov. 12, 2021, 8:44 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
171 |
10240000 |
|
2100 |
135209882 |
HKing147 |
D |
Nov. 13, 2021, 3:04 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
155 |
19865600 |
|
2100 |
135209742 |
Evang |
D |
Nov. 13, 2021, 3:01 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
156 |
17203200 |
|
2100 |
135219589 |
Turkey |
D |
Nov. 13, 2021, 5:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
156 |
19046400 |
|
2100 |
135175870 |
Blondie |
D |
Nov. 12, 2021, 5:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
170 |
18022400 |
|
2100 |
135221293 |
codelegend |
D |
Nov. 13, 2021, 5:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
170 |
18534400 |
|
2100 |
135206168 |
dblark |
D |
Nov. 13, 2021, 1:52 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
170 |
18739200 |
|
2100 |
135186173 |
hamray |
D |
Nov. 12, 2021, 6:42 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
171 |
13824000 |
|
2100 |
135203274 |
Acc_Robin |
D |
Nov. 13, 2021, 12:33 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
171 |
15052800 |
|
2100 |
135196073 |
pluto_ish |
D |
Nov. 12, 2021, 9:04 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
171 |
17817600 |
|
2100 |
135172939 |
DioHERO |
D |
Nov. 12, 2021, 5 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
171 |
17817600 |
|
2100 |
135174043 |
Uppercase |
D |
Nov. 12, 2021, 5:06 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
140 |
17408000 |
|
2100 |
135208704 |
silxi |
D |
Nov. 13, 2021, 2:43 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
140 |
17715200 |
|
2100 |
135188693 |
robosapien |
D |
Nov. 12, 2021, 7:10 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
140 |
18227200 |
|
2100 |
135173522 |
Uppercase |
D |
Nov. 12, 2021, 5:03 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
140 |
19251200 |
|
2100 |
135179442 |
follow_diana_please |
D |
Nov. 12, 2021, 5:43 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
140 |
20992000 |
|
2100 |
135187690 |
xudian |
D |
Nov. 12, 2021, 6:58 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
155 |
16691200 |
|
2100 |
135184752 |
wbdzq1_ |
D |
Nov. 12, 2021, 6:28 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
155 |
19660800 |
|
2100 |
135197468 |
NewLul |
D |
Nov. 12, 2021, 9:32 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
155 |
19968000 |
|
2100 |
135176522 |
follow_diana_please |
D |
Nov. 12, 2021, 5:21 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
155 |
20992000 |
|
2100 |
135164195 |
fengYuanWanYe |
D |
Nov. 12, 2021, 4:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
155 |
22016000 |
|
2100 |
135179760 |
procrastinate7 |
D |
Nov. 12, 2021, 5:46 p.m. |
OK |
Java 11 |
TESTS |
53 |
732 |
63180800 |
|
2100 |
135173083 |
bobib |
D |
Nov. 12, 2021, 5:01 p.m. |
OK |
Java 11 |
TESTS |
53 |
889 |
104140800 |
|
2100 |
135179380 |
G.A.T.C |
D |
Nov. 12, 2021, 5:43 p.m. |
OK |
Java 11 |
TESTS |
53 |
1232 |
97689600 |
|
2100 |
135173088 |
TCchen |
D |
Nov. 12, 2021, 5:01 p.m. |
OK |
Java 8 |
TESTS |
53 |
233 |
21811200 |
|
2100 |
135201128 |
invincible777 |
D |
Nov. 12, 2021, 11:17 p.m. |
OK |
Java 8 |
TESTS |
53 |
545 |
62771200 |
|
2100 |
135168832 |
jakejase2 |
D |
Nov. 12, 2021, 4:31 p.m. |
OK |
Java 8 |
TESTS |
53 |
545 |
66867200 |
|
2100 |
135175485 |
tabr |
D |
Nov. 12, 2021, 5:14 p.m. |
OK |
Java 8 |
TESTS |
53 |
592 |
53452800 |
|
2100 |
135206486 |
kkkkush |
D |
Nov. 13, 2021, 1:59 a.m. |
OK |
Java 8 |
TESTS |
53 |
624 |
99225600 |
|
2100 |
135167218 |
thedesalizes |
D |
Nov. 12, 2021, 4:27 p.m. |
OK |
Java 8 |
TESTS |
53 |
639 |
62361600 |
|
2100 |
135164045 |
honeysingh18 |
D |
Nov. 12, 2021, 4:20 p.m. |
OK |
Java 8 |
TESTS |
53 |
702 |
66252800 |
|
2100 |
135198861 |
podtelkin |
D |
Nov. 12, 2021, 10:05 p.m. |
OK |
Java 8 |
TESTS |
53 |
1793 |
66355200 |
|
2100 |
135212563 |
Koo_Pung-Kei |
D |
Nov. 13, 2021, 3:53 a.m. |
OK |
Kotlin 1.5 |
TESTS |
53 |
1606 |
67276800 |
|
2100 |
135206924 |
P___ |
D |
Nov. 13, 2021, 2:09 a.m. |
OK |
MS C++ 2017 |
TESTS |
53 |
249 |
11264000 |
|
2100 |
135179366 |
r57shell |
D |
Nov. 12, 2021, 5:43 p.m. |
OK |
MS C++ 2017 |
TESTS |
53 |
264 |
11059200 |
|
2100 |
135218771 |
MiaoUUUo |
D |
Nov. 13, 2021, 5:27 a.m. |
OK |
MS C++ 2017 |
TESTS |
53 |
499 |
12595200 |
|
2100 |
135214950 |
andreyDagger |
D |
Nov. 13, 2021, 4:33 a.m. |
OK |
MS C++ 2017 |
TESTS |
53 |
514 |
18124800 |
|
2100 |
135189330 |
uttharapally.chandra |
D |
Nov. 12, 2021, 7:19 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
498 |
179814400 |
|
2100 |
135173491 |
hxu10 |
D |
Nov. 12, 2021, 5:03 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
638 |
52633600 |
|
2100 |
135172242 |
NecroSean38 |
D |
Nov. 12, 2021, 4:57 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
639 |
56115200 |
|
2100 |
135198757 |
whatshisbucket |
D |
Nov. 12, 2021, 10:02 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
779 |
52224000 |
|
2100 |
135168065 |
lallala |
D |
Nov. 12, 2021, 4:29 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
951 |
58675200 |
|
2100 |
135162990 |
plevande |
D |
Nov. 12, 2021, 4:18 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
967 |
83148800 |
|
2100 |
135204550 |
petya47 |
D |
Nov. 13, 2021, 1:10 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
842 |
83353600 |
|
2100 |
135164737 |
laplce |
D |
Nov. 12, 2021, 4:22 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
1091 |
99532800 |
|
2100 |
135204520 |
petya47 |
D |
Nov. 13, 2021, 1:09 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
1965 |
83763200 |
|
2100 |
135218575 |
megurine |
D |
Nov. 13, 2021, 5:24 a.m. |
OK |
Python 3 |
TESTS |
53 |
888 |
63897600 |
|
2100 |
135164249 |
kento_maeda |
D |
Nov. 12, 2021, 4:20 p.m. |
OK |
Python 3 |
TESTS |
53 |
1918 |
32460800 |
|
2100 |
135174564 |
kumalimak |
D |
Nov. 12, 2021, 5:08 p.m. |
OK |
Rust |
TESTS |
53 |
124 |
14438400 |
|
2100 |
135215092 |
Spheniscine |
D |
Nov. 13, 2021, 4:35 a.m. |
OK |
Rust |
TESTS |
53 |
124 |
14950400 |
|
2100 |
remove filters
Back to search problems