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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. ...
instruction
0
31,589
13
63,178
No
output
1
31,589
13
63,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mitya and Vasya are playing an interesting game. They have a rooted tree with n vertices, and the vertices are indexed from 1 to n. The root has index 1. Every other vertex i ≥ 2 has its parent ...
instruction
0
31,807
13
63,614
No
output
1
31,807
13
63,615
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mitya and Vasya are playing an interesting game. They have a rooted tree with n vertices, and the vertices are indexed from 1 to n. The root has index 1. Every other vertex i ≥ 2 has its parent ...
instruction
0
31,808
13
63,616
No
output
1
31,808
13
63,617
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mitya and Vasya are playing an interesting game. They have a rooted tree with n vertices, and the vertices are indexed from 1 to n. The root has index 1. Every other vertex i ≥ 2 has its parent ...
instruction
0
31,809
13
63,618
No
output
1
31,809
13
63,619
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vus the Cossack has a simple graph with n vertices and m edges. Let d_i be a degree of the i-th vertex. Recall that a degree of the i-th vertex is the number of conected edges to the i-th vertex...
instruction
0
31,842
13
63,684
No
output
1
31,842
13
63,685
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vus the Cossack has a simple graph with n vertices and m edges. Let d_i be a degree of the i-th vertex. Recall that a degree of the i-th vertex is the number of conected edges to the i-th vertex...
instruction
0
31,843
13
63,686
No
output
1
31,843
13
63,687
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vus the Cossack has a simple graph with n vertices and m edges. Let d_i be a degree of the i-th vertex. Recall that a degree of the i-th vertex is the number of conected edges to the i-th vertex...
instruction
0
31,844
13
63,688
No
output
1
31,844
13
63,689
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vus the Cossack has a simple graph with n vertices and m edges. Let d_i be a degree of the i-th vertex. Recall that a degree of the i-th vertex is the number of conected edges to the i-th vertex...
instruction
0
31,845
13
63,690
No
output
1
31,845
13
63,691
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,004
13
64,008
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` n , k = 0 , int(input()) p=[['0']*100 for i in range(100)] while k: for i in range(n): if i>k: break p[n][i]=p[i][n]='1' k=k-i n+=1 print(n) for i in range(n): print(''.join(p[i][:n])) ```
output
1
32,004
13
64,009
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,005
13
64,010
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` # Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase def main(): k=int(input()) l=3 r=100 while l<=r : n=l+((r-l)>>1) if (n*(n-1)*(n-2))/...
output
1
32,005
13
64,011
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,006
13
64,012
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` import sys import math c=int(input()) Ans=[] F=[1] for i in range(1,101): F.append(F[-1]*i) for i in range(100): Ans.append([0]*100) print(100) cycles=1 Ans[0][1]=1 Ans[1][0]=1 Ans[1][2]=1 Ans[2][1]=1 Ans[0][2]=1 Ans[2][0]=1 ...
output
1
32,006
13
64,013
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,007
13
64,014
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` n = int( input() ) a = [] MAXN = 100 for i in range(MAXN): a.append( [0]*MAXN ) for i in range(3): for j in range(3): if i != j: a[i][j] = 1 cycles = 1 if cycles != n: for i in range(3,MAXN): ...
output
1
32,007
13
64,015
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,008
13
64,016
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` n, k = 0, int(input()) p = [['0'] * 100 for i in range(100)] while k: for i in range(n): if i > k: break p[n][i] = p[i][n] = '1' k -= i n += 1 print(n) for i in range(n): print(''.join(p[i][:n])) ```
output
1
32,008
13
64,017
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,009
13
64,018
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` k=int(input()) i=3 while (i-2)*(i-1)*i//6<k: i+=1 a=[[1 for j in range(i)] for k in range(i)] b=(i-2)*(i-1)*i//6 j=0 while b>k: b-=i-2 a[j*2][j*2+1]=0 a[j*2+1][j*2]=0 j+=1 while k-b>0: l=3 while (l-2)*(l-1)*l/...
output
1
32,009
13
64,019
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,010
13
64,020
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` # Author : nitish420 -------------------------------------------------------------------- import os import sys from io import BytesIO, IOBase def main(): k=int(input()) l=3 r=100 while l<=r : n=l+((r-l)>>1) if (n*(n-1)*(n-2))/...
output
1
32,010
13
64,021
Provide tags and a correct Python 3 solution for this coding contest problem. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and ...
instruction
0
32,011
13
64,022
Tags: binary search, constructive algorithms, graphs, greedy Correct Solution: ``` n = int( input() ) a = [] MAXN = 100 for i in range(MAXN): a.append( [0]*MAXN ) for i in range(3): for j in range(3): if i != j: a[i][j] = 1 cycles = 1 if cycles != n: for i in range(3,MAXN): ...
output
1
32,011
13
64,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,012
13
64,024
Yes
output
1
32,012
13
64,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,013
13
64,026
Yes
output
1
32,013
13
64,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,014
13
64,028
No
output
1
32,014
13
64,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,015
13
64,030
No
output
1
32,015
13
64,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,016
13
64,032
No
output
1
32,016
13
64,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered g...
instruction
0
32,017
13
64,034
No
output
1
32,017
13
64,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to n. Then we represent the color o...
instruction
0
32,023
13
64,046
No
output
1
32,023
13
64,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to n. Then we represent the color o...
instruction
0
32,024
13
64,048
No
output
1
32,024
13
64,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to n. Then we represent the color o...
instruction
0
32,025
13
64,050
No
output
1
32,025
13
64,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. We will assume that the tree vertices are numbered by integers from 1 to n. Then we represent the color o...
instruction
0
32,026
13
64,052
No
output
1
32,026
13
64,053
Provide a correct Python 3 solution for this coding contest problem. We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added. We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to the graph ...
instruction
0
32,383
13
64,766
"Correct Solution: ``` import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from operator import itemgetter N,Q = map(int,readline().split()) m = map(int,read().split()) ABC = list(zip(m,m,m)) INF = 10 ** 18 cyclic_cost = [INF] * N for a,b,c in ABC: ...
output
1
32,383
13
64,767
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added. We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be gi...
instruction
0
32,384
13
64,768
No
output
1
32,384
13
64,769
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added. We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be gi...
instruction
0
32,385
13
64,770
No
output
1
32,385
13
64,771
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,460
13
64,920
"Correct Solution: ``` import sys f_i = sys.stdin n = int(f_i.readline()) class VCost: def __init__(self, v, cost): self.v_n = v self.cost = cost def __lt__(self, other): return self.cost < other.cost def __gt__(self, other): return self.cost > other.cost adj = [[VCost(in...
output
1
32,460
13
64,921
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,461
13
64,922
"Correct Solution: ``` # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_12_C ???????§????????????????II """ from enum import Enum from heapq import heappush, heappop, heapify class Sssp(object): """ single source shortest path """ INFINITY = 999999999 class Statu...
output
1
32,461
13
64,923
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,462
13
64,924
"Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 0 3 2 3 3 1 1 2 1 2 0 2 3 4 2 3 0 3 3 1 4 1 3 4 2 1 0 1 1 4 4 3 4 2 2 1 3 3 output: 0 0 1 2 2 2 3 1 4 3 """ import sys import heapq as hp WHITE, GRAY, BLACK = 0, 1, 2 D_MAX = int(5e10 + 1) def generate_adj_table(v_table): for ea...
output
1
32,462
13
64,925
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,463
13
64,926
"Correct Solution: ``` import sys from heapq import* e=sys.stdin.readline n=int(e()) A=[[]for _ in[0]*n] for _ in[0]*n: b=list(map(int,e().split())) for i in range(b[1]):k=2*-~i;A[b[0]]+=[(b[k],b[k+1])] H=[[0,0]] d=[0]+[1e6]*n c=[1]*n while H: f=heappop(H) u=f[1] c[u]=0 if d[u]>=f[0]: for s in A[u]: v=s[0] ...
output
1
32,463
13
64,927
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,464
13
64,928
"Correct Solution: ``` import heapq def dijkstra(n): inf = 10 ** 6 + 1 dist = [0] + [inf] * (n - 1) q = [(0, 0)] while q: u = heapq.heappop(q)[1] for (v, c) in edge[u]: alt = dist[u] + c if dist[v] > alt: dist[v] = alt heapq.heapp...
output
1
32,464
13
64,929
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,465
13
64,930
"Correct Solution: ``` import sys,collections N = int(sys.stdin.readline()) G = tuple(tuple(map(int,sys.stdin.readline().rstrip().split()))[2:] for _ in range(N)) # multi line with multi param # n x n adjacency matrix #G = [[-1,2,3],[2,-1,3],[1,2,-1]] INF = float("inf") ALL = set(range(N)) mst = set() distances = [INF]...
output
1
32,465
13
64,931
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,466
13
64,932
"Correct Solution: ``` from heapq import heapify, heappush, heappop INF = float("inf") def MAIN(): n = int(input()) G = [[i, INF] for i in range(n)] G[0][1] = 0 m = {} for _ in range(n): A = list(map(int, input().split())) m[A[0]] = {} for i in range(2, len(A), 2): ...
output
1
32,466
13
64,933
Provide a correct Python 3 solution for this coding contest problem. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. Constraints * $1 \leq n \leq 10,000$ * $0 \leq c_i \leq ...
instruction
0
32,467
13
64,934
"Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 0 3 2 3 3 1 1 2 1 2 0 2 3 4 2 3 0 3 3 1 4 1 3 4 2 1 0 1 1 4 4 3 4 2 2 1 3 3 output: 0 0 1 2 2 2 3 1 4 3 """ import sys import heapq as hp WHITE, GRAY, BLACK = 0, 1, 2 D_MAX = int(5e10 + 1) def generate_adj_table(v_table): for ea...
output
1
32,467
13
64,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,468
13
64,936
Yes
output
1
32,468
13
64,937
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,469
13
64,938
Yes
output
1
32,469
13
64,939
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,470
13
64,940
Yes
output
1
32,470
13
64,941
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,471
13
64,942
Yes
output
1
32,471
13
64,943
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,472
13
64,944
No
output
1
32,472
13
64,945
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,473
13
64,946
No
output
1
32,473
13
64,947
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,474
13
64,948
No
output
1
32,474
13
64,949
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. C...
instruction
0
32,475
13
64,950
No
output
1
32,475
13
64,951
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n. The graph is considered harmonious if and only if the following property holds: * For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤...
instruction
0
32,634
13
65,268
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings Correct Solution: ``` # unionfind class Uf: def __init__(self, N): self.p = list(range(N)) self.rank = [0] * N self.size = [1] * N def root(self, x): if self.p[x] != x: self.p[x] = self.roo...
output
1
32,634
13
65,269
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n. The graph is considered harmonious if and only if the following property holds: * For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤...
instruction
0
32,635
13
65,270
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings Correct Solution: ``` import io, os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n, m = [int(s) for s in input().split()] parent = [i for i in range(n + 1)] def find(a): a1 = a while a != parent[a]: a = paren...
output
1
32,635
13
65,271
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n. The graph is considered harmonious if and only if the following property holds: * For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤...
instruction
0
32,636
13
65,272
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings Correct Solution: ``` from collections import defaultdict import threading, sys sys.setrecursionlimit(10**8) visited = [False] * 200010 graph = defaultdict(set) def read(): return sys.stdin.readline().split() def dfs(start): vis...
output
1
32,636
13
65,273
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n. The graph is considered harmonious if and only if the following property holds: * For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤...
instruction
0
32,637
13
65,274
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings Correct Solution: ``` from bisect import bisect_left as bl, bisect_right as br, insort import sys import heapq # from math import * from collections import defaultdict as dd, deque def data(): return sys.stdin.readline().strip() def mdata(): ...
output
1
32,637
13
65,275
Provide tags and a correct Python 3 solution for this coding contest problem. You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n. The graph is considered harmonious if and only if the following property holds: * For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤...
instruction
0
32,638
13
65,276
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline n,m=map(int,input().split()) #E=[tuple(map(int,input().split())) for i in range(m)] Group=[i for i in range(n+1)] Nodes=[1]*(n+1) def find(x): while Group[x] != x: x=G...
output
1
32,638
13
65,277