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 N-1 subsets of \\{1,2,...,N\\}. Let the i-th set be E_i.
Let us choose two distinct elements u_i and v_i from each set E_i, and consider a graph T with N vertices and N-1 edges, w... | instruction | 0 | 90,774 | 13 | 181,548 |
No | output | 1 | 90,774 | 13 | 181,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given N-1 subsets of \\{1,2,...,N\\}. Let the i-th set be E_i.
Let us choose two distinct elements u_i and v_i from each set E_i, and consider a graph T with N vertices and N-1 edges, w... | instruction | 0 | 90,775 | 13 | 181,550 |
No | output | 1 | 90,775 | 13 | 181,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given N-1 subsets of \\{1,2,...,N\\}. Let the i-th set be E_i.
Let us choose two distinct elements u_i and v_i from each set E_i, and consider a graph T with N vertices and N-1 edges, w... | instruction | 0 | 90,776 | 13 | 181,552 |
No | output | 1 | 90,776 | 13 | 181,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given N-1 subsets of \\{1,2,...,N\\}. Let the i-th set be E_i.
Let us choose two distinct elements u_i and v_i from each set E_i, and consider a graph T with N vertices and N-1 edges, w... | instruction | 0 | 90,777 | 13 | 181,554 |
No | output | 1 | 90,777 | 13 | 181,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Once, during a lesson, Sasha got bored and decided to talk with his friends. Suddenly, he saw Kefa. Since we can talk endlessly about Kefa, we won't even start doing that. The conversation turne... | instruction | 0 | 90,967 | 13 | 181,934 |
No | output | 1 | 90,967 | 13 | 181,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,114 | 13 | 182,228 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
import os,io
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def distance(graph,u,v):
visited = {i: True for i in graph}
stack = [(u,0)]
rp = 0
while stack:
node,p = stack.pop()
if node == v:
rp = p
... | output | 1 | 91,114 | 13 | 182,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,115 | 13 | 182,230 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
from sys import stdin
for _ in range(int(input())):
n,a,b,da,db=map(int,input().split())
a-=1
b-=1
go=[[] for _ in range(n)]
for _ in range(n-1):
x,y=map(int,stdin.readline().split())
x-=1
y-=1
go[x].append... | output | 1 | 91,115 | 13 | 182,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,116 | 13 | 182,232 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
# -*- coding: utf-8 -*-
# import bisect
# import heapq
# import math
# import random
# from collections import Counter, defaultdict, deque
# from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
# from fractions import Fraction
# from functools import lr... | output | 1 | 91,116 | 13 | 182,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,117 | 13 | 182,234 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self._f... | output | 1 | 91,117 | 13 | 182,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,118 | 13 | 182,236 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, a, b, da, db = map(int,input().split())
C = [list(map(int,input().split())) for j in range(n-1)]
for j in range(n-1):
for k in range(2):
C[j][k] -= 1... | output | 1 | 91,118 | 13 | 182,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,119 | 13 | 182,238 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
from sys import stdin
def inp():
return stdin.buffer.readline().rstrip().decode('utf8')
def itg():
return int(stdin.buffer.readline())
def mpint():
return map(int, stdin.buffer.readline().split())
# ############################## import
f... | output | 1 | 91,119 | 13 | 182,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,120 | 13 | 182,240 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
from sys import stdin
def input():
return stdin.readline().strip()
tests = int(input())
for t in range(tests):
n, a, b, da, db = list(map(int, input().split()))
edge_ls = [[] for _ in range(n+1)]
for _ in range(n-1):
e1, e2 = list... | output | 1 | 91,120 | 13 | 182,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 edges.
Initially, Alice is located at vertex a, ... | instruction | 0 | 91,121 | 13 | 182,242 |
Tags: dfs and similar, dp, games, trees
Correct Solution:
```
# if da > db then Alice wins
# if dist(a, b) <= da then Alice wins
# if da+da >= db then Alice wins because Bob can't jump over Alice
# and go to some other branch of tree
# otherwise is there always an element at more than 2*da away?
# Optimizations if syn... | output | 1 | 91,121 | 13 | 182,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,122 | 13 | 182,244 |
Yes | output | 1 | 91,122 | 13 | 182,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,123 | 13 | 182,246 |
Yes | output | 1 | 91,123 | 13 | 182,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,124 | 13 | 182,248 |
Yes | output | 1 | 91,124 | 13 | 182,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,125 | 13 | 182,250 |
Yes | output | 1 | 91,125 | 13 | 182,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,126 | 13 | 182,252 |
No | output | 1 | 91,126 | 13 | 182,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,127 | 13 | 182,254 |
No | output | 1 | 91,127 | 13 | 182,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,128 | 13 | 182,256 |
No | output | 1 | 91,128 | 13 | 182,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice and Bob are playing a fun game of tree tag.
The game is played on a tree of n vertices numbered from 1 to n. Recall that a tree on n vertices is an undirected, connected graph with n-1 ed... | instruction | 0 | 91,129 | 13 | 182,258 |
No | output | 1 | 91,129 | 13 | 182,259 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,146 | 13 | 182,292 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
return dijkstraHeap(*args)
# return dijkstraHeapComparatorWrong(*args)
# return dijkstraHeapComparator(*args)
# return dijkstraSegTree(*args)
# return dijkstraSortedList(*args)
def dijk... | output | 1 | 91,146 | 13 | 182,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,147 | 13 | 182,294 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args)
# return dijkstraHeapComparatorWrong(*args)
# return dijkstraHeapComparator(*args)
return dijkstraSegTree(*args)
# return dijkstraSortedList(*args)
def dijk... | output | 1 | 91,147 | 13 | 182,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,148 | 13 | 182,296 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args)
# return dijkstraHeapComparatorWrong(*args)
return dijkstraHeapComparator(*args)
# return dijkstraSegTree(*args)
# return dijkstraSortedList(*args)
def dijk... | output | 1 | 91,148 | 13 | 182,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,149 | 13 | 182,298 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args)
return dijkstraHeapComparatorWrong(*args)
# return dijkstraHeapComparator(*args)
# return dijkstraSegTree(*args)
# return dijkstraSortedList(*args)
def dijk... | output | 1 | 91,149 | 13 | 182,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,150 | 13 | 182,300 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args) # 2979 ms
return dijkstraHeapComparatorWrong(*args) # 2823 ms
# return dijkstraHeapComparator(*args) # 2370 ms
# return dijkstraSegTree(*args) # 2417 ms with ... | output | 1 | 91,150 | 13 | 182,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,151 | 13 | 182,302 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args)
# return dijkstraHeapComparatorWrong(*args)
# return dijkstraHeapComparator(*args)
return dijkstraSegTree(*args) # with inf = -1
# return dijkstraSortedList(... | output | 1 | 91,151 | 13 | 182,303 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with ind... | instruction | 0 | 91,152 | 13 | 182,304 |
Tags: graphs, shortest paths
Correct Solution:
```
import io
import os
# import __pypy__
def dijkstra(*args):
# return dijkstraHeap(*args)
# return dijkstraHeapComparatorWrong(*args)
# return dijkstraHeapComparator(*args)
# return dijkstraSegTree(*args)
return dijkstraSortedList(*args)
def dijk... | output | 1 | 91,152 | 13 | 182,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the we... | instruction | 0 | 91,153 | 13 | 182,306 |
No | output | 1 | 91,153 | 13 | 182,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the we... | instruction | 0 | 91,154 | 13 | 182,308 |
No | output | 1 | 91,154 | 13 | 182,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the we... | instruction | 0 | 91,155 | 13 | 182,310 |
No | output | 1 | 91,155 | 13 | 182,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the we... | instruction | 0 | 91,156 | 13 | 182,312 |
No | output | 1 | 91,156 | 13 | 182,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a bipartite graph consisting of n_1 vertices in the first part, n_2 vertices in the second part, and m edges, numbered from 1 to m. You have to color each edge into one of two colo... | instruction | 0 | 91,157 | 13 | 182,314 |
No | output | 1 | 91,157 | 13 | 182,315 |
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 T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1.
Let's look at the subtree Tv of some vertex v. It is possible to read ... | instruction | 0 | 91,308 | 13 | 182,616 |
No | output | 1 | 91,308 | 13 | 182,617 |
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 T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1.
Let's look at the subtree Tv of some vertex v. It is possible to read ... | instruction | 0 | 91,309 | 13 | 182,618 |
No | output | 1 | 91,309 | 13 | 182,619 |
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 T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1.
Let's look at the subtree Tv of some vertex v. It is possible to read ... | instruction | 0 | 91,310 | 13 | 182,620 |
No | output | 1 | 91,310 | 13 | 182,621 |
Provide a correct Python 3 solution for this coding contest problem.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of painting these N vertices in K colors numbered 1,2,...,K. ... | instruction | 0 | 91,558 | 13 | 183,116 |
"Correct Solution:
```
class Unionfindtree:
def __init__(self, number):
self.par = [i for i in range(number)]
self.rank = [0] * (number)
def find(self, x): # 親を探す
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return... | output | 1 | 91,558 | 13 | 183,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of pa... | instruction | 0 | 91,559 | 13 | 183,118 |
No | output | 1 | 91,559 | 13 | 183,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of pa... | instruction | 0 | 91,560 | 13 | 183,120 |
No | output | 1 | 91,560 | 13 | 183,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of pa... | instruction | 0 | 91,561 | 13 | 183,122 |
No | output | 1 | 91,561 | 13 | 183,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of pa... | instruction | 0 | 91,562 | 13 | 183,124 |
No | output | 1 | 91,562 | 13 | 183,125 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
This pairing is valid if for every pair of pairs... | instruction | 0 | 91,902 | 13 | 183,804 |
Tags: constructive algorithms, dfs and similar, graphs, greedy, trees
Correct Solution:
```
# Fast IO (only use in integer input)
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
n,m = map(int,input().split())
connectionList = []
for _ in range(n):... | output | 1 | 91,902 | 13 | 183,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
T... | instruction | 0 | 91,903 | 13 | 183,806 |
No | output | 1 | 91,903 | 13 | 183,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
T... | instruction | 0 | 91,904 | 13 | 183,808 |
No | output | 1 | 91,904 | 13 | 183,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
T... | instruction | 0 | 91,905 | 13 | 183,810 |
No | output | 1 | 91,905 | 13 | 183,811 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
T... | instruction | 0 | 91,906 | 13 | 183,812 |
No | output | 1 | 91,906 | 13 | 183,813 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,991 | 13 | 183,982 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
import sys
from array import array # noqa: F401
import typing as Tp # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def output(*args):
sys.stdout.buffer.write(
('\n'.join(map(str, args)) + '\n').encode('utf-8')
... | output | 1 | 91,991 | 13 | 183,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,992 | 13 | 183,984 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BU... | output | 1 | 91,992 | 13 | 183,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,993 | 13 | 183,986 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
def main():
n,k=map(int,input().split())
tree=[[] for _ in range(n+1)]
# 1 indexed
for _ in range(n-1):
a,b=map(int,... | output | 1 | 91,993 | 13 | 183,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,994 | 13 | 183,988 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
n, k = map(int, input().split())
t, q = [[] for i in range(n + 1)], [1]
for j in range(n - 1):
a, b = map(int, input().split())
t[a].append(b)
t[b].append(a)
for x in q:
for y in t[x]: t[y].remove(x)
q.extend(t[x])
q.reverse()
a, luismore = ... | output | 1 | 91,994 | 13 | 183,989 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.