GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 19 July 2022

[Solution] Qpwoeirut and Vertices Codeforces Solution




E. Qpwoeirut and Vertices
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a connected undirected graph with n vertices and m edges. Vertices of the graph are numbered by integers from 1 to n and edges of the graph are numbered by integers from 1 to m.

Your task is to answer q queries, each consisting of two integers l and r. The answer to each query is the smallest non-negative integer k such that the following condition holds:

  • For all pairs of integers (a,b) such that labr, vertices a and b are reachable from one another using only the first k edges (that is, edges 1,2,,k).
Input

The first line contains a single integer t (1t1000) — the number of test cases.

The first line of each test case contains three integers nm, and q (2n1051m,q2105) — the

Solution Click Below:-  👉CLICK HERE

 number of vertices, edges, and queries respectively.

Each of the next m lines contains two integers ui and vi (1ui,vin) — ends of the i-th edge.

It is guaranteed that the graph is connected and there are no multiple edges or self-loops.

Another String Minimization Problem Codeforces Solution

Making Towers Codeforces Solution

Qpwoeirut And The City Codeforces Solution

Chopping Carrots (Easy Version) Codeforces Solution

Chopping Carrots (Hard Version) Codeforces Solution

Each of the next q lines contains two integers l and r (1lrn) — descriptions of the queries.

It is guaranteed that that the sum of n over all test cases does not exceed 105, the sum of m over all test cases does not exceed 2105, and the sum of q over all test cases does not exceed 2105.

Output

For each test case, print q integers — the answers to the queries.


No comments:

Post a Comment