message
stringlengths
2
49.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
446
108k
cluster
float64
13
13
__index_level_0__
int64
892
217k
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. C...
instruction
0
38,295
13
76,590
Tags: dfs and similar, graphs Correct Solution: ``` cycle_begin, cycle_end = -1, -1 g, mark, prev, edges = [], [], [], [] def dfs(u): global cycle_begin, cycle_end mark[u] = 1 for v in g[u]: if mark[v] == 0: prev[v] = u if dfs(v): return True elif mar...
output
1
38,295
13
76,591
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it. C...
instruction
0
38,296
13
76,592
Tags: dfs and similar, graphs Correct Solution: ``` def my_solve(n, m, graph, mask): if do_dfs_bool(n,graph,mask.copy()): c = get_cyclic(n, graph, mask) for u,v in c: graph[u].remove(v) if not do_dfs_bool(n,graph,mask.copy()): return 'YES' graph[u].append(v) return "NO" return "YES" def get_cycl...
output
1
38,296
13
76,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,297
13
76,594
Yes
output
1
38,297
13
76,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,298
13
76,596
Yes
output
1
38,298
13
76,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,299
13
76,598
No
output
1
38,299
13
76,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,300
13
76,600
No
output
1
38,300
13
76,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,301
13
76,602
No
output
1
38,301
13
76,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are...
instruction
0
38,302
13
76,604
No
output
1
38,302
13
76,605
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,558
13
77,116
"Correct Solution: ``` def sToTree(S): # print(S) if len(S)==0: return 'N' c = 0 left=0 right=0 #print(S) for i in range(len(S)): if S[i] =='(': c+=1 elif S[i] ==')': c-=1 elif c==0 and S[i]=='[': left=i elif c==0 and...
output
1
38,558
13
77,117
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,559
13
77,118
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int...
output
1
38,559
13
77,119
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,560
13
77,120
"Correct Solution: ``` class binary_tree(): def __init__(self,value,left=None,right=None): self.value=value self.left=left self.right=right def find_corres_bra(s,fr,to): count=0 x=-1 for i in range(len(s)): if s[i]==fr: count += 1 elif s[i]==to: ...
output
1
38,560
13
77,121
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,561
13
77,122
"Correct Solution: ``` def parse_node(l, r, S): left, right = 0, 0 cnt = 0 for i in range(l, r + 1): if S[i] == '(': cnt += 1 elif S[i] == ')': cnt -= 1 elif cnt == 0 and S[i] == "[": left = i elif cnt == 0 and S[i] == "]": righ...
output
1
38,561
13
77,123
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,562
13
77,124
"Correct Solution: ``` from sys import setrecursionlimit setrecursionlimit(10 ** 8) A = input() B = input() A_root = [[-1] * 3 for i in range(1000)] B_root = [[-1] * 3 for i in range(1000)] class Source(): def __init__(self, S): self.S = S self.pos = 0 def peek(S): return S.S[S.pos] if S.pos < len...
output
1
38,562
13
77,125
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,563
13
77,126
"Correct Solution: ``` def sep(S): l=r=0 for i,s in enumerate(S): l+=s=='(' r+=s==')' if l==r: j=S.find(']',i) s_l=S[1:i] s_r=S[j+2:-1] s_c=int(S[i+2:j]) break return s_l,s_c,s_r def solve(A,B): if A=='' or B=='': ...
output
1
38,563
13
77,127
Provide a correct Python 3 solution for this coding contest problem. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vert...
instruction
0
38,564
13
77,128
"Correct Solution: ``` def convert(S): cur = 0 def parse(): nonlocal cur if S[cur] == ')': return () cur += 1 # '(' left = parse() cur += 2 # ')[' num = 0 while S[cur] != ']': num = 10*num + int(S[cur]) cur += 1 ...
output
1
38,564
13
77,129
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree ha...
instruction
0
38,565
13
77,130
No
output
1
38,565
13
77,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree ha...
instruction
0
38,566
13
77,132
No
output
1
38,566
13
77,133
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree ha...
instruction
0
38,567
13
77,134
No
output
1
38,567
13
77,135
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree ha...
instruction
0
38,568
13
77,136
No
output
1
38,568
13
77,137
Provide tags and a correct Python 3 solution for this coding contest problem. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning tree that contains the edge (u, v). The weight...
instruction
0
39,112
13
78,224
Tags: data structures, dfs and similar, dsu, graphs, trees Correct Solution: ``` def find(u): if u == par[u] : return u par[u] = find(par[u]) return par[u] def union(u,v): if len(ev[u]) < len(ev[v]): u, v = v, u par[v] = u for j in ev[v] & ev[u]: ans[j] -= w ev[u] ^=...
output
1
39,112
13
78,225
Provide tags and a correct Python 3 solution for this coding contest problem. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning tree that contains the edge (u, v). The weight...
instruction
0
39,113
13
78,226
Tags: data structures, dfs and similar, dsu, graphs, trees Correct Solution: ``` from sys import stdin, stdout def main(): n, m = map(int, stdin.readline().split()) d = [] ev = [set() for _ in range(n + 1)] ans = [0] * m for i in range(m): u, v, w = map(int, stdin.readline().split()) ...
output
1
39,113
13
78,227
Provide tags and a correct Python 3 solution for this coding contest problem. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning tree that contains the edge (u, v). The weight...
instruction
0
39,114
13
78,228
Tags: data structures, dfs and similar, dsu, graphs, trees Correct Solution: ``` from sys import stdin, stdout n, m = map(int, stdin.readline().split()) d = [] ev = [set() for _ in range(n + 1)] ans = [0] * m for i in range(m): u, v, w = map(int, stdin.readline().split()) d.append((w, u, v)) ev[u].add(i) ...
output
1
39,114
13
78,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning ...
instruction
0
39,115
13
78,230
No
output
1
39,115
13
78,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning ...
instruction
0
39,116
13
78,232
No
output
1
39,116
13
78,233
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning ...
instruction
0
39,117
13
78,234
No
output
1
39,117
13
78,235
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning ...
instruction
0
39,118
13
78,236
No
output
1
39,118
13
78,237
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,568
13
79,136
"Correct Solution: ``` import sys sys.setrecursionlimit(200000) def f_dfs(i): global f_edges, counter visited[i] = True for edge in f_edges[i]: if visited[edge]: continue f_dfs(edge) finish_order[i] = (counter, i) counter += 1 def b_dfs(i, group): global b_edges,...
output
1
39,568
13
79,137
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,569
13
79,138
"Correct Solution: ``` # Acceptance of input import sys file_input = sys.stdin V, E = map(int, file_input.readline().split()) adj = [[] for i in range(V)] for i in range(E): s, t = map(int, file_input.readline().split()) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import...
output
1
39,569
13
79,139
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,570
13
79,140
"Correct Solution: ``` #!/usr/bin/env python3 # GRL_3_C: Connected Components - Strongly Connected Components from collections import namedtuple DirectedEdge = namedtuple('DirectedEdge', ('src', 'dest')) def revert(edge): return edge._replace(src=edge.dest, dest=edge.src) class Digraph: def __init__(sel...
output
1
39,570
13
79,141
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,571
13
79,142
"Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 6 0 1 1 0 1 2 2 4 4 3 3 2 4 0 1 0 3 2 3 3 4 output: 1 0 1 1 """ import sys sys.setrecursionlimit(int(1e5)) def generate_adj_table(_v_info): for v_detail in _v_info: v_from, v_to = map(int, v_detail) init_adj_tabl...
output
1
39,571
13
79,143
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,572
13
79,144
"Correct Solution: ``` def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = get_strongly_connected_components(edges, r_edg...
output
1
39,572
13
79,145
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,573
13
79,146
"Correct Solution: ``` # Acceptance of input import sys file_input = sys.stdin V, E = map(int, file_input.readline().split()) adj = [[] for i in range(V)] for i in range(E): s, t = map(int, file_input.readline().split()) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import...
output
1
39,573
13
79,147
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,574
13
79,148
"Correct Solution: ``` # Acceptance of input import sys file_input = sys.stdin V, E = map(int, file_input.readline().split()) adj = [[] for i in range(V)] for i in range(E): s, t = map(int, file_input.readline().split()) adj[s].append(t) # Tarjan's strongly connected components algorithm import collection...
output
1
39,574
13
79,149
Provide a correct Python 3 solution for this coding contest problem. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,00...
instruction
0
39,575
13
79,150
"Correct Solution: ``` def solve(): N, M = map(int, input().split()) edges = [[] for _ in [0]*N] r_edges = [[] for _ in [0]*N] for _ in [0]*M: a, b = map(int, input().split()) edges[a].append(b) r_edges[b].append(a) c = kosaraju(edges, r_edges) group = [0]*N for i i...
output
1
39,575
13
79,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,576
13
79,152
Yes
output
1
39,576
13
79,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,577
13
79,154
Yes
output
1
39,577
13
79,155
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,578
13
79,156
Yes
output
1
39,578
13
79,157
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,579
13
79,158
Yes
output
1
39,579
13
79,159
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,580
13
79,160
No
output
1
39,580
13
79,161
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,581
13
79,162
No
output
1
39,581
13
79,163
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,582
13
79,164
No
output
1
39,582
13
79,165
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reach...
instruction
0
39,583
13
79,166
No
output
1
39,583
13
79,167
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a graph with n vertices, each of which has it's own point A_i = (x_i, y_i) with integer coordinates, a planar tree if: * All points A_1, A_2, …, A_n are different and no three poin...
instruction
0
39,752
13
79,504
No
output
1
39,752
13
79,505
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let's call a graph with n vertices, each of which has it's own point A_i = (x_i, y_i) with integer coordinates, a planar tree if: * All points A_1, A_2, …, A_n are different and no three poin...
instruction
0
39,753
13
79,506
No
output
1
39,753
13
79,507
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,046
13
80,092
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` def parse(i): t = input().split() return int(t[0]), int(t[1]), i n, m = [int(x) for x in input().split()] list = [parse(i) for i in range(m)] list.sort(key=lambda x: (x[0], -x[1])) # print(list) f = 0 t = 1 fakeFrom = 1 fakeTo = 2...
output
1
40,046
13
80,093
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,047
13
80,094
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` def next(): global fr global to fr += 1 if fr == to: fr = 2 to += 1 n, m = tuple(map(int, input().split())) lenths = [] for i in range(m): a, b = tuple(map(int, input().split())) if b == 1: b = 0 ...
output
1
40,047
13
80,095
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,048
13
80,096
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` # Legends Always Come Up with Solution # Author: Manvir Singh import os import sys from io import BytesIO, IOBase from heapq import * def main(): n,m=map(int,input().split()) a=[list(map(int,input().split())) for _ in range(m)] ed...
output
1
40,048
13
80,097
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,049
13
80,098
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` # Legends Always Come Up with Solution # Author: Manvir Singh import os import sys from io import BytesIO, IOBase from heapq import * def main(): n,m=map(int,input().split()) a=[list(map(int,input().split())) for _ in range(m)] ed...
output
1
40,049
13
80,099
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,050
13
80,100
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` __author__ = 'MoonBall' import sys import functools # sys.stdin = open('data/D.in', 'r') T = 1 def process(): N, M = list(map(int, input().split())) e = [] for _ in range(M): e.append(list(map(int, input().split())) + [_]) e ...
output
1
40,050
13
80,101
Provide tags and a correct Python 3 solution for this coding contest problem. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to le...
instruction
0
40,051
13
80,102
Tags: constructive algorithms, data structures, graphs Correct Solution: ``` import sys from operator import itemgetter lines = sys.stdin.readlines() n, m = map(int, lines[0].split(' ')) def build_edge(i, row): parts = row.split(' ') return (int(parts[0]), int(parts[1]), i) def edge_key(a): return (a[0], -a[1]) ...
output
1
40,051
13
80,103