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.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like ... | instruction | 0 | 76,540 | 13 | 153,080 |
No | output | 1 | 76,540 | 13 | 153,081 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like ... | instruction | 0 | 76,541 | 13 | 153,082 |
No | output | 1 | 76,541 | 13 | 153,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let N be an even number.
There is a tree with N vertices. The vertices are numbered 1, 2, ..., N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i.
Snuke would like ... | instruction | 0 | 76,542 | 13 | 153,084 |
No | output | 1 | 76,542 | 13 | 153,085 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree that has n nodes and n-1 edges. There are military bases on t out of the n nodes. We want to disconnect the bases as much as possible by destroying k edges. The tree will be split into k+1 regions when we destroy k edges. Given the pu... | instruction | 0 | 76,647 | 13 | 153,294 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve(t):
N, T, K = map(int, readline().split())
if N == T == K == 0:
return False
G = [[] for i in range(N)]
E = []
res = 0
for i in range(N-1):
a, b, c = map(int, readline().split())
... | output | 1 | 76,647 | 13 | 153,295 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree that has n nodes and n-1 edges. There are military bases on t out of the n nodes. We want to disconnect the bases as much as possible by destroying k edges. The tree will be split into k+1 regions when we destroy k edges. Given the pu... | instruction | 0 | 76,648 | 13 | 153,296 |
"Correct Solution:
```
from collections import defaultdict
import heapq
case = 1
while True:
n, t, k = map(int, input().split())
if n == t == k == 0:
break
costs = [0] * 10001
# 全ての辺をまず壊して考える
E = defaultdict(list)
for i in range(n-1):
fr, to, c = map(int, input().split())
... | output | 1 | 76,648 | 13 | 153,297 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,652 | 13 | 153,304 |
"Correct Solution:
```
from collections import deque
q = deque([])
n = int(input())
G = []
for i in range(n):
u, k, *vvv = list(map(int, input().split()))
G.append([v-1 for v in vvv])
visited = [False for _ in range(n)]
q.append(0)
dist = [-1 for _ in range(n)]
dist[0] = 0
while q:
u = q.popleft()
visited[u] = ... | output | 1 | 76,652 | 13 | 153,305 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,653 | 13 | 153,306 |
"Correct Solution:
```
from collections import deque
V = int(input())
edge = [[] for _ in range(V)]
for _ in range(V):
u, _, *v = map(lambda x: int(x)-1, input().split())
edge[u] = sorted(v)
dist = [-1] * V
dist[0] = 0
que = deque([0])
while len(que):
v = que.popleft()
for c in edge[v]:
if dist... | output | 1 | 76,653 | 13 | 153,307 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,654 | 13 | 153,308 |
"Correct Solution:
```
import collections
n=int(input())
l=[]
for i in range(n):
l1=list(map(int,input().split()))
l2=[]
if l1[1]==0:
l2=["0" for j in range(n)]
else:
for j in range(n):
if j+1 in l1[2:]:
l2.append("1")
else:
l2.append("0")
l.append(l2)
D=[-1 for i in range(... | output | 1 | 76,654 | 13 | 153,309 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,655 | 13 | 153,310 |
"Correct Solution:
```
n = int(input())
adj = [list(map(int, input().split()))[2:] for _ in range(n)]
d = [-1] * n
s = 1
q = []
d[s - 1] = 0
q.append(s)
while len(q):
u = q.pop()
v = adj[u - 1]
for vi in v:
if d[vi - 1] == -1:
d[vi - 1] = d[u - 1] + 1
q.append(vi)
... | output | 1 | 76,655 | 13 | 153,311 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,656 | 13 | 153,312 |
"Correct Solution:
```
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)
def inpl():
return list(map(int, input().split()))
N = int(input())
edge = {}
for _ in range(N):
tmp = inpl()
u, k = tmp[:2]
edge[u] = tmp[2:]
d = {i: -1 for i in range(1, N ... | output | 1 | 76,656 | 13 | 153,313 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,657 | 13 | 153,314 |
"Correct Solution:
```
from collections import deque
def main():
inf = 1000000007
n = int(input())
e = [[] for _ in range(n)]
d = [inf]*n
for i in range(n):
m = list(map(int,input().split()))
for j in range(2,len(m)):
e[m[0]-1].append(m[j]-1)
d[0] = 0
dq = deq... | output | 1 | 76,657 | 13 | 153,315 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,658 | 13 | 153,316 |
"Correct Solution:
```
from collections import deque
n = int(input())
adj = [0]*n # adjacent list
d = [-1]*n # distance from the source vertex
c = ['w']*n # the 'color' of each vertex
# receiving input (the structure of the graph)
for i in range(n):
tmp = list(map( int, input().split() ) )
adj[tmp[0]-1] = li... | output | 1 | 76,658 | 13 | 153,317 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
... | instruction | 0 | 76,659 | 13 | 153,318 |
"Correct Solution:
```
from collections import deque
n = int(input())
vdata = [list(map(int,input().split())) for _ in range(n)]
d = [-1]*n
q = deque()
q.append(vdata[0])
d[0] = 0
while len(q) > 0:
node = q.popleft()
c = d[node[0]-1]
a = node[1]
for i in range(a):
b = node[i+2]-1
if d[b] == -1:
... | output | 1 | 76,659 | 13 | 153,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,660 | 13 | 153,320 |
Yes | output | 1 | 76,660 | 13 | 153,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,661 | 13 | 153,322 |
Yes | output | 1 | 76,661 | 13 | 153,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,662 | 13 | 153,324 |
Yes | output | 1 | 76,662 | 13 | 153,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,663 | 13 | 153,326 |
Yes | output | 1 | 76,663 | 13 | 153,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,664 | 13 | 153,328 |
No | output | 1 | 76,664 | 13 | 153,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,665 | 13 | 153,330 |
No | output | 1 | 76,665 | 13 | 153,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,666 | 13 | 153,332 |
No | output | 1 | 76,666 | 13 | 153,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by ... | instruction | 0 | 76,667 | 13 | 153,334 |
No | output | 1 | 76,667 | 13 | 153,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,816 | 13 | 153,632 |
Tags: bitmasks, math, number theory
Correct Solution:
```
N = int(input())
*B, = map(int, input().split())
C = [0]*64
L = [[] for i in range(64)]
for b in B:
l = (b & -b).bit_length()
C[l] += 1
L[l].append(b)
i = C.index(max(C))
R = [b for b in B if (b & -b).bit_length() != i]
print(len(R))
if R:
print(... | output | 1 | 76,816 | 13 | 153,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,817 | 13 | 153,634 |
Tags: bitmasks, math, number theory
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
ans=[0]*65
bans=[0]*n
for i in range(n):
b=l[i]
score=0
while b%2==0:
b//=2
score+=1
ans[score]+=1
bans[i]=score
k=max(ans)
ind=ans.index(k)
print(n-k)
ta=[l[i] for i in range(n... | output | 1 | 76,817 | 13 | 153,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,818 | 13 | 153,636 |
Tags: bitmasks, math, number theory
Correct Solution:
```
from collections import Counter
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
def divide_count(n, p):
cnt = 0
val = p
while n % p == 0:
n //= p
cnt += 1
return cnt
for i in range(n):
a[i]=divide_count(b[i],2)
A=... | output | 1 | 76,818 | 13 | 153,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,819 | 13 | 153,638 |
Tags: bitmasks, math, number theory
Correct Solution:
```
import sys
input=sys.stdin.readline
n=int(input())
b=list(map(int,input().split()))
p=[[] for i in range(61)]
for i in range(n):
c=b[i]
cnt=0
while c%2==0:
cnt+=1
c//=2
p[cnt].append(b[i])
max_l=0
ans=[]
for i in range(61):
if... | output | 1 | 76,819 | 13 | 153,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,820 | 13 | 153,640 |
Tags: bitmasks, math, number theory
Correct Solution:
```
n = int(input())
a = list(map(int, input().split()))
count = [0] * 100
b = [0] * 200005
for i, v in enumerate(a):
tot = 0
while v % 2 == 0:
v //= 2
tot += 1
count[tot] += 1
b[i] = tot
m = max(count)
idx = count.index(m)
print(n-m... | output | 1 | 76,820 | 13 | 153,641 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,821 | 13 | 153,642 |
Tags: bitmasks, math, number theory
Correct Solution:
```
n = int(input())
b = list(map(int, input().split()))
pwr2 = [0] * n
cnt = [0] * 64
for i in range(n):
x = b[i]
while x & 1 == 0:
x >>= 1
pwr2[i] += 1
cnt[pwr2[i]] += 1
ind = 0
for i in range(64):
if cnt[ind] < cnt[i]:
ind ... | output | 1 | 76,821 | 13 | 153,643 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,822 | 13 | 153,644 |
Tags: bitmasks, math, number theory
Correct Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
B=list(map(int,input().split()))
ANS=[0]*65
BANS=[0]*n
for i in range(n):
b=B[i]
score=0
while b%2==0:
b//=2
score+=1
ANS[score]+=1
BANS[i]=score
k=max(ANS)
ind=ANS.ind... | output | 1 | 76,822 | 13 | 153,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was almost upset, but her friend Alex said, that h... | instruction | 0 | 76,823 | 13 | 153,646 |
Tags: bitmasks, math, number theory
Correct Solution:
```
n = int(input())
a = {}
b = list(map(int,input().split()))
c = []
for d in b:
m = 0
while not d%2:
d //= 2
m += 1
a[m] = a.get(m,0)+1
c.append(m)
m = max(a.values())
print(n-m)
for i in a.keys():
if a[i] == m:
x = i
fo... | output | 1 | 76,823 | 13 | 153,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,824 | 13 | 153,648 |
Yes | output | 1 | 76,824 | 13 | 153,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,825 | 13 | 153,650 |
Yes | output | 1 | 76,825 | 13 | 153,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,826 | 13 | 153,652 |
Yes | output | 1 | 76,826 | 13 | 153,653 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,827 | 13 | 153,654 |
Yes | output | 1 | 76,827 | 13 | 153,655 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,828 | 13 | 153,656 |
No | output | 1 | 76,828 | 13 | 153,657 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,829 | 13 | 153,658 |
No | output | 1 | 76,829 | 13 | 153,659 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,830 | 13 | 153,660 |
No | output | 1 | 76,830 | 13 | 153,661 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Boy Dima gave Julian a birthday present — set B consisting of positive integers. However, he didn't know, that Julian hates sets, but enjoys bipartite graphs more than anything else!
Julian was... | instruction | 0 | 76,831 | 13 | 153,662 |
No | output | 1 | 76,831 | 13 | 153,663 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a weighted rooted tree $T$ with the following operations:
* $add(v,w)$: add $w$ to all edges from the root to node $u$
* $getSum(u)$: report the sum of weights of all edges from the root to node $u$
The given tr... | instruction | 0 | 77,547 | 13 | 155,094 |
"Correct Solution:
```
from collections import deque
import sys
from typing import List
sys.setrecursionlimit(200000)
N = int(input())
G: List[List[int]] = [[0]] * N
for i in range(N):
k, *c = map(lambda x: int(x), input().split())
G[i] = c
H = [0] * N
prv = [None] * N
def dfs(v):
s = 1
heavy = No... | output | 1 | 77,547 | 13 | 155,095 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a weighted rooted tree $T$ with the following operations:
* $add(v,w)$: add $w$ to all edges from the root to node $u$
* $getSum(u)$: report the sum of weights of all edges from the root to node $u$
The given tr... | instruction | 0 | 77,548 | 13 | 155,096 |
"Correct Solution:
```
from collections import deque
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
write = sys.stdout.write
N = int(readline())
G = [None]*N
for i in range(N):
k, *c = map(int, readline().split())
G[i] = c
H = [0]*N
prv = [None]*N
def dfs(v):
s = 1; heavy = None; m ... | output | 1 | 77,548 | 13 | 155,097 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a weighted rooted tree $T$ with the following operations:
* $add(v,w)$: add $w$ to all edges from the root to node $u$
* $getSum(u)$: report the sum of weights of all edges from the root to node $u$
The given tr... | instruction | 0 | 77,549 | 13 | 155,098 |
"Correct Solution:
```
#!/usr/bin/env python3
# GRL_5_E: Tree - Range Query on Tree 2
# Undirected Graph
class Edge:
__slots__ = ('v', 'w')
def __init__(self, v, w):
self.v = v
self.w = w
def either(self):
return self.v
def other(self, v):
if v == self.v:
... | output | 1 | 77,549 | 13 | 155,099 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which manipulates a weighted rooted tree $T$ with the following operations:
* $add(v,w)$: add $w$ to all edges from the root to node $u$
* $getSum(u)$: report the sum of weights of all edges from the root to node $u$
The given tr... | instruction | 0 | 77,550 | 13 | 155,100 |
"Correct Solution:
```
class Tree():
def __init__(self, n, edge):
self.n = n
self.tree = [[] for _ in range(n)]
for e in edge:
self.tree[e[0] - 1].append(e[1] - 1)
self.tree[e[1] - 1].append(e[0] - 1)
def setroot(self, root):
self.root = root
self... | output | 1 | 77,550 | 13 | 155,101 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which manipulates a weighted rooted tree $T$ with the following operations:
* $add(v,w)$: add $w$ to all edges from the root to node $u$
* $getSum(u)$: report the sum of weight... | instruction | 0 | 77,551 | 13 | 155,102 |
No | output | 1 | 77,551 | 13 | 155,103 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's lab... | instruction | 0 | 77,571 | 13 | 155,142 |
Tags: dfs and similar, interactive, trees
Correct Solution:
```
import sys
from collections import deque
t=int(sys.stdin.readline())
for i in range(t):
n=int(sys.stdin.readline())#node
EDGE=[list(map(int,sys.stdin.readline().split())) for i in range(n-1)]
k1=int(sys.stdin.readline())
X=list(map(int... | output | 1 | 77,571 | 13 | 155,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's lab... | instruction | 0 | 77,572 | 13 | 155,144 |
Tags: dfs and similar, interactive, trees
Correct Solution:
```
from collections import deque
import sys
t = int(input())
for i in range(t):
n = int(input())
edge = {}
for j in range(1,n+1):
a = set()
edge[j] = a
for k in range(n-1):
a,b = map(int,input().split())
edge[a]... | output | 1 | 77,572 | 13 | 155,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you know the other's lab... | instruction | 0 | 77,573 | 13 | 155,146 |
Tags: dfs and similar, interactive, trees
Correct Solution:
```
import sys
def ask(u, t):
if t == 0:
print('A', u)
else:
print('B', u)
sys.stdout.flush()
return int(input())
def solve():
n = int(input())
e = [[] for _ in range(n + 1)]
p = [0] * (n + 1)
inA = [False] * (... | output | 1 | 77,573 | 13 | 155,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices f... | instruction | 0 | 77,574 | 13 | 155,148 |
No | output | 1 | 77,574 | 13 | 155,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are ca... | instruction | 0 | 77,673 | 13 | 155,346 |
Tags: data structures, dfs and similar, shortest paths, trees
Correct Solution:
```
from sys import stdin, stdout
import math
graph = []
lca = []
depth = []
lim = 0
def build_lca(cur, p):
global lca
global depth
global lim
global graph
stack = []
stack.append((cur,p))
while stack:
... | output | 1 | 77,673 | 13 | 155,347 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are ca... | instruction | 0 | 77,674 | 13 | 155,348 |
Tags: data structures, dfs and similar, shortest paths, trees
Correct Solution:
```
import sys
input = sys.stdin.readline
N = int(input())
G = [set() for _ in range(N+1)]
for _ in range(N-1):
a, b = map(int, input().split())
G[a].add(b)
G[b].add(a)
S = [1]+[None]*(2*N-2)
F = [None, 0] + [None]*(N-1)
stack ... | output | 1 | 77,674 | 13 | 155,349 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are ca... | instruction | 0 | 77,675 | 13 | 155,350 |
Tags: data structures, dfs and similar, shortest paths, trees
Correct Solution:
```
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict... | output | 1 | 77,675 | 13 | 155,351 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?
Then he found that such tree-like graphs are ca... | instruction | 0 | 77,676 | 13 | 155,352 |
Tags: data structures, dfs and similar, shortest paths, trees
Correct Solution:
```
import sys
x = 150000
sys.setrecursionlimit(x)
def go():
n = int(input())
e = {i: set() for i in range(n)}
for i in range(n - 1):
a, b = map(lambda s: int(s) - 1, input().split())
e[a].add(b)
e[b].ad... | output | 1 | 77,676 | 13 | 155,353 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.