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. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,132
13
180,264
Yes
output
1
90,132
13
180,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,133
13
180,266
Yes
output
1
90,133
13
180,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,134
13
180,268
No
output
1
90,134
13
180,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,135
13
180,270
No
output
1
90,135
13
180,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,136
13
180,272
No
output
1
90,136
13
180,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ...
instruction
0
90,137
13
180,274
No
output
1
90,137
13
180,275
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,182
13
180,364
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` import sys input = sys.stdin.readline class DSU: # Disjoint Set Union (Union-Find) Data Structure def __init__(self, nodes): # Dictionary of parents self.p = [i for i in range(nodes)] # Dictionary of ranks...
output
1
90,182
13
180,365
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,183
13
180,366
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` class UnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.rank = [1 for i in range(N)] self.rank[0] = 0 def union(self, x, y): if not self.is_same_set(x, y): par_x = se...
output
1
90,183
13
180,367
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,184
13
180,368
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` class Deque: def __init__(self): self.buff = [0] * 400000 self.l = 0 self.r = 0 def append(self, x): self.buff[self.r] = x self.r = self.r + 1 def popleft(self): old_left = self.l self.l = self.l + 1 return self.buff[old_...
output
1
90,184
13
180,369
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,185
13
180,370
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` import sys;sys.setrecursionlimit(10**9) class UnionFind: def __init__(self,n): self.n=[-1]*n self.r=[0]*n self.siz=n def find_root(self,x): if self.n[x]<0: return x else: self.n[x]=self.find_root(self.n[x...
output
1
90,185
13
180,371
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,186
13
180,372
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` from collections import defaultdict def colour(a, graph, cur, i): top = set() top.add(i) while len(top): x = top.pop() a[x] = cur for y in graph[x]: if a[y] == 0: top.add(y) ...
output
1
90,186
13
180,373
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,187
13
180,374
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` n = int(input()) class UnionFind(object): def __init__(self, n): # 初始化uf数组和组数目 self.count = n self.uf = [i for i in range(n)] self.size = [1] * n # 每个联通分量的size def find(self, x): # 判断节点所属于的组 while...
output
1
90,187
13
180,375
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,188
13
180,376
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` class UnionFind(): def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) def Find_Root(self, x): if(self.root[x] < 0): return x else: self...
output
1
90,188
13
180,377
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges). Let's call an ordered...
instruction
0
90,189
13
180,378
Tags: dfs and similar, divide and conquer, dp, dsu, trees Correct Solution: ``` from collections import deque from sys import stdin def bfs(source, graph, mark, num, fcount): visited = [source] q = deque() mark[source] = True q.append(source) while q: u = q.popleft() for v in graph[u]: if not mark[v]: ...
output
1
90,189
13
180,379
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,190
13
180,380
Yes
output
1
90,190
13
180,381
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,191
13
180,382
Yes
output
1
90,191
13
180,383
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,192
13
180,384
Yes
output
1
90,192
13
180,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,193
13
180,386
Yes
output
1
90,193
13
180,387
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,194
13
180,388
No
output
1
90,194
13
180,389
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,195
13
180,390
No
output
1
90,195
13
180,391
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,196
13
180,392
No
output
1
90,196
13
180,393
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) o...
instruction
0
90,197
13
180,394
No
output
1
90,197
13
180,395
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,198
13
180,396
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import heapq n,m,k = map(int,input().split()) connectionList = [] for _ in range(n): connectionList.append([]) edgeList = [] for _ in range(m): x,y,w = map(int,input().split()) edgeList.append((x,y,w)) edgeList.sort(k...
output
1
90,198
13
180,397
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,199
13
180,398
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import sys input = sys.stdin.readline n,m,k=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(m)] EDGE.sort(key=lambda x:x[2]) EDGE=EDGE[:k] COST_vertex=[[] for i in range(n+1)] VERLIST=[] for a,b,c...
output
1
90,199
13
180,399
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,200
13
180,400
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import sys input = sys.stdin.readline n,m,k=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(m)] EDGE.sort(key=lambda x:x[2]) EDGE=EDGE[:k] COST_vertex=[[] for i in range(n+1)] for a,b,c in EDGE: ...
output
1
90,200
13
180,401
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,201
13
180,402
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin....
output
1
90,201
13
180,403
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,202
13
180,404
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import sys input = sys.stdin.readline N, M, K = map(int, input().split()) X = [] for _ in range(M): x, y, w = map(int, input().split()) X.append([min(x,y), max(x,y), w]) X = (sorted(X, key = lambda x: x[2])+[[0, 0, 10**20...
output
1
90,202
13
180,405
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,203
13
180,406
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` # i8nd5t's code modified by spider_0859 import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify mod = 10**9+7 INF = floa...
output
1
90,203
13
180,407
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,204
13
180,408
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` import sys input = sys.stdin.readline n,m,k=map(int,input().split()) EDGE=[list(map(int,input().split())) for i in range(m)] EDGE.sort(key=lambda x:x[2]) EDGE=EDGE[:k] COST_vertex=[[] for i in range(n+1)] VERLIST=[] for a,b,c...
output
1
90,204
13
180,409
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from i to j and from j to i ar...
instruction
0
90,205
13
180,410
Tags: brute force, constructive algorithms, shortest paths, sortings Correct Solution: ``` # i8nd5t's code modified by spider_0859 import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify mod = 10**9+7 INF = floa...
output
1
90,205
13
180,411
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are no...
instruction
0
90,206
13
180,412
No
output
1
90,206
13
180,413
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are no...
instruction
0
90,207
13
180,414
No
output
1
90,207
13
180,415
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are no...
instruction
0
90,208
13
180,416
No
output
1
90,208
13
180,417
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a connected undirected weighted graph consisting of n vertices and m edges. You need to print the k-th smallest shortest path in this graph (paths from the vertex to itself are no...
instruction
0
90,209
13
180,418
No
output
1
90,209
13
180,419
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Wu got hungry after an intense training session, and came to a nearby store to buy his favourite instant noodles. After Wu paid for his purchase, the cashier gave him an interesting task. You a...
instruction
0
90,286
13
180,572
No
output
1
90,286
13
180,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Wu got hungry after an intense training session, and came to a nearby store to buy his favourite instant noodles. After Wu paid for his purchase, the cashier gave him an interesting task. You a...
instruction
0
90,287
13
180,574
No
output
1
90,287
13
180,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Wu got hungry after an intense training session, and came to a nearby store to buy his favourite instant noodles. After Wu paid for his purchase, the cashier gave him an interesting task. You a...
instruction
0
90,288
13
180,576
No
output
1
90,288
13
180,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Wu got hungry after an intense training session, and came to a nearby store to buy his favourite instant noodles. After Wu paid for his purchase, the cashier gave him an interesting task. You a...
instruction
0
90,289
13
180,578
No
output
1
90,289
13
180,579
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,532
13
181,064
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` import sys input = sys.stdin.buffer.readline class SegmentTree: def __init__(self, n, op, e): self.n = n self.op = op self.e = e self.size = 2 ** ((n - 1).bit_length()) self.node = [self.e] * (2 * self...
output
1
90,532
13
181,065
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,533
13
181,066
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` # dsu on tree # logistics: if the problem asked to compute some value of a subtree # naive method would be for each node, compute the query value which would be O(n^2) because of doing dfs for each node # we want to reuse some information of subtr...
output
1
90,533
13
181,067
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,534
13
181,068
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` import sys input = sys.stdin.buffer.readline class SegmentTree: def __init__(self, n, op, e): self.n = n self.op = op self.e = e self.size = 2 ** ((n - 1).bit_length()) self.node = [self.e] * (2 * self...
output
1
90,534
13
181,069
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,535
13
181,070
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` import sys input = sys.stdin.buffer.readline class SegmentTree: def __init__(self, n, op, e): self.n = n self.op = op self.e = e self.size = 2 ** ((n - 1).bit_length()) self.node = [self.e] * (2 * se...
output
1
90,535
13
181,071
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,536
13
181,072
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` from collections import defaultdict class SumDefaultdict(defaultdict): def __init__(self, *args, **kwargs) -> None: super().__init__(int, *args, **kwargs) self.mx = max(self.values()) self.mx_sum = sum(c for c, v in ...
output
1
90,536
13
181,073
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,537
13
181,074
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` import sys from collections import Counter n = int(input()) color = list(map(int, input().split())) adj = [[] for _ in range(n)] for _ in range(n-1): u, v = map(int, sys.stdin.readline().split()) u -= 1 v -= 1 adj[u].append(v) ...
output
1
90,537
13
181,075
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,538
13
181,076
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` def main(): import sys from collections import deque input = sys.stdin.readline N = int(input()) color = list(map(int, input().split())) color.insert(0, 0) adj = [[] for _ in range(N+1)] for _ in range(N-1): ...
output
1
90,538
13
181,077
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour...
instruction
0
90,539
13
181,078
Tags: data structures, dfs and similar, dsu, trees Correct Solution: ``` import os import sys from io import BytesIO, IOBase _str = str BUFSIZE = 8192 def str(x=b''): return x if type(x) is bytes else _str(x).encode() class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file...
output
1
90,539
13
181,079
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in...
instruction
0
90,540
13
181,080
No
output
1
90,540
13
181,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in...
instruction
0
90,541
13
181,082
No
output
1
90,541
13
181,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in...
instruction
0
90,542
13
181,084
No
output
1
90,542
13
181,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in...
instruction
0
90,543
13
181,086
No
output
1
90,543
13
181,087