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.
We have a graph with N vertices and M edges, and there are two people on the graph: Takahashi and Aoki.
The i-th edge connects Vertex U_i and Vertex V_i. The time it takes to traverse this edge... | instruction | 0 | 65,506 | 13 | 131,012 |
No | output | 1 | 65,506 | 13 | 131,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and ... | instruction | 0 | 65,631 | 13 | 131,262 |
Tags: binary search, data structures, dp, greedy, trees
Correct Solution:
```
from collections import defaultdict
def rec(n, l, s):
# dp[i] is a doctionary, where key is the chain length
# and value is the weight at node i
dp = [{} for _ in range(n)]
ans = 0
for cur in range(n - 1, -1, -1):
... | output | 1 | 65,631 | 13 | 131,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and ... | instruction | 0 | 65,632 | 13 | 131,264 |
Tags: binary search, data structures, dp, greedy, trees
Correct Solution:
```
n , l , s = map(int , input().split())
i , ans = n , 0
w , par , vis = [0] , [0 , 0] , [0] * (n + 10)
for u in map(int , input().split()):
if(u > s):
print(-1) , exit(0)
w.append(u)
if(n > 1):
for u in map(int , input().sp... | output | 1 | 65,632 | 13 | 131,265 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and ... | instruction | 0 | 65,633 | 13 | 131,266 |
Tags: binary search, data structures, dp, greedy, trees
Correct Solution:
```
def solve(n, l, s, www, children):
ans = 0
dp = [{} for _ in range(n)]
for v in range(n - 1, -1, -1):
cv = children[v]
if not cv:
dp[v][1] = www[v]
continue
ans += len(cv) - 1
... | output | 1 | 65,633 | 13 | 131,267 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and ... | instruction | 0 | 65,634 | 13 | 131,268 |
Tags: binary search, data structures, dp, greedy, trees
Correct Solution:
```
from collections import defaultdict
import sys
def rec(n, l, s):
# dp[i] is a doctionary, where key is the chain length
# and value is the weight at node i
dp = [{} for _ in range(n)]
ans = 0
for cur in range(n - 1, -1, ... | output | 1 | 65,634 | 13 | 131,269 |
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 on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that ... | instruction | 0 | 65,635 | 13 | 131,270 |
No | output | 1 | 65,635 | 13 | 131,271 |
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 on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that ... | instruction | 0 | 65,636 | 13 | 131,272 |
No | output | 1 | 65,636 | 13 | 131,273 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider an undirected graph G with n vertices. There is a value a_i in each vertex.
Two vertices i and j are connected with an edge if and only if gcd(a_i, a_j) > 1, where gcd(x, y) denotes th... | instruction | 0 | 65,674 | 13 | 131,348 |
No | output | 1 | 65,674 | 13 | 131,349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider an undirected graph G with n vertices. There is a value a_i in each vertex.
Two vertices i and j are connected with an edge if and only if gcd(a_i, a_j) > 1, where gcd(x, y) denotes th... | instruction | 0 | 65,675 | 13 | 131,350 |
No | output | 1 | 65,675 | 13 | 131,351 |
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. We will consider simple paths on it. Let's denote path between vertices a and b as (a, b). Let d-neighborhood of a path be a set of vertices of the tree located at a distan... | instruction | 0 | 65,802 | 13 | 131,604 |
No | output | 1 | 65,802 | 13 | 131,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,835 | 13 | 131,670 |
Tags: dp, math, matrices
Correct Solution:
```
from sys import stdin
from collections import deque
mod = 10**9 + 7
import sys
sys.setrecursionlimit(10**5)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect import bisect_left
fr... | output | 1 | 65,835 | 13 | 131,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,836 | 13 | 131,672 |
Tags: dp, math, matrices
Correct Solution:
```
import sys
input=sys.stdin.readline
m=10**9+7
n=int(input())
a=b=c=s=1
d=t=0
'''dp[i][j] ye bata raha h ki (i remaining turns me j(A,B,C,D) pr
kitne tareeko se pohoch skte h)
wo humesha peeche steps pr hi depend krega'''
'''matrix nhi bn skti h sirf purane states ka
hi u... | output | 1 | 65,836 | 13 | 131,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,837 | 13 | 131,674 |
Tags: dp, math, matrices
Correct Solution:
```
import sys
input = sys.stdin.readline
mod = 10**9+7
'''
mod = 10**9+7
def abhi(y,n):
if n==0:
if y==4:
return 1
else:
return 0
elif dp[n][y]!=-1:
return dp[n][y]
else:
u='1243'
a=0
... | output | 1 | 65,837 | 13 | 131,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,838 | 13 | 131,676 |
Tags: dp, math, matrices
Correct Solution:
```
def main():
fpp = 0
fp = 0
f = 3
n = int(input())
if n == 1:
print(0)
return
for i in range(3, n + 1):
fpp = fp
fp = f
f = (2 * fp + 3 * fpp) % 1000000007
print(f)
return
if __name__ == "__main__":
... | output | 1 | 65,838 | 13 | 131,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,839 | 13 | 131,678 |
Tags: dp, math, matrices
Correct Solution:
```
def solve(n, mod, dp):
current = dp[0]
for i in range(1, n + 1):
current = (3 * current) + (2 * dp[1])
dp = (dp[1] % mod, current % mod)
current = dp[0]
return dp[0]
n = int(input())
mod = 1000000007
dp = (1, 0)
print(solve(n, mo... | output | 1 | 65,839 | 13 | 131,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,840 | 13 | 131,680 |
Tags: dp, math, matrices
Correct Solution:
```
n=int(input())
# def mod1(a,mod):
# return a%mod
# def mult(a,b,mod):
# return mod1((mod1(a,mod)*mod1(b,mod)),mod)
# def sumd(a,b,mod):
# return mod1((mod1(a,mod)+mod1(b,mod)),mod)
# def main(n):
# prev123 = 0
# prev4 = 1
# for i in range(1,n+1):
# prevx = ... | output | 1 | 65,840 | 13 | 131,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,841 | 13 | 131,682 |
Tags: dp, math, matrices
Correct Solution:
```
n = int(input()); p = 3; ans = 0
for i in range(1,n):
ans = (p - ans) % 1000000007; p = p % 1000000007 * 3;
print(ans)
``` | output | 1 | 65,841 | 13 | 131,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.
<image>
An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he ma... | instruction | 0 | 65,842 | 13 | 131,684 |
Tags: dp, math, matrices
Correct Solution:
```
n=int(input())
a,b=1,0
m=10**9+7
for i in range(n):
a,b=(b*3)%m,(a+b*2)%m
print(a)
``` | output | 1 | 65,842 | 13 | 131,685 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. V... | instruction | 0 | 66,024 | 13 | 132,048 |
No | output | 1 | 66,024 | 13 | 132,049 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. V... | instruction | 0 | 66,025 | 13 | 132,050 |
No | output | 1 | 66,025 | 13 | 132,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. V... | instruction | 0 | 66,026 | 13 | 132,052 |
No | output | 1 | 66,026 | 13 | 132,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. V... | instruction | 0 | 66,027 | 13 | 132,054 |
No | output | 1 | 66,027 | 13 | 132,055 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n - 1 remaining vertices has a parent in the tree. V... | instruction | 0 | 66,028 | 13 | 132,056 |
No | output | 1 | 66,028 | 13 | 132,057 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,338 | 13 | 132,676 |
"Correct Solution:
```
from collections import defaultdict
def paint(v, d, c):
if color[v] == 0:
color[v] = c
if dp[v] >= d or d == 0:
return
dp[v] = d
for nb in graph[v]:
paint(nb, d-1, c)
N, M = map(int, input().split())
dp = [0] * N
color = [0] * N
graph = defaultdict(set)
f... | output | 1 | 66,338 | 13 | 132,677 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,339 | 13 | 132,678 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
from collections import deque
N,M=map(int,input().split())
table=[[] for i in range(N)]
for i in range(M):
a,b=map(int,input().split())
a,b=a-1,b-1
table[a].append(b)
table[b].append(a)
Q=int(input())
X=[[int(i) for i in input().split()] for i... | output | 1 | 66,339 | 13 | 132,679 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,340 | 13 | 132,680 |
"Correct Solution:
```
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
a, b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
dp = [{-1: -1} for i in range(N)]
mark = {}
Q = int(input())
col = [0]*(Q+1)
col[-1] = 0
C = []
for i in range(Q):
v, d, c = map(i... | output | 1 | 66,340 | 13 | 132,681 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,341 | 13 | 132,682 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def solve():
n, m = nm()
G = [list() for _ in range(n)]
for _ in range(m):
a, b = ... | output | 1 | 66,341 | 13 | 132,683 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,342 | 13 | 132,684 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
def func(v, d, c):
if memo[v][d]!=0:
return
memo[v][d] = c
if d==0:
return
func(v, d-1, c)
for nv in G[v]:
func(nv, d-1, c)
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in... | output | 1 | 66,342 | 13 | 132,685 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,343 | 13 | 132,686 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
a -= 1
b -= 1
G[a].append(b)
G[b].append(a)
q = int(input())
vdc = [list(ma... | output | 1 | 66,343 | 13 | 132,687 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,344 | 13 | 132,688 |
"Correct Solution:
```
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
a,b=map(int,input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
Q=int(input())
v=[0 for i in range(Q)]
d=[0 for i in range(Q)]
c=[0 for i in range(Q)]
for i in range(Q):
v[-i-... | output | 1 | 66,344 | 13 | 132,689 |
Provide a correct Python 3 solution for this coding contest problem.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b... | instruction | 0 | 66,345 | 13 | 132,690 |
"Correct Solution:
```
n, m = map(int, input().split())
g = {}
used = {i:[False for _ in range(11)] for i in range(n)}
color = [0 for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u-=1
v-=1
if u not in g:
g[u] = []
if v not in g:
g[v] = []
g[u].ap... | output | 1 | 66,345 | 13 | 132,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,346 | 13 | 132,692 |
Yes | output | 1 | 66,346 | 13 | 132,693 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,347 | 13 | 132,694 |
Yes | output | 1 | 66,347 | 13 | 132,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,348 | 13 | 132,696 |
Yes | output | 1 | 66,348 | 13 | 132,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,349 | 13 | 132,698 |
Yes | output | 1 | 66,349 | 13 | 132,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,350 | 13 | 132,700 |
No | output | 1 | 66,350 | 13 | 132,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,351 | 13 | 132,702 |
No | output | 1 | 66,351 | 13 | 132,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,352 | 13 | 132,704 |
No | output | 1 | 66,352 | 13 | 132,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i... | instruction | 0 | 66,353 | 13 | 132,706 |
No | output | 1 | 66,353 | 13 | 132,707 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow on... | instruction | 0 | 66,411 | 13 | 132,822 |
"Correct Solution:
```
from collections import deque
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
x, y = map(int, input().split())
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
Q = deque([0])
T = []
while Q:
i = deque.popleft(Q)
T.append(i)
for a in X[i]:
if a ... | output | 1 | 66,411 | 13 | 132,823 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow on... | instruction | 0 | 66,412 | 13 | 132,824 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10 ** 7)
def resolve():
def dfs1(r_topo, par):
for i in reversed(r_topo):
stack = [i]
while stack:
idx = stack.pop()
for to in G[idx]:
if to == par[i]:
... | output | 1 | 66,412 | 13 | 132,825 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow on... | instruction | 0 | 66,413 | 13 | 132,826 |
"Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
x, y = map(int, input().split())
x -= 1
y -= 1
edge[x].append(y)
edge[y].append(x)
topo = []
parent = [-1] * N
node = [0]
whi... | output | 1 | 66,413 | 13 | 132,827 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow on... | instruction | 0 | 66,414 | 13 | 132,828 |
"Correct Solution:
```
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
from collections import deque
N = int(input())
#隣接リストの作成
G = [[] for _ in range(N)]
for _ in range(N - 1):
u, v = map(int, input().split())
u -= 1
v -= 1... | output | 1 | 66,414 | 13 | 132,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,572 | 13 | 133,144 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
# region fastio # from https://codeforces.com/contest/1333/submission/75948789
import sys, io, os
BUFSIZE = 8192
class FastIO(io.IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno... | output | 1 | 66,572 | 13 | 133,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,573 | 13 | 133,146 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
from collections import defaultdict, deque
import os
def get_neighbors(edges):
neighbors = defaultdict(set, {})
for v1, v2 in edges:
if v1 != v2:
neighbors[v1].add(v2)
neighbors[... | output | 1 | 66,573 | 13 | 133,147 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,574 | 13 | 133,148 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
import os
import sys
input = sys.stdin.buffer.readline
#sys.setrecursionlimit(int(3e5))
from collections import deque
from queue import PriorityQueue
import math
# list(map(int, input().split()))
######################... | output | 1 | 66,574 | 13 | 133,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,575 | 13 | 133,150 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
n = int(input())
l = [[] for _ in range(n)]
for _ in range(n-1):
p1, p2 = map(lambda x : x-1, map(int, input().split()))
l[p1].append(p2)
l[p2].append(p1)
leaf = []
e = [0] * n
maxans = n-1
for i in range(n):
temp = ... | output | 1 | 66,575 | 13 | 133,151 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,576 | 13 | 133,152 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
from collections import deque
def prog():
n = int(input())
adj_list = [[] for i in range(n+1)]
for i in range(n-1):
a,b = map(int,input().split())
... | output | 1 | 66,576 | 13 | 133,153 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,577 | 13 | 133,154 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
from sys import stdin
input = stdin.readline
class N:
def __init__(self, v) -> None:
self.v = v
self.c = set()
self.l = False
if __name__ == '__main__':
n = int(input())
arr = [N... | output | 1 | 66,577 | 13 | 133,155 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wi... | instruction | 0 | 66,578 | 13 | 133,156 |
Tags: bitmasks, constructive algorithms, dfs and similar, greedy, math, trees
Correct Solution:
```
import sys
readline = sys.stdin.readline
def parorder(Edge, p):
N = len(Edge)
par = [0]*N
par[p] = -1
stack = [p]
order = []
visited = set([p])
ast = stack.append
apo = order.append
w... | output | 1 | 66,578 | 13 | 133,157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.