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.
There is a tree with N vertices, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, so that any black vertex can be reached from any other b... | instruction | 0 | 107,692 | 13 | 215,384 |
"Correct Solution:
```
# †全方位木DP†
import sys
input = lambda : sys.stdin.readline().strip()
n,m = map(int, input().split())
mod = m
G = [[] for i in range(n)]
for i in range(n-1):
a,b = map(int, input().split())
a,b = a-1,b-1
G[a].append(b)
G[b].append(a)
from collections import deque
def dfs(root):
... | output | 1 | 107,692 | 13 | 215,385 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, so that any black vertex can be reached from any other b... | instruction | 0 | 107,693 | 13 | 215,386 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
n, MOD = map(int,input().split())
if n == 1:
print(1)
return
E = [[] for _ in range(n)]
nv_to_idx = [{} for _ in range(n... | output | 1 | 107,693 | 13 | 215,387 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,694 | 13 | 215,388 |
Yes | output | 1 | 107,694 | 13 | 215,389 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,695 | 13 | 215,390 |
Yes | output | 1 | 107,695 | 13 | 215,391 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,696 | 13 | 215,392 |
Yes | output | 1 | 107,696 | 13 | 215,393 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,697 | 13 | 215,394 |
Yes | output | 1 | 107,697 | 13 | 215,395 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,698 | 13 | 215,396 |
No | output | 1 | 107,698 | 13 | 215,397 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,699 | 13 | 215,398 |
No | output | 1 | 107,699 | 13 | 215,399 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,700 | 13 | 215,400 |
No | output | 1 | 107,700 | 13 | 215,401 |
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, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Taro has decided to paint each vertex in white or black, ... | instruction | 0 | 107,701 | 13 | 215,402 |
No | output | 1 | 107,701 | 13 | 215,403 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,734 | 13 | 215,468 |
"Correct Solution:
```
import sys
from itertools import chain
readline = sys.stdin.readline
#非再帰
def scc(Edge):
N = len(Edge)
Edgeinv = [[] for _ in range(N)]
for vn in range(N):
for vf in Edge[vn]:
Edgeinv[vf].append(vn)
used = [False]*N
dim = [len(Edge[i]) for i in range(... | output | 1 | 107,734 | 13 | 215,469 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,735 | 13 | 215,470 |
"Correct Solution:
```
from collections import deque
N=int(input())
IN=[[] for i in range(N)]
OUT=[-1 for i in range(N)]
p=list(map(int,input().split()))
for i in range(N):
IN[p[i]-1].append(i)
OUT[i]=p[i]-1
deg=[len(IN[i]) for i in range(N)]
deq=deque([v for v in range(N) if deg[v]==0])
res=[]
while deq:
... | output | 1 | 107,735 | 13 | 215,471 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,736 | 13 | 215,472 |
"Correct Solution:
```
from collections import defaultdict
import heapq as hq
def helper(n):
q = child_L[n]
del child_L[n]
hq.heapify(q)
i = 0
while q:
t = hq.heappop(q)
if i < t:
break
else:
i += (i == t)
j = i + 1
while q:
t = hq.... | output | 1 | 107,736 | 13 | 215,473 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,737 | 13 | 215,474 |
"Correct Solution:
```
# 結局は木+1辺
from collections import defaultdict
import heapq as hq
N = int(input())
P = list(map(lambda x:int(x)-1,input().split()))
D = [0]*N
for p in P:
D[p] += 1
child_L = defaultdict(list)
S = [p for p in range(N) if D[p] == 0]
L = [None]*N
while S:
n = S.pop()
q = child_L[n]
del c... | output | 1 | 107,737 | 13 | 215,475 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,738 | 13 | 215,476 |
"Correct Solution:
```
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
"""
・pseudo-tree graph
・in_deg = 1が保証されているので、向きの揃ったcycleがある
・1箇所の2択を決めれば全部決まる
"""
N = int(readline())
parent = [0] + list(map(int,read().split()))
child = [[] for _ in range(N+1)... | output | 1 | 107,738 | 13 | 215,477 |
Provide a correct Python 3 solution for this coding contest problem.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is deno... | instruction | 0 | 107,739 | 13 | 215,478 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**6)
n = int(input())
p = list(map(int, input().split()))
c = [[] for _ in range(n)]
is_leaf = [True for _ in range(n)]
for i in range(n):
p[i] -= 1
c[p[i]].append(i)
is_leaf[p[i]] = False
if sum(is_leaf) == 0:
if n%2 == 0:
print("POSSIBLE")
else:
prin... | output | 1 | 107,739 | 13 | 215,479 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly co... | instruction | 0 | 107,740 | 13 | 215,480 |
No | output | 1 | 107,740 | 13 | 215,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly co... | instruction | 0 | 107,741 | 13 | 215,482 |
No | output | 1 | 107,741 | 13 | 215,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly co... | instruction | 0 | 107,742 | 13 | 215,484 |
No | output | 1 | 107,742 | 13 | 215,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.
The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly co... | instruction | 0 | 107,743 | 13 | 215,486 |
No | output | 1 | 107,743 | 13 | 215,487 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,830 | 13 | 215,660 |
"Correct Solution:
```
class Node():
def __init__(self, id, key):
self.id = id
self.key = key
def setKeys(self, data):
length = len(data)
if ( self.id // 2 ) != 0:
self.pk = data[self.id // 2]
else :
self.pk = -1
if self.id * 2 < length:
... | output | 1 | 107,830 | 13 | 215,661 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,831 | 13 | 215,662 |
"Correct Solution:
```
H = int(input())
last_index = H + 1
keys = [None] + list(map(int, input().split()))
for i in range(1, last_index):
print('node {0}: '.format(i), end = '')
print('key = {0}, '.format(keys[i]), end = '')
if i != 1:
print('parent key = {0}, '.format(keys[i // 2]), end = '')
... | output | 1 | 107,831 | 13 | 215,663 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,832 | 13 | 215,664 |
"Correct Solution:
```
def parent_id(id, H):
if 1 <= id // 2 and id // 2 <= H:
return id// 2
return None
def left_id(id, H):
if 1 <= id *2 and id * 2 <= H:
return id* 2
return None
def right_id(id, H):
if 1 <= (id * 2) + 1 and (id * 2) + 1 <= H:
return (id * 2) + 1
ret... | output | 1 | 107,832 | 13 | 215,665 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,833 | 13 | 215,666 |
"Correct Solution:
```
N = int(input())
*A, = map(int, input().split())
for i in range(N):
R = ["node %d: key = %d," % (i+1, A[i])]
l = 2*i+1; r = 2*i+2
if i:
R.append("parent key = %d," % A[(i-1)//2])
if l < N:
R.append("left key = %d," % A[l])
if r < N:
R.append("right key ... | output | 1 | 107,833 | 13 | 215,667 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,834 | 13 | 215,668 |
"Correct Solution:
```
from math import ceil
N = int(input())
H = list(map(int, input().split()))
for i in range(len(H)):
res = "node {}: key = {}, ".format(i+1, H[i])
parent = ceil(i/2) - 1
left = 2*i + 1
right = 2*i + 2
if parent >= 0:
res += "parent key = {}, ".format(H[parent])
if left < N:
re... | output | 1 | 107,834 | 13 | 215,669 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,835 | 13 | 215,670 |
"Correct Solution:
```
#! /usr/bin/env python
def print_heap (heap, i):
ret = "node {0}: key = {1}, ".format(i + 1, heap[i])
p = get_parent_node(i)
if p is not None:
ret += "parent key = {0}, ".format(heap[p])
len_heap = len(heap)
l = get_left_node(i)
r = get_right_node(i)
if l ... | output | 1 | 107,835 | 13 | 215,671 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,836 | 13 | 215,672 |
"Correct Solution:
```
if __name__ == '__main__':
N = input()
heap_array = [int(i) for i in input().split()]
for i in range(len(heap_array)):
print("node {}: key = {}, ".format(i+1, heap_array[i]), end='')
if (i-1)//2 != -1 :
print("parent key = {}, ".format(heap_array[(i-1)//2]... | output | 1 | 107,836 | 13 | 215,673 |
Provide a correct Python 3 solution for this coding contest problem.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all nodes (leaves) are pushed across to the left, is also (nea... | instruction | 0 | 107,837 | 13 | 215,674 |
"Correct Solution:
```
def main():
""" ????????? """
H = int(input().strip())
hkeys = list(map(int,(input().split())))
for i in range(H):
txts = []
id = i + 1
txts.append("node {}: key = {},".format(id, hkeys[i]))
parent = int(id / 2)
if parent != 0:
... | output | 1 | 107,837 | 13 | 215,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,838 | 13 | 215,676 |
Yes | output | 1 | 107,838 | 13 | 215,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,839 | 13 | 215,678 |
Yes | output | 1 | 107,839 | 13 | 215,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,840 | 13 | 215,680 |
Yes | output | 1 | 107,840 | 13 | 215,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,841 | 13 | 215,682 |
Yes | output | 1 | 107,841 | 13 | 215,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,842 | 13 | 215,684 |
No | output | 1 | 107,842 | 13 | 215,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,843 | 13 | 215,686 |
No | output | 1 | 107,843 | 13 | 215,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,844 | 13 | 215,688 |
No | output | 1 | 107,844 | 13 | 215,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A complete binary tree is a binary tree in which every internal node has two children and all leaves have the same depth. A binary tree in which if last level is not completely filled but all no... | instruction | 0 | 107,845 | 13 | 215,690 |
No | output | 1 | 107,845 | 13 | 215,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,986 | 13 | 215,972 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
mod = 1000000007
eps = 10**-9
def main():
import sys
from collections import deque
input = sys.stdin.buffer.readline
N = int(input())
A = [10**10]
BC = [0]
for _ in range(N):
a, b, c = map(int, input().split())
... | output | 1 | 107,986 | 13 | 215,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,987 | 13 | 215,974 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
from types import GeneratorType
def bootstrap(func, stack=[]):
def wrapped_function(*args, **kwargs):
if stack:
return func(*args, **kwargs)
else:
call = func(*args, **kwargs)
while True:
... | output | 1 | 107,987 | 13 | 215,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,988 | 13 | 215,976 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
n = int(input())
cbc = [list(map(int,input().split())) for i in range(n)]
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
if n == 1:
if cbc[0][1] != cbc[0][2]:
print(-1)
... | output | 1 | 107,988 | 13 | 215,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,989 | 13 | 215,978 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
# from math import factorial as fac
from collections import defaultdict
# from copy import deepcopy
import sys, math
f = None
try:
f = open('q1.input', 'r')
except IOError:
f = sys.stdin
if 'xrange' in dir(__builtins__):
range = xrange
# print(f.readli... | output | 1 | 107,989 | 13 | 215,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,990 | 13 | 215,980 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
data = [list(map(int, line.rstrip().split())) for line in sys.stdin.readlines()]
n = data[0][0]
dic = [[] for _ in range(n+1)]
dic[1].append(0)
for u,v in data[n+1:]:
dic[u].append(v)
dic[v].append(u)
cost = [0]*(n+1)
cost[1] = 100000000... | output | 1 | 107,990 | 13 | 215,981 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,991 | 13 | 215,982 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
from collections import deque
N = int(sys.stdin.readline())
A, B, C = [], [], []
bd, cd = 0, 0
for i in range(N):
a, b, c = [int(_) for _ in sys.stdin.readline().split()]
A.append(a)
B.append(b)
C.append(c)
if b == 0 and c =... | output | 1 | 107,991 | 13 | 215,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,992 | 13 | 215,984 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
import math
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input().strip()
return(list(s[:len(s)])... | output | 1 | 107,992 | 13 | 215,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,993 | 13 | 215,986 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
import sys
def main(x):
for i in v[x]:
d[i-1][-1] = min(d[x-1][-1], d[i-1][-1])
def main2(x):
for i in v[x]:
d[x-1][0] += d[i-1][0]
d[x-1][1] += d[i-1][1]
d[x-1][2] += d[i-1][2]
delta = min(d[x-1][0], d[x-1][1])... | output | 1 | 107,993 | 13 | 215,987 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve thi... | instruction | 0 | 107,994 | 13 | 215,988 |
Tags: dfs and similar, dp, greedy, trees
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
return map(int,raw_in... | output | 1 | 107,994 | 13 | 215,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i writt... | instruction | 0 | 107,995 | 13 | 215,990 |
Yes | output | 1 | 107,995 | 13 | 215,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i writt... | instruction | 0 | 107,996 | 13 | 215,992 |
Yes | output | 1 | 107,996 | 13 | 215,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i writt... | instruction | 0 | 107,997 | 13 | 215,994 |
Yes | output | 1 | 107,997 | 13 | 215,995 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i writt... | instruction | 0 | 107,998 | 13 | 215,996 |
Yes | output | 1 | 107,998 | 13 | 215,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i writt... | instruction | 0 | 107,999 | 13 | 215,998 |
No | output | 1 | 107,999 | 13 | 215,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.