Good Bye 2023

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
1916 Good Bye 2023 FINISHED False 7200 72457823 Dec. 30, 2023, 2:50 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 234 ) G Optimizations From Chelsu PROGRAMMING divide and conquer dp number theory trees

You are given a tree with (n) vertices, whose vertices are numbered from (1) to (n). Each edge is labeled with some integer (w_i). Define (len(u, v)) as the number of edges in the simple path between vertices (u) and (v), and (gcd(u, v)) as the Greatest Common Divisor of all numbers written on the edges of the simple path between vertices (u) and (v). For example, (len(u, u) = 0) and (gcd(u, u) = 0) for any (1 \leq u \leq n). You need to find the maximum value of (len(u, v) \cdot gcd(u, v)) over all pairs of vertices in the tree. Each test consists of multiple test cases. The first line contains a single integer (t) ((1 \leq t \leq 10^4)) — the number of test cases. This is followed by their description. The first line of each test case contains the number (n) ((2 \leq n \leq 10^5)) — the number of vertices in the tree. The next (n-1) lines specify the edges in the format (u), (v), (w) ((1 \leq u, v \leq n), (1 \leq w \leq 10^{12})). It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, output a single number equal to the maximum value of (len(u, v) \cdot gcd(u, v)) over all pairs of vertices in the tree.

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
239726464 rainboy G Dec. 30, 2023, 7:39 p.m. OK GNU C11 TESTS 119 1497 16691200
239735738 Benq G Dec. 30, 2023, 9:55 p.m. OK GNU C++17 (64) TESTS 119 342 30515200
239751483 lunchbox G Dec. 31, 2023, 4:18 a.m. OK GNU C++17 (64) TESTS 119 358 26009600
239729679 Benq G Dec. 30, 2023, 8:13 p.m. OK GNU C++17 (64) TESTS 119 358 27443200
239745822 lunchbox G Dec. 31, 2023, 2:29 a.m. OK GNU C++17 (64) TESTS 119 421 50892800
239743726 lunchbox G Dec. 31, 2023, 1:37 a.m. OK GNU C++17 (64) TESTS 119 764 29081600
239749994 chappy1 G Dec. 31, 2023, 3:49 a.m. OK GNU C++17 (64) TESTS 119 779 29081600
239748614 hayley17 G Dec. 31, 2023, 3:25 a.m. OK GNU C++20 (64) TESTS 119 390 25395200
239740268 ecnerwala G Dec. 30, 2023, 11:51 p.m. OK GNU C++20 (64) TESTS 119 405 25395200
239748275 your_submissions_ G Dec. 31, 2023, 3:19 a.m. OK GNU C++20 (64) TESTS 119 451 22220800
239726240 jiangly G Dec. 30, 2023, 7:37 p.m. OK GNU C++20 (64) TESTS 119 452 22220800
239755108 coding_bit G Dec. 31, 2023, 5:15 a.m. OK GNU C++20 (64) TESTS 119 561 18432000
239725152 inst-veplsnx G Dec. 30, 2023, 7:29 p.m. OK GNU C++20 (64) TESTS 119 608 18432000
239729702 ManojkumarPatanik G Dec. 30, 2023, 8:13 p.m. OK GNU C++20 (64) TESTS 119 1809 22835200

remove filters

Back to search problems