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 |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of ve... | instruction | 0 | 95,860 | 13 | 191,720 |
"Correct Solution:
```
n = int(input())
al = list(map(int, input().split()))
bl = [0]*(n+1)
acc = [0]*(n+2)
for i in range(n+1):
acc[i+1] = al[i]+acc[i]
res = 0
for d in range(n+1):
if d==0:
res += 1
bl[0] = 1 - al[0]
else:
r1 = 2*bl[d-1] - al[d]
r2 = acc[-1] - acc[d+1]
... | output | 1 | 95,860 | 13 | 191,721 |
Provide a correct Python 3 solution for this coding contest problem.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of ve... | instruction | 0 | 95,861 | 13 | 191,722 |
"Correct Solution:
```
N = int(input())
A = list(map(int, input().split()))
b = [0] * (N+1)
b[0] = 1
flag = True
for i in range(N):
if A[i] > b[i]:
flag = False
b[i+1] = (b[i] - A[i]) * 2
if A[N] > b[N]:
flag = False
ans = 0
l = 0
for i in range(N, -1, -1):
l += A[i]
ans += min(l, b[i])
... | output | 1 | 95,861 | 13 | 191,723 |
Provide a correct Python 3 solution for this coding contest problem.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of ve... | instruction | 0 | 95,862 | 13 | 191,724 |
"Correct Solution:
```
N = int(input())
A = list(map(int, input().split()))
isOK = True
B = [0]*(N+1)
B[0] = 1-A[0]
M = 1
i = 1
while i <= N:
B[i] = B[i-1]*2-A[i]
i += 1
if B[-1] < 0 or N > 0 and A[-1] == 0:
isOK = False
B[-1] = A[-1]
i = N-1
while i >= 0:
if B[i] < 1 or i > 0 and B[i] > B[i-1]*2:
isOK = Fa... | output | 1 | 95,862 | 13 | 191,725 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,863 | 13 | 191,726 |
Yes | output | 1 | 95,863 | 13 | 191,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,864 | 13 | 191,728 |
Yes | output | 1 | 95,864 | 13 | 191,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,865 | 13 | 191,730 |
Yes | output | 1 | 95,865 | 13 | 191,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,866 | 13 | 191,732 |
Yes | output | 1 | 95,866 | 13 | 191,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,867 | 13 | 191,734 |
No | output | 1 | 95,867 | 13 | 191,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,868 | 13 | 191,736 |
No | output | 1 | 95,868 | 13 | 191,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,869 | 13 | 191,738 |
No | output | 1 | 95,869 | 13 | 191,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If suc... | instruction | 0 | 95,870 | 13 | 191,740 |
No | output | 1 | 95,870 | 13 | 191,741 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,871 | 13 | 191,742 |
"Correct Solution:
```
from collections import defaultdict
from heapq import heappop, heappush
class Graph(object):
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return len(self.graph)
def add_edge(self, From, To, cost=1):
self.graph[From].append((To,cost... | output | 1 | 95,871 | 13 | 191,743 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,872 | 13 | 191,744 |
"Correct Solution:
```
def resolve():
def dfs(u, v, parent):
if u == v:
return True
for (to, idx) in G[u]:
if to == parent:
continue
if dfs(to, v, u):
path.append(idx)
return True
return False
N = int(... | output | 1 | 95,872 | 13 | 191,745 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,873 | 13 | 191,746 |
"Correct Solution:
```
N = int(input())
from collections import defaultdict
G = defaultdict(list)
EdaNum = {}
Ki = [[float('inf')]*(N+1) for i in range(N+1)]
for i in range(N-1):
a,b = map(int,input().split())
G[a].append(b)
G[b].append(a)
EdaNum[(min(a,b),max(a,b))] = i
Ki[a][b] = 1
Ki[b][a] = ... | output | 1 | 95,873 | 13 | 191,747 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,874 | 13 | 191,748 |
"Correct Solution:
```
n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
m = int(input())
path = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]
memo = {}
for i in range(n - 1):
a, b = info[i]
a -= 1
b -= 1
tree[a].append(b)
tree[b].ap... | output | 1 | 95,874 | 13 | 191,749 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,875 | 13 | 191,750 |
"Correct Solution:
```
def popcount(x):
x = x - ((x >> 1) & 0x5555555555555555)
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
x = x + (x >> 8)
x = x + (x >> 16)
x = x + (x >> 32)
return x & 0x0000007f
def main():
import sys
... | output | 1 | 95,875 | 13 | 191,751 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,876 | 13 | 191,752 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**7)
def main(n,ki,uv):
# n: 頂点数
# ki: 木
# Euler Tour の構築
S=[] # Euler Tour
F=[0]*n # F[v]:vにはじめて訪れるステップ
depth=[0]*n # 0を根としたときの深さ
def dfs(v,pare,d):
F[v]=len(S)
depth[v]=d
S.append(v)
for i,w in ki[v]:
if w==pare:continue
... | output | 1 | 95,876 | 13 | 191,753 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,877 | 13 | 191,754 |
"Correct Solution:
```
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
a, b = map(int, input().split())
E[a-1].append(b-1)
E[b-1].append(a-1)
parent = [None]*N
depth = [0]*N
d = 0
queue = [0]
while queue:
d += 1
queue_new = []
for q in queue:
for e in E[q]:
... | output | 1 | 95,877 | 13 | 191,755 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of t... | instruction | 0 | 95,878 | 13 | 191,756 |
"Correct Solution:
```
N = int(input())
ab = [tuple(map(int,input().split())) for _ in range(N - 1)]
M = int(input())
uv = [tuple(map(int,input().split())) for _ in range(M)]
route = [[] for _ in range(N)]
for i, (a, b) in enumerate(ab):
a -= 1
b -= 1
route[a].append((b, i))
route[b].append((a, i))
pa... | output | 1 | 95,878 | 13 | 191,757 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,879 | 13 | 191,758 |
Yes | output | 1 | 95,879 | 13 | 191,759 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,880 | 13 | 191,760 |
Yes | output | 1 | 95,880 | 13 | 191,761 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,881 | 13 | 191,762 |
Yes | output | 1 | 95,881 | 13 | 191,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,882 | 13 | 191,764 |
Yes | output | 1 | 95,882 | 13 | 191,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,883 | 13 | 191,766 |
No | output | 1 | 95,883 | 13 | 191,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,884 | 13 | 191,768 |
No | output | 1 | 95,884 | 13 | 191,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,885 | 13 | 191,770 |
No | output | 1 | 95,885 | 13 | 191,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways t... | instruction | 0 | 95,886 | 13 | 191,772 |
No | output | 1 | 95,886 | 13 | 191,773 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B` ... | instruction | 0 | 95,925 | 13 | 191,850 |
"Correct Solution:
```
"""
https://atcoder.jp/contests/arc097/tasks/arc097_d
始点と終点関係ある?
→逆にしても問題はない
黒い葉は完全に無視できる(落とせる)
よって、葉はすべて白
葉以外は白黒どっちもあり得る
すべての葉をめぐる最短経路?
ある葉からスタートするのは自明っぽい?
ある白からスタートするのはそう
→自分を塗ってからdfsする
→全方位木dp?
行きのみで帰らない場所が1つ存在するはず
→始点と終点のパスとそこから生える木って感じのイメージ
足踏み(停止)の回数を極力少なくしたい
→始点でも終点でもない場合、 e本の辺がつなが... | output | 1 | 95,925 | 13 | 191,851 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B` ... | instruction | 0 | 95,926 | 13 | 191,852 |
"Correct Solution:
```
from collections import deque
def first_cut(links, colors):
tmp_links = links.copy()
for v, neighbors in tmp_links.items():
while len(neighbors) == 1 and colors[v]:
del links[v]
par = neighbors.pop()
links[par].remove(v)
v = par
... | output | 1 | 95,926 | 13 | 191,853 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B` ... | instruction | 0 | 95,927 | 13 | 191,854 |
"Correct Solution:
```
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
data = read().split()
m = map(int,data[:-1])
XY = zip(m,m)
C = [0] + [1 * (x == ord('W')) for x in data[-1]]
graph = [set() for _ in range(N+1)]
for x,y in XY:... | output | 1 | 95,927 | 13 | 191,855 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B` ... | instruction | 0 | 95,928 | 13 | 191,856 |
"Correct Solution:
```
import sys
from collections import deque
input=sys.stdin.readline
N=int(input())
edge=[[] for i in range(N)]
for i in range(N-1):
x,y=map(int,input().split())
edge[x-1].append(y-1)
edge[y-1].append(x-1)
c=input()[:N]
deg=[len(edge[i]) for i in range(N)]
leaf=set([])
for i in range... | output | 1 | 95,928 | 13 | 191,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c... | instruction | 0 | 95,929 | 13 | 191,858 |
No | output | 1 | 95,929 | 13 | 191,859 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c... | instruction | 0 | 95,930 | 13 | 191,860 |
No | output | 1 | 95,930 | 13 | 191,861 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c... | instruction | 0 | 95,931 | 13 | 191,862 |
No | output | 1 | 95,931 | 13 | 191,863 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c... | instruction | 0 | 95,932 | 13 | 191,864 |
No | output | 1 | 95,932 | 13 | 191,865 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,308 | 13 | 192,616 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
# begin FastIntegerInput;
import sys
_ord, inp, num, neg, _Index = lambda x: x, [], 0, False, 0
i, s = 0, sys.stdin.buffer.read()
try:
while True:
if s[i] >= b"0"[0]:num = 10 * num + _ord(s[i]) - 48... | output | 1 | 96,308 | 13 | 192,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,309 | 13 | 192,618 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7
t = int(input())
for _ in range(t):
n = int(input())
adj_lis = []
adj_cnt = []
for _ in range(n):
adj_lis.append([])
adj_... | output | 1 | 96,309 | 13 | 192,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,310 | 13 | 192,620 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
import sys
input=sys.stdin.buffer.readline
inin=lambda: int(input())
inar=lambda: list(map(int,input().split()))
inst=lambda: input().decode().rstrip('\n\r')
#INF=float('inf'); from math import gcd
#from colle... | output | 1 | 96,310 | 13 | 192,621 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,311 | 13 | 192,622 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
from collections import defaultdict
import sys
from types import GeneratorType
MOD = (10 ** 9) + 7
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*ar... | output | 1 | 96,311 | 13 | 192,623 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,312 | 13 | 192,624 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
tests = int(input())
for t in range(tests):
n = int(input())
node_dict = {}
for _ in range(n-1):
u, v = list(map(int, input().split()))
if u in node_dict:
node_dict[u][0]... | output | 1 | 96,312 | 13 | 192,625 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,313 | 13 | 192,626 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as b... | output | 1 | 96,313 | 13 | 192,627 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,314 | 13 | 192,628 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
import sys
import threading
from sys import stdin, stdout
sys.setrecursionlimit(10**9)
threading.stack_size(16*2048*2048)
def maximum_distributed_tree(n, uv_dic, p_a, edg):
MOD = 10**9 + 7
dfs(n, uv_... | output | 1 | 96,314 | 13 | 192,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than 0;
* the product of all n-1 numbers should ... | instruction | 0 | 96,315 | 13 | 192,630 |
Tags: dfs and similar, dp, greedy, implementation, math, number theory, sortings, trees
Correct Solution:
```
#!/usr/bin/env python3
import sys
import collections
input=sys.stdin.readline
mod=10**9+7
t=int(input())
for _ in range(t):
n=int(input())
g=[[] for _ in range(n+1)]
for _ in range(n-1):
... | output | 1 | 96,315 | 13 | 192,631 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,316 | 13 | 192,632 |
Yes | output | 1 | 96,316 | 13 | 192,633 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,317 | 13 | 192,634 |
Yes | output | 1 | 96,317 | 13 | 192,635 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,318 | 13 | 192,636 |
Yes | output | 1 | 96,318 | 13 | 192,637 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,319 | 13 | 192,638 |
Yes | output | 1 | 96,319 | 13 | 192,639 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,320 | 13 | 192,640 |
No | output | 1 | 96,320 | 13 | 192,641 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,321 | 13 | 192,642 |
No | output | 1 | 96,321 | 13 | 192,643 |
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 that consists of n nodes. You should label each of its n-1 edges with an integer in such way that satisfies the following conditions:
* each integer must be greater than... | instruction | 0 | 96,322 | 13 | 192,644 |
No | output | 1 | 96,322 | 13 | 192,645 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.