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.
You are given a directed acyclic graph (a directed graph that does not contain cycles) of n vertices and m arcs. The i-th arc leads from the vertex x_i to the vertex y_i and has the weight w_i.
... | instruction | 0 | 15,271 | 13 | 30,542 |
No | output | 1 | 15,271 | 13 | 30,543 |
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 acyclic graph (a directed graph that does not contain cycles) of n vertices and m arcs. The i-th arc leads from the vertex x_i to the vertex y_i and has the weight w_i.
... | instruction | 0 | 15,272 | 13 | 30,544 |
No | output | 1 | 15,272 | 13 | 30,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices.
A subtree of a tree T is a tree with bo... | instruction | 0 | 15,373 | 13 | 30,746 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
def minp():
return sys.stdin.readline().strip()
n = int(minp())
e = [0]
p = [None]*(n+1)
for i in range(n):
e.append([])
for i in range(n-1):
a, b = map(int,minp().split())
e[a].append(b)
e[b].append(a)
v = list(map(int,minp().split()))
pl... | output | 1 | 15,373 | 13 | 30,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,443 | 13 | 30,886 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
import sys
def readInts(): return [int(x) for x in sys.stdin.readline().split()]
def readInt(): return int(sys.stdin.readline())
def print(x):
sys.stdout.write(str(x) + '\n')
def solve():
MOD = int(1e9 + 7)
d, n = readInts()
a = readIn... | output | 1 | 15,443 | 13 | 30,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,444 | 13 | 30,888 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
d, n = map(int, input().split())
M = 10**9+7
a = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(n-1):
u, v = map(int, input().split())
u -= 1
v -= 1
g[u].append(v)
g[v].append(u)
vis = [0]*n
def dfs(i, prev... | output | 1 | 15,444 | 13 | 30,889 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,445 | 13 | 30,890 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
d, n = map(int,input().split())
a = list(map(int, input().split()))
mas = [[] for _ in range(n+1)]
MOD = 1000000007
for _ in range(n-1):
u, v = map(int,input().split())
mas[u].append(v)
mas[v].append(u)
# #mas = [[],[2,3,10],[1,6,7],[... | output | 1 | 15,445 | 13 | 30,891 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,446 | 13 | 30,892 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
f = lambda: map(int, input().split())
m = 1000000007
d, n = f()
t = list(f())
p = [[] for i in range(n)]
for j in range(n - 1):
u, v = f()
p[u - 1].append(v - 1)
p[v - 1].append(u - 1)
def g(u, x, y):
s = 1
for v in p[u]:
if 0 < ... | output | 1 | 15,446 | 13 | 30,893 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,447 | 13 | 30,894 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
d, n = map(int,input().split())
a = list(map(int, input().split()))
mas = [[] for _ in range(n+1)]
MOD = 1000000007
for _ in range(n-1):
u, v = map(int,input().split())
mas[u].append(v)
mas[v].append(u)
def dfs(nomer,mas,tyt_yge_bili,f,nach... | output | 1 | 15,447 | 13 | 30,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,448 | 13 | 30,896 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
import sys
def readInts(): return [int(x) for x in sys.stdin.readline().split()]
def readInt(): return int(sys.stdin.readline())
def print(x):
sys.stdout.write(str(x) + '\n')
def solve():
MOD = int(1e9 + 7)
d, n = readInts()
a = [0] + ... | output | 1 | 15,448 | 13 | 30,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,449 | 13 | 30,898 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
d, n = map(int,input().split())
a = list(map(int, input().split()))
mas = [[] for _ in range(n+1)]
MOD = 1000000007
for _ in range(n-1):
u, v = map(int,input().split())
mas[u].append(v)
mas[v].append(u)
# #mas = [[],[2,3,10],[1,6,7],[... | output | 1 | 15,449 | 13 | 30,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with it.
We call a set S of tree nodes valid if fol... | instruction | 0 | 15,450 | 13 | 30,900 |
Tags: dfs and similar, dp, math, trees
Correct Solution:
```
import sys
def readInts(): return [int(x) for x in sys.stdin.readline().split()]
def readInt(): return int(sys.stdin.readline())
# def print(x):
# sys.stdout.write(str(x) + '\n')
def solve():
MOD = int(1e9 + 7)
d, n = readInts()
a = re... | output | 1 | 15,450 | 13 | 30,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,451 | 13 | 30,902 |
Yes | output | 1 | 15,451 | 13 | 30,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,452 | 13 | 30,904 |
Yes | output | 1 | 15,452 | 13 | 30,905 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,453 | 13 | 30,906 |
No | output | 1 | 15,453 | 13 | 30,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,454 | 13 | 30,908 |
No | output | 1 | 15,454 | 13 | 30,909 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,455 | 13 | 30,910 |
No | output | 1 | 15,455 | 13 | 30,911 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As you know, an undirected connected graph with n nodes and n - 1 edges is called a tree. You are given an integer d and a tree consisting of n nodes. Each node i has a value ai associated with ... | instruction | 0 | 15,456 | 13 | 30,912 |
No | output | 1 | 15,456 | 13 | 30,913 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sagheer is playing a game with his best friend Soliman. He brought a tree with n nodes numbered from 1 to n and rooted at node 1. The i-th node has ai apples. This tree has a special property: the lengths of all paths from the root to any le... | instruction | 0 | 15,614 | 13 | 31,228 |
Tags: games, trees
Correct Solution:
```
n= int(input())
a = [int(_) for _ in input().split()]
c = [int(_) for _ in input().split()]
depth = [0] * (n)
for i in range(1,n):
depth[i] = depth[c[i-1]-1] + 1
MAX = max(depth)
t = 0
store = {}
todo = []
p = 0
for i in range(n):
if (MAX-depth[i]) % 2 == 0: # odd, useful... | output | 1 | 15,614 | 13 | 31,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Sagheer is playing a game with his best friend Soliman. He brought a tree with n nodes numbered from 1 to n and rooted at node 1. The i-th node has ai apples. This tree has a special property: the lengths of all paths from the root to any le... | instruction | 0 | 15,615 | 13 | 31,230 |
Tags: games, trees
Correct Solution:
```
def coloring(i, ancestors, color):
while i != 0 and color[ancestors[i - 1]] is None:
color[ancestors[i - 1]] = not color[i]
i = ancestors[i - 1]
def main():
n = int(input())
a = list(map(int, input().split()))
ancestors = list(map(lambda x: int(... | output | 1 | 15,615 | 13 | 31,231 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an strictly convex polygon with n vertices. It is guaranteed that no three points are collinear. You would like to take a maximum non intersecting path on the polygon vertices that... | instruction | 0 | 15,616 | 13 | 31,232 |
No | output | 1 | 15,616 | 13 | 31,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an strictly convex polygon with n vertices. It is guaranteed that no three points are collinear. You would like to take a maximum non intersecting path on the polygon vertices that... | instruction | 0 | 15,617 | 13 | 31,234 |
No | output | 1 | 15,617 | 13 | 31,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!
Each grid (main and r... | instruction | 0 | 16,062 | 13 | 32,124 |
No | output | 1 | 16,062 | 13 | 32,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!
Each grid (main and r... | instruction | 0 | 16,063 | 13 | 32,126 |
No | output | 1 | 16,063 | 13 | 32,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!
Each grid (main and r... | instruction | 0 | 16,064 | 13 | 32,128 |
No | output | 1 | 16,064 | 13 | 32,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!
Each grid (main and r... | instruction | 0 | 16,065 | 13 | 32,130 |
No | output | 1 | 16,065 | 13 | 32,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,098 | 13 | 32,196 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
from array import array # noqa: F401
from typing import List, Tuple, TypeVar, Generic, Sequence, Union # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def main():
n, m = map(int, input().split())
adj = [... | output | 1 | 16,098 | 13 | 32,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,099 | 13 | 32,198 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys, math,os
from io import BytesIO, IOBase
# data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# from bisect import bisect_left as bl, bisect_right as br, insort
# from heapq import heapify, heappush, heappop
from collections import defaultdict... | output | 1 | 16,099 | 13 | 32,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,100 | 13 | 32,200 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list... | output | 1 | 16,100 | 13 | 32,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,101 | 13 | 32,202 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
from collections import deque
import sys
input = sys.stdin.readline
def bfs(s):
q = deque()
q.append(s)
dist = [-1] * (n + 1)
dist[s] = 0
parent = [-1] * (n + 1)
while q:
i = q.popleft()
d = dist[i] + 1
for j in ... | output | 1 | 16,101 | 13 | 32,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,102 | 13 | 32,204 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
from sys import stdin, stdout
tree = []
parent = []
go_in = []
go_out = []
d = []
def main():
global tree
global parent
global go_in
global go_out
global d
n,k = list(map(int, stdin.readline().split()))
tree = [[] for _ in range(n+... | output | 1 | 16,102 | 13 | 32,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,103 | 13 | 32,206 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is Ge... | output | 1 | 16,103 | 13 | 32,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,104 | 13 | 32,208 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
from collections import defaultdict
from collections import deque
from enum import Enum
"""
Because it asks for node within distance 1.
We can consider parent of the given node.
After that, we've to find whether if ... | output | 1 | 16,104 | 13 | 32,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i... | instruction | 0 | 16,105 | 13 | 32,210 |
Tags: dfs and similar, graphs, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
EDGELIST=[[] for i in range(n+1)]
for i in range(n-1):
x,y=map(int,input().split())
EDGELIST[x].append(y)
EDGELIST[y].append(x)
DEPTH=[-1]*(n+1)
DEPTH[1]=0
from collections impor... | output | 1 | 16,105 | 13 | 32,211 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,106 | 13 | 32,212 |
Yes | output | 1 | 16,106 | 13 | 32,213 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,107 | 13 | 32,214 |
Yes | output | 1 | 16,107 | 13 | 32,215 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,108 | 13 | 32,216 |
Yes | output | 1 | 16,108 | 13 | 32,217 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,109 | 13 | 32,218 |
Yes | output | 1 | 16,109 | 13 | 32,219 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,110 | 13 | 32,220 |
No | output | 1 | 16,110 | 13 | 32,221 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,111 | 13 | 32,222 |
No | output | 1 | 16,111 | 13 | 32,223 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,112 | 13 | 32,224 |
No | output | 1 | 16,112 | 13 | 32,225 |
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 consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m que... | instruction | 0 | 16,113 | 13 | 32,226 |
No | output | 1 | 16,113 | 13 | 32,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and th... | instruction | 0 | 16,283 | 13 | 32,566 |
Tags: constructive algorithms, dfs and similar, trees
Correct Solution:
```
from collections import defaultdict
class Solution:
def __init__(self):
pass
def solve_and_print(self):
tree = Tree()
parents = [None] * (tree.n+1)
parents[1] = 1
tree.set_parents(1, ... | output | 1 | 16,283 | 13 | 32,567 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and th... | instruction | 0 | 16,284 | 13 | 32,568 |
Tags: constructive algorithms, dfs and similar, trees
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n = int(input())
adj = [[] for _ in range(n + 1)]
deg = [0] * (n + 1)
deg[1] = 1
for _ in range(n - 1):
u, v = map(int... | output | 1 | 16,284 | 13 | 32,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and th... | instruction | 0 | 16,285 | 13 | 32,570 |
Tags: constructive algorithms, dfs and similar, trees
Correct Solution:
```
class Node:
def __init__(self, data=None):
self.data = data
self.connections = []
self.path = []
class Tree:
def __init__(self):
self.root = None
self.nodes = {}
def addConnections(self, p,... | output | 1 | 16,285 | 13 | 32,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and th... | instruction | 0 | 16,286 | 13 | 32,572 |
Tags: constructive algorithms, dfs and similar, trees
Correct Solution:
```
from collections import defaultdict
def set_parents(tree, node, parents):
for i in tree[node]:
if parents[i] is None:
parents[i] = node
set_parents(tree, i, parents)
def create_path(leaves, leaves_path):
... | output | 1 | 16,286 | 13 | 32,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and th... | instruction | 0 | 16,287 | 13 | 32,574 |
Tags: constructive algorithms, dfs and similar, trees
Correct Solution:
```
n = int(input())
adj = [[] for i in range(n)]
adj2 = [[] for i in range(n)]
for i in range(n-1):
u,v = map(int,input().split())
adj[u-1].append(v-1)
adj[v-1].append(u-1)
leaf = {}
a = list(map(int,input().split()))
for i in range(l... | output | 1 | 16,287 | 13 | 32,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He see... | instruction | 0 | 16,288 | 13 | 32,576 |
No | output | 1 | 16,288 | 13 | 32,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He see... | instruction | 0 | 16,289 | 13 | 32,578 |
No | output | 1 | 16,289 | 13 | 32,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He see... | instruction | 0 | 16,290 | 13 | 32,580 |
No | output | 1 | 16,290 | 13 | 32,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.
An ant stands at the root of some tree. He see... | instruction | 0 | 16,291 | 13 | 32,582 |
No | output | 1 | 16,291 | 13 | 32,583 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.