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. This is an interactive problem. You're given a tree consisting of n nodes, rooted at node 1. A tree is a connected graph with no cycles. We chose a hidden node x. In order to find this node, y...
instruction
0
48,009
13
96,018
No
output
1
48,009
13
96,019
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,135
13
96,270
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` import sys input = sys.stdin.readline n, m = map(int, input().split()) same, both = 0, 0 edges = {} for _ in range(m): x = input().split() if x[0] == '+': k, i, j, c = x edges[i, j] = c if (j, i) in ed...
output
1
48,135
13
96,271
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,136
13
96,272
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` from bisect import * from collections import * from math import gcd,ceil,sqrt,floor,inf from heapq import * from itertools import * from operator import add,mul,sub,xor,truediv,floordiv from functools import * #---------------------...
output
1
48,136
13
96,273
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,137
13
96,274
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` n, m = map(int,input().split()) rev, same = 0, 0 now = {} a = [set() for _ in range(n+1)] for i in range(m): b = input().split() x = b[0] if x == '+': u, v, w = int(b[1]), int(b[2]), b[3] a[u].add(v) ...
output
1
48,137
13
96,275
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,138
13
96,276
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` """ #If FastIO not needed, use this and don't forget to strip #import sys, math #input = sys.stdin.readline """ import os, sys, heapq as h, time from io import BytesIO, IOBase from types import GeneratorType from bisect import bisect...
output
1
48,138
13
96,277
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,139
13
96,278
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` import sys n, m = map(int, sys.stdin.readline().split()) D = {} edges2 = set() edges1 = set() for i in range(m): s, *A = sys.stdin.readline().split() if s == '+': u, v, c = int(A[0]), int(A[1]), A[2] D[(u, v)]...
output
1
48,139
13
96,279
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,140
13
96,280
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` """ #If FastIO not needed, use this and don't forget to strip #import sys, math #input = sys.stdin.readline """ import os, sys, heapq as h, time from io import BytesIO, IOBase from types import GeneratorType from bisect import bisect...
output
1
48,140
13
96,281
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,141
13
96,282
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` import sys input = sys.stdin.readline n, m = map(int, input().split()) bothpathnum = 0 equalpathnum = 0 edge = dict() ans = [] for querynum in range(m): inpstr = input() if inpstr[0] == '+': u, v, c = inpstr[2:]....
output
1
48,141
13
96,283
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each query is one of three types: * "+ u v c" — a...
instruction
0
48,142
13
96,284
Tags: constructive algorithms, data structures, graphs, hashing Correct Solution: ``` """ #If FastIO not needed, use this and don't forget to strip #import sys, math #input = sys.stdin.readline """ import os, sys from io import BytesIO, IOBase from collections import defaultdict as dd import math, string BUFSIZE = 819...
output
1
48,142
13
96,285
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,143
13
96,286
Yes
output
1
48,143
13
96,287
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,144
13
96,288
Yes
output
1
48,144
13
96,289
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,145
13
96,290
Yes
output
1
48,145
13
96,291
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,146
13
96,292
Yes
output
1
48,146
13
96,293
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,147
13
96,294
No
output
1
48,147
13
96,295
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,148
13
96,296
No
output
1
48,148
13
96,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,149
13
96,298
No
output
1
48,149
13
96,299
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty. You should process m queries with it. Each q...
instruction
0
48,150
13
96,300
No
output
1
48,150
13
96,301
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,283
13
96,566
Tags: dfs and similar, trees Correct Solution: ``` import sys lines = sys.stdin.readlines() n = int(lines[0].strip()) edges = {} for i in range(1,n): (u, v) = map(int, lines[i].strip().split(" ")) if u not in edges: edges[u] = [] if v not in edges: edges[v] = [] edges[u].append(v) edges[v].append(u)...
output
1
48,283
13
96,567
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,284
13
96,568
Tags: dfs and similar, trees Correct Solution: ``` n = int(input()) p = [[] for i in range(n + 1)] for i in range(n - 1): a, b = map(int, input().split()) p[a].append(b) p[b].append(a) u, v = ' ' + input()[:: 2], ' ' + input()[:: 2] s, q = [(1, 0, 0, 0)], [] while s: a, k, i, j = s.pop() if k: ...
output
1
48,284
13
96,569
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,285
13
96,570
Tags: dfs and similar, trees Correct Solution: ``` # Made By Mostafa_Khaled bot = True n = int(input()) p = [[] for i in range(n + 1)] for i in range(n - 1): a, b = map(int, input().split()) p[a].append(b) p[b].append(a) u, v = ' ' + input()[:: 2], ' ' + input()[:: 2] s, q = [(1, 0, 0, 0)], [] whi...
output
1
48,285
13
96,571
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,286
13
96,572
Tags: dfs and similar, trees Correct Solution: ``` from collections import defaultdict, deque from typing import Any, List, Tuple def solve( n: int, adj: List[List[int]], init: List[int], goal: List[int] ) -> List[int]: g = defaultdict(list) # type: Any for u, v in adj: g[u].append(v...
output
1
48,286
13
96,573
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,287
13
96,574
Tags: dfs and similar, trees Correct Solution: ``` #Getting out of comfort zone is the first step of revolution import sys import threading for test in range(1): n = int(input()) global adj adj = list([] for i in range(n+1)) for i in range(n-1): a,b = map(int,input().split()) adj[a].app...
output
1
48,287
13
96,575
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,288
13
96,576
Tags: dfs and similar, trees Correct Solution: ``` n=int(input()) L=[[] for i in range(n)] for i in range(n-1) : a,b=map(int,input().split()) L[a-1].append(b-1) L[b-1].append(a-1) l=list(map(int,input().split())) l1=list(map(int,input().split())) W=[] for i in range(n) : W.append(abs(l[i]-l1[i])) was=[0...
output
1
48,288
13
96,577
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,289
13
96,578
Tags: dfs and similar, trees Correct Solution: ``` # 429A __author__ = 'artyom' def read_int(): return int(input()) def read_int_ary(): return map(int, input().split()) n = read_int() g = [[] for x in range(n + 1)] for i in range(n - 1): u, v = read_int_ary() g[u].append(v) g[v].append(u) init = [0] ...
output
1
48,289
13
96,579
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees. The game is played on a tree havin...
instruction
0
48,290
13
96,580
Tags: dfs and similar, trees Correct Solution: ``` import sys import math from collections import defaultdict MAXNUM = math.inf MINNUM = -1 * math.inf ASCIILOWER = 97 ASCIIUPPER = 65 def getInt(): return int(sys.stdin.readline().rstrip()) def getInts(): return map(int, sys.stdin.readline().rstrip().split("...
output
1
48,290
13
96,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses...
instruction
0
48,292
13
96,584
Yes
output
1
48,292
13
96,585
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,783
13
97,566
"Correct Solution: ``` # -*- coding: utf-8 -*- import random import sys import os class Tree: def __init__(self): self.root = None def __str__(self): if self.root == None: return None else: return "TODO" def print_inorder(self): self.inorder_list ...
output
1
48,783
13
97,567
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,784
13
97,568
"Correct Solution: ``` #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_A #???????????? 15??? 8A???????????? def insert(root, insert_node): focus_node = root parent = None while not focus_node == None: parent = focus_node if focus_node["data"] > insert_node["data"]: ...
output
1
48,784
13
97,569
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,785
13
97,570
"Correct Solution: ``` # coding: utf-8 class Node: def __init__(self, me, left, right): self.me = me self.left = left self.right = right self.parent = None class NodeTree: def __init__(self, root=None): self.root = root def insert(self,z): y = None ...
output
1
48,785
13
97,571
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,786
13
97,572
"Correct Solution: ``` class Node: def __init__(self, key): self.key = key self.right = None self.left = None class BST: root = None def insert(self, key): x = self.root y = None z = Node(key) while x != None: y = x if(z.key < y.key): x = x.left elif(y.key < ...
output
1
48,786
13
97,573
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,787
13
97,574
"Correct Solution: ``` # 二分探索 データの削除から クラス定義を用いて class Node: def __init__(self, key): self.key = key self.parent = None self.left = None self.right = None class BinarySearchTree: def __init__(self): self.root = None def insert(self, key): root_node = self.ro...
output
1
48,787
13
97,575
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,788
13
97,576
"Correct Solution: ``` import sys class Node: __slots__ = ['key', 'left', 'right'] def __init__(self, key): self.key = key self.left = self.right = None root = None def delete(target): def remove_node(p, c, a): if p.left == c: p.left = a else: p.right...
output
1
48,788
13
97,577
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,789
13
97,578
"Correct Solution: ``` import sys readline = sys.stdin.readline from copy import deepcopy, copy class Node: __slots__ = ['value', 'left', 'right'] def __init__(self, value=None): self.value = value self.left = None self.right = None class BinTree: __slots__ = ['_tree', 'result'] ...
output
1
48,789
13
97,579
Provide a correct Python 3 solution for this coding contest problem. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node contai...
instruction
0
48,790
13
97,580
"Correct Solution: ``` import sys # def input(): # return sys.stdin.readline()[:-1] # n = int(input()) # A = [input() for i in range(n)] class Node(): __slots__ = ['key', 'left', 'right','parent'] def __init__(self, key): self.key = key self.left = None self.right = None se...
output
1
48,790
13
97,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,791
13
97,582
Yes
output
1
48,791
13
97,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,792
13
97,584
Yes
output
1
48,792
13
97,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,793
13
97,586
Yes
output
1
48,793
13
97,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,794
13
97,588
Yes
output
1
48,794
13
97,589
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,795
13
97,590
No
output
1
48,795
13
97,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,796
13
97,592
No
output
1
48,796
13
97,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,797
13
97,594
No
output
1
48,797
13
97,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II. * insert $k$: Insert a node containing $k$ as key in...
instruction
0
48,798
13
97,596
No
output
1
48,798
13
97,597
Provide tags and a correct Python 3 solution for this coding contest problem. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree that exactly one vertex is a root, all leaves h...
instruction
0
48,927
13
97,854
Tags: constructive algorithms, implementation, trees Correct Solution: ``` #!/usr/bin/python3 import array import math import os import sys DEBUG = 'DEBUG' in os.environ def inp(): return sys.stdin.readline().rstrip() def dprint(*value, sep=' ', end='\n'): if DEBUG: print(*value, sep=sep, end=end...
output
1
48,927
13
97,855
Provide tags and a correct Python 3 solution for this coding contest problem. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree that exactly one vertex is a root, all leaves h...
instruction
0
48,928
13
97,856
Tags: constructive algorithms, implementation, trees Correct Solution: ``` #!/usr/bin/python3 import array import math import os import sys DEBUG = 'DEBUG' in os.environ def inp(): return sys.stdin.readline().rstrip() def dprint(*value, sep=' ', end='\n'): if DEBUG: print(*value, sep=sep, end=end...
output
1
48,928
13
97,857
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree ...
instruction
0
48,929
13
97,858
No
output
1
48,929
13
97,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree ...
instruction
0
48,930
13
97,860
No
output
1
48,930
13
97,861
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree ...
instruction
0
48,931
13
97,862
No
output
1
48,931
13
97,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have an integer n. Let's define following tree generation as McDic's generation: 1. Make a complete and full binary tree of 2^{n} - 1 vertices. Complete and full binary tree means a tree ...
instruction
0
48,932
13
97,864
No
output
1
48,932
13
97,865
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so we advise you to read both statements carefully. You are given a weighted rooted tree, vertex 1 is the root of this tree. A tree is a connected graph without cycles. A rooted tree ...
instruction
0
49,003
13
98,006
Tags: data structures, dfs and similar, greedy, trees Correct Solution: ``` """ NTC here """ #!/usr/bin/env python import os import sys from io import BytesIO, IOBase # from functools import lru_cache # sys.setrecursionlimit(10**6) # recusive with optimization from types import GeneratorType def bootstrap(f, sta...
output
1
49,003
13
98,007
Provide tags and a correct Python 3 solution for this coding contest problem. Easy and hard versions are actually different problems, so we advise you to read both statements carefully. You are given a weighted rooted tree, vertex 1 is the root of this tree. A tree is a connected graph without cycles. A rooted tree ...
instruction
0
49,004
13
98,008
Tags: data structures, dfs and similar, greedy, trees Correct Solution: ``` import sys import heapq input=sys.stdin.readline t = int(input()) for _ in range(t): n,s = list(map(int,input().split())) E = [] N = [[] for _ in range(n)] V = [] P = [-1 for _ in range(n)] E = {} for i ...
output
1
49,004
13
98,009