Educational Codeforces Round 140 (Rated for Div. 2)

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1767 Educational Codeforces Round 140 (Rated for Div. 2) FINISHED False 7200 65978663 Dec. 16, 2022, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 333 ) F Two Subtrees PROGRAMMING data structures trees

B'You are given a rooted tree consisting of n vertices. The vertex 1 is the root. Each vertex has an integer written on it; this integer is val_i for the vertex i . You are given q queries to the tree. The i -th query is represented by two vertices, u_i and v_i . To answer the query, consider all vertices w that lie in the subtree of u_i or v_i (if a vertex is in both subtrees, it is counted twice). For all vertices in these two subtrees, list all integers written on them, and find the integer with the maximum number of occurrences. If there are multiple integers with maximum number of occurrences, the minimum among them is the answer. The first line contains one integer n ( 1 <= n <= 2 cdot 10^5 ) -- the number of vertices in the tree. The second line contains n integers val_1, val_2, ... , val_n ( 1 <= val_i <= 2 cdot 10^5 ) -- the numbers written on the vertices. Then n - 1 lines follow, each containing two integers x and y ( 1 <= x, y <= n ) representing an edge between vertices x and y . These edges form a tree. The next line contains one integer q ( 1 <= q <= 2 cdot 10^5 ) -- the number of queries to process. Then q lines follow. The i -th of them containing two numbers u_i and v_i ( 1 <= u_i, v_i <= n ) -- the roots of subtrees in the i -th query. For each query, print one integer -- the number that has the maximum amount of occurrences in the corresponding pair of subtrees (if there are multiple such numbers, print the minimum one among them). In the 1 -st query, the pair of subtrees consists of vertices [2, 4, 7, 8] , and the numbers written on them are {1, 2, 2, 4 } . The number 2 occurs twice, all other numbers -- at most once, so the answer is 2 . In the 2 -nd query, the pair of subtrees consists of vertices [3, 5, 6, 7, 7, 8, 8]$$'...

Tutorials

110225

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
185581474 Alex_Wei F Dec. 17, 2022, 5:10 a.m. OK GNU C++17 (64) TESTS 76 1762 403968000
185581746 Alex_Wei F Dec. 17, 2022, 5:13 a.m. OK GNU C++17 (64) TESTS 76 1855 403968000
185548043 SSRS_ F Dec. 16, 2022, 6:08 p.m. OK GNU C++17 (64) TESTS 76 4148 88371200
185547524 SSRS_ F Dec. 16, 2022, 6:04 p.m. OK GNU C++17 (64) TESTS 76 4273 88371200
185547405 SSRS_ F Dec. 16, 2022, 6:03 p.m. OK GNU C++17 (64) TESTS 76 4726 136704000
185547990 jiangly F Dec. 16, 2022, 6:08 p.m. OK GNU C++20 (64) TESTS 76 1497 482099200
185548652 jiangly F Dec. 16, 2022, 6:14 p.m. OK GNU C++20 (64) TESTS 76 1512 401920000
185548166 jiangly F Dec. 16, 2022, 6:10 p.m. OK GNU C++20 (64) TESTS 76 1528 309760000
185559060 fallleaves01 F Dec. 16, 2022, 8:01 p.m. OK GNU C++20 (64) TESTS 76 1606 41369600
185548070 jiangly F Dec. 16, 2022, 6:09 p.m. OK GNU C++20 (64) TESTS 76 1637 121344000
185547931 jiangly F Dec. 16, 2022, 6:08 p.m. OK GNU C++20 (64) TESTS 76 1637 484249600
185548104 jiangly F Dec. 16, 2022, 6:09 p.m. OK GNU C++20 (64) TESTS 76 1638 241664000
185539153 tfg F Dec. 16, 2022, 5:03 p.m. OK GNU C++20 (64) TESTS 76 1808 236748800
185557505 YouKn0wWho F Dec. 16, 2022, 7:42 p.m. OK GNU C++20 (64) TESTS 76 3915 194764800
185557115 YouKn0wWho F Dec. 16, 2022, 7:38 p.m. OK GNU C++20 (64) TESTS 76 3977 194764800

remove filters

Back to search problems