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'You are given a directed graph G with n vertices and m edges between them. Initially, graph H is the same as graph G . Then you decided to perform the following actions: Note that the number of edges in H can be up to n^2 after performing the actions. You also wrote some values on vertices of graph H . More precisely, vertex i has the value of a_i written on it. Consider a simple path consisting of k distinct vertices with indexes v_1, v_2, ldots, v_k . The length of such a path is k . The value of that path is defined as sum_{i = 1}^k a_{v_i} . A simple path is considered the longest if there is no other simple path in the graph with greater length. Among all the longest simple paths in H , find the one with the smallest value. Each test contains multiple test cases. The first line contains the number of test cases t ( 1 <= t <= 10^4 ). The description of the test cases follows. The first line of each test case contains two integers n and m ( 1 <= n,m <= 2 cdot 10^5 ) -- the number of vertices and the number of edges. The second line contains n integers a_1, a_2, ldots, a_n ( 0 <= a_i <= 10^9 ) -- the numbers written on the vertices of graph H . The i -th of the next m lines contains two integers v_i and u_i ( 1 <= v_i, u_i <= n ) -- meaning that there is an edge going from vertex v_i to vertex u_i in graph G . Note that edges are directed. Also note that the graph may have self-loops and multiple edges. It is guaranteed that neither the sum of n nor the sum of m over all test cases exceeds 2 cdot 10^5 . For each test case, output two numbers -- the length of the longest simple path in H and the minimal possible value of such path. In the first test case, the longest path in both graphs is 1 to 3 to 4 to 5 to 2 . As the path inclu'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
234532964 |
KasodaniKyouko |
E |
Nov. 27, 2023, 4:10 a.m. |
OK |
C# 10 |
TESTS |
92 |
685 |
78848000 |
|
|
234541101 |
KasodaniKyouko |
E |
Nov. 27, 2023, 5:52 a.m. |
OK |
C# 10 |
TESTS |
92 |
732 |
79155200 |
|
|
234535990 |
KasodaniKyouko |
E |
Nov. 27, 2023, 4:49 a.m. |
OK |
C# 10 |
TESTS |
92 |
763 |
79155200 |
|
|
234530762 |
Mars_Dingdang |
E |
Nov. 27, 2023, 3:32 a.m. |
OK |
GNU C++14 |
TESTS |
92 |
78 |
26521600 |
|
|
234481593 |
yaotianqi |
E |
Nov. 26, 2023, 4:34 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
186 |
22630400 |
|
|
234476700 |
LDM0116 |
E |
Nov. 26, 2023, 4:15 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
217 |
25600000 |
|
|
234530209 |
RernaG |
E |
Nov. 27, 2023, 3:22 a.m. |
OK |
GNU C++14 |
TESTS |
92 |
218 |
27648000 |
|
|
234477026 |
Zhouyubo |
E |
Nov. 26, 2023, 4:16 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
234 |
26419200 |
|
|
234477200 |
Geoyster |
E |
Nov. 26, 2023, 4:17 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
264 |
26419200 |
|
|
234471725 |
confesser |
E |
Nov. 26, 2023, 3:58 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
264 |
40345600 |
|
|
234471560 |
_Burnside |
E |
Nov. 26, 2023, 3:58 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
280 |
20787200 |
|
|
234468894 |
StarSilk |
E |
Nov. 26, 2023, 3:49 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
280 |
27545600 |
|
|
234484480 |
ExRoc__ |
E |
Nov. 26, 2023, 5:18 p.m. |
OK |
GNU C++14 |
TESTS |
92 |
280 |
28979200 |
|
|
remove filters
Back to search problems