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.
You are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.
Graph is given as the array f0, f1, ..., fn... | instruction | 0 | 77,927 | 13 | 155,854 |
No | output | 1 | 77,927 | 13 | 155,855 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,031 | 13 | 156,062 |
"Correct Solution:
```
from collections import deque
n,u,v=map(int,input().split())
graph=[[] for i in range(n)]
for i in range(n-1):
a,b=map(int,input().split())
a-=1;b-=1
graph[a].append(b)
graph[b].append(a)
Q=deque([v-1])
Vert=[[0,0] for i in range(n)]
visited=[False]*n
visited[v-1]=True
while Q:
V=Q.popl... | output | 1 | 78,031 | 13 | 156,063 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,032 | 13 | 156,064 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(200000)
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]
for i in range(n-1):
a, b = map(int, input().split())
edge[a].append(b)
edge[b].append(a)
def tdfs(x, last = -1)... | output | 1 | 78,032 | 13 | 156,065 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,033 | 13 | 156,066 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**7)
N, u, v = map(int, input().split())
u -= 1
v -= 1
graph = [[] for _ in range(N)]
for i in range(N-1):
a, b = map(int, input().split())
a -= 1
b -= 1
graph[a].append(b)
graph[b].append(a)
dist = []
def dfs(v, depth=0, parent=-1):
... | output | 1 | 78,033 | 13 | 156,067 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,034 | 13 | 156,068 |
"Correct Solution:
```
from collections import deque
N,u,v=map(int,input().split())
u-=1
v-=1
L=[list() for _ in range(N)]
for _ in range(N-1):
a,b=map(int,input().split())
a-=1
b-=1
L[a].append(b)
L[b].append(a)
q=deque([(v,0)])
T=[-1]*N
A=[-1]*N
while q:
p,x=q.pop()
A[p]=x
for to i... | output | 1 | 78,034 | 13 | 156,069 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,035 | 13 | 156,070 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
# 再帰上限を引き上げる
sys.setrecursionlimit(10**6)
# G:graph, cr:current node, seen:is seen?, dist:out;each distance
def dfs(G,cr,seen,dist):
seen[cr] = 1
for i in G[cr]: #G[cr]から行ける各頂点へ
if seen[i] == 0: #まだ通っていなかったら
dist[i] = dist[cr]+1
dfs(G,i,seen,dist)... | output | 1 | 78,035 | 13 | 156,071 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,036 | 13 | 156,072 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**5)
N,u,v=map(int,input().split())
du,dv=[0]*-~N,[0]*-~N
T=[list() for i in range(-~N)]
def dfs(p,t,v,d):
d[v]=t
for i in T[v]:
if i!=p:
dfs(v,t+1,i,d)
for i in range(N-1):
a,b=map(int,input().split())
T[a].append(b)
T[b].append(a)
dfs(0... | output | 1 | 78,036 | 13 | 156,073 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,037 | 13 | 156,074 |
"Correct Solution:
```
from collections import deque
n, u, v = map(int,input().split())
tree = [[] for _ in range(n+1)]
for _i in range(n-1):
a, b = map(int, input().split())
tree[a].append(b)
tree[b].append(a)
def solve(x):
visit = [-1 for _ in range(n+1)]
visit[x] = 0
q = deque([x])
whil... | output | 1 | 78,037 | 13 | 156,075 |
Provide a correct Python 3 solution for this coding contest problem.
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of tag as follows:
* 1. If Takahashi and Aoki are standing a... | instruction | 0 | 78,038 | 13 | 156,076 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**9)
f=lambda:map(int,input().split())
n,st,sa=f()
st-=1
sa-=1
g=[[] for _ in range(n)]
for _ in range(n-1):
a,b=f()
g[a-1].append(b-1)
g[b-1].append(a-1)
def dfs(v,p=-1,d=0):
l[v]=d
for c in g[v]:
if c==p: continue
dfs(c,v,d+1)
def dist(s):
... | output | 1 | 78,038 | 13 | 156,077 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,039 | 13 | 156,078 |
Yes | output | 1 | 78,039 | 13 | 156,079 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,040 | 13 | 156,080 |
Yes | output | 1 | 78,040 | 13 | 156,081 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,041 | 13 | 156,082 |
Yes | output | 1 | 78,041 | 13 | 156,083 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,042 | 13 | 156,084 |
Yes | output | 1 | 78,042 | 13 | 156,085 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,043 | 13 | 156,086 |
No | output | 1 | 78,043 | 13 | 156,087 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,044 | 13 | 156,088 |
No | output | 1 | 78,044 | 13 | 156,089 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,045 | 13 | 156,090 |
No | output | 1 | 78,045 | 13 | 156,091 |
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. The i-th edge connects Vertex A_i and B_i bidirectionally.
Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
Now, they will play a game of ta... | instruction | 0 | 78,046 | 13 | 156,092 |
No | output | 1 | 78,046 | 13 | 156,093 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,263 | 13 | 156,526 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
# AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1850894#1)
V, E, r = list(map(int, input().split()))
es = [list(map(int, input().split())) for i in range(E)]
# 以下を参考にさせていただきました
# http://ti2236.hatenablog.com/entry/2012/12/07/175841
# Chu-Liu/Edmonds' Algorithm... | output | 1 | 78,263 | 13 | 156,527 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,264 | 13 | 156,528 |
"Correct Solution:
```
from collections import defaultdict
from itertools import chain
nv, ne, r = map(int, input().split())
in_edges = defaultdict(set)
out_edges = defaultdict(set)
while ne:
s, t, w = map(int, input().split())
in_edges[t].add((w, s))
out_edges[s].add((w, t))
ne -= 1
def chu_liu_edm... | output | 1 | 78,264 | 13 | 156,529 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,265 | 13 | 156,530 |
"Correct Solution:
```
# AOJ GRL_2_B
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_B
import sys
from heapq import heappush, heappop
V, E, r = list(map(int, input().split()))
Edge = [list(map(int, input().split())) for _ in range(0, E)]
def solve(V, Edge, r):
if V <= 1:
return 0
q =... | output | 1 | 78,265 | 13 | 156,531 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,266 | 13 | 156,532 |
"Correct Solution:
```
from collections import defaultdict
nv, ne, r = map(int, input().split())
in_edges = defaultdict(set)
out_edges = defaultdict(set)
while ne:
s, t, w = map(int, input().split())
in_edges[t].add((w, s))
out_edges[s].add((w, t))
ne -= 1
def chu_liu_edmond(vertices, cycle_cost):
... | output | 1 | 78,266 | 13 | 156,533 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,267 | 13 | 156,534 |
"Correct Solution:
```
import heapq
from typing import List, Optional
def _find_cycle(incoming_edges: List[List[int]], root: int) -> Optional[List[int]]:
in_tree = [False] * v_num
in_tree[root] = True
for e in incoming_edges:
if e:
S = []
S.append(e[2])
while Tr... | output | 1 | 78,267 | 13 | 156,535 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,268 | 13 | 156,536 |
"Correct Solution:
```
def get_cycle(pre, nxt, root):
cycles, checked = [], set()
# root?????£????????????????????????????????§?????????????????????
checked |= {root}
que = nxt[root][:]
while que:
root_linked = que.pop()
checked |= {root_linked}
if nxt[root_linked]:
... | output | 1 | 78,268 | 13 | 156,537 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,269 | 13 | 156,538 |
"Correct Solution:
```
# Edige Weighted Digraph
from collections import namedtuple
WeightedEdge = namedtuple('WeightedEdge', ('src', 'dest', 'weight'))
class Digraph:
def __init__(self, v):
self.v = v
self._edges = [[] for _ in range(v)]
def add(self, edge):
self._edges[edge.src].... | output | 1 | 78,269 | 13 | 156,539 |
Provide a correct Python 3 solution for this coding contest problem.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|... | instruction | 0 | 78,270 | 13 | 156,540 |
"Correct Solution:
```
# Acceptance of input
import sys
file_input = sys.stdin
v_num, e_num, r = map(int, file_input.readline().split())
G = [[] for i in range(v_num)]
import heapq
for line in file_input:
s, t, w = map(int, line.split())
if t != r:
heapq.heappush(G[t], [w, s, t])
# Edmonds' algor... | output | 1 | 78,270 | 13 | 156,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 1... | instruction | 0 | 78,271 | 13 | 156,542 |
No | output | 1 | 78,271 | 13 | 156,543 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 1... | instruction | 0 | 78,272 | 13 | 156,544 |
No | output | 1 | 78,272 | 13 | 156,545 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 1... | instruction | 0 | 78,273 | 13 | 156,546 |
No | output | 1 | 78,273 | 13 | 156,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 1... | instruction | 0 | 78,274 | 13 | 156,548 |
No | output | 1 | 78,274 | 13 | 156,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an undirected graph with n vertices numbered from 1 to n. Initially there are no edges.
You are asked to perform some queries on the graph. Let last be the answer to the latest qu... | instruction | 0 | 78,372 | 13 | 156,744 |
No | output | 1 | 78,372 | 13 | 156,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
Let's define the k... | instruction | 0 | 78,373 | 13 | 156,746 |
No | output | 1 | 78,373 | 13 | 156,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
Let's define the k... | instruction | 0 | 78,374 | 13 | 156,748 |
No | output | 1 | 78,374 | 13 | 156,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
Let's define the k... | instruction | 0 | 78,375 | 13 | 156,750 |
No | output | 1 | 78,375 | 13 | 156,751 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
Let's define the k... | instruction | 0 | 78,376 | 13 | 156,752 |
No | output | 1 | 78,376 | 13 | 156,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,641 | 13 | 157,282 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
mod=10**9+7
n=int(input())
edges=list(map(int,input().split()))
colored=list(map(int,input().split()))
childs=[[] for i in range(n)]
for i in range(1,n):
childs[edges[i-1]].append(i)
dp = [[0,0] for i in range(n)]
for i in range(n-1,-1,-1):
prod=1
fo... | output | 1 | 78,641 | 13 | 157,283 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,642 | 13 | 157,284 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
MOD = 1000000007
n = int(input())
p = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
children = [[] for x in range(n)]
for i in range(1,n):
children[p[i-1]].append(i)
#print(children)
count = [(0,0) for i in range(n)]
for i in reve... | output | 1 | 78,642 | 13 | 157,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,643 | 13 | 157,286 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
n = int(input())
edges = [int(x) for x in input().split()]
color = [int(x) for x in input().split()]
graph = [[] for _ in range(n)]
for a,b in enumerate(edges):
graph[a+1].append(b)
graph[b].append(a+1)
dp = [[0]*2 for _ in range(n)]
visited = [0]*n
stack... | output | 1 | 78,643 | 13 | 157,287 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,644 | 13 | 157,288 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO,IOBase
def main():
mod = 10**9+7
n = int(input())
path = [[] for _ in range(n)]
for ind,i in enumerate(map(int,input().split())):
path[i].app... | output | 1 | 78,644 | 13 | 157,289 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,645 | 13 | 157,290 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = Byt... | output | 1 | 78,645 | 13 | 157,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,646 | 13 | 157,292 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
from collections import UserDict
class Tree(UserDict):
def __init__(self, g):
super().__init__()
for name, value in enumerate(g, 1):
self[value] = name
def __setitem__(self, name, value):
if name in self:
i... | output | 1 | 78,646 | 13 | 157,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,647 | 13 | 157,294 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
from collections import UserDict
class Tree(UserDict):
def __init__(self, g):
super().__init__()
for name, value in enumerate(g, 1):
self[value] = name
def __setitem__(self, name, value):
if name in self:
i... | output | 1 | 78,647 | 13 | 157,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the t... | instruction | 0 | 78,648 | 13 | 157,296 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
MOD = 10**9 + 7
def topo_compute(childrens, colors, parents):
def f(node, connected_to_black):
if colors[node] == 1 and connected_to_black:
return 0
children = childrens[node]
if colors[node] == 1 or connected_to_black:
... | output | 1 | 78,648 | 13 | 157,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's t... | instruction | 0 | 78,649 | 13 | 157,298 |
No | output | 1 | 78,649 | 13 | 157,299 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's t... | instruction | 0 | 78,650 | 13 | 157,300 |
No | output | 1 | 78,650 | 13 | 157,301 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's t... | instruction | 0 | 78,651 | 13 | 157,302 |
No | output | 1 | 78,651 | 13 | 157,303 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 ≤ k < n) edges of Appleman's t... | instruction | 0 | 78,652 | 13 | 157,304 |
No | output | 1 | 78,652 | 13 | 157,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given a tree with n vertices rooted at 1.
We say that there's a k-ary heap of depth m located at u if the following holds:
* For m = 1 u itself is a k-ary heap of depth 1.
* For m ... | instruction | 0 | 78,858 | 13 | 157,716 |
No | output | 1 | 78,858 | 13 | 157,717 |
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 of n vertices. You are to select k (not necessarily distinct) simple paths in such a way that it is possible to split all edges of the tree into three sets: edges not contai... | instruction | 0 | 78,859 | 13 | 157,718 |
No | output | 1 | 78,859 | 13 | 157,719 |
Provide a correct Python 3 solution for this coding contest problem.
There are 2N points evenly spaced on the circumference of a circle. These points are numbered 1 to 2N in clockwise order, starting from some of them.
Snuke will divide these points into N pairs, then for each pair, he will draw a line segment connec... | instruction | 0 | 78,940 | 13 | 157,880 |
"Correct Solution:
```
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
"""
AGC028 D
"""
import itertools
from functools import reduce
from functools import lru_cache
nn, k = map(int, input().split())
n = 2*nn
abli = []
for i in range(k):
a, b = map(int, input().split())
if a < b:
ab... | output | 1 | 78,940 | 13 | 157,881 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are 2N points evenly spaced on the circumference of a circle. These points are numbered 1 to 2N in clockwise order, starting from some of them.
Snuke will divide these points into N pairs... | instruction | 0 | 78,941 | 13 | 157,882 |
No | output | 1 | 78,941 | 13 | 157,883 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.