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.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,496 | 13 | 174,992 |
"Correct Solution:
```
import sys
f_i = sys.stdin
V, E = map(int, f_i.readline().split())
# adjacency matrix
no_edge = float("inf")
adj = [[no_edge] * V for i in range(V)]
for i in range(V):
adj[i][i] = 0
odd_b = 0 # bit DP to record odd vertex
ans = 0
# acceptance of input
for l_i in f_i:
s, t, d = map... | output | 1 | 87,496 | 13 | 174,993 |
Provide a correct Python 3 solution for this coding contest problem.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,497 | 13 | 174,994 |
"Correct Solution:
```
def warshall_floyd(n, dists):
prev = [t.copy() for t in dists]
for k in range(n):
current = [[0] * n for _ in range(n)]
prev_k = prev[k]
for i in range(n):
prev_i, current_i = prev[i], current[i]
prev_i_k = prev_i[k]
for j in ra... | output | 1 | 87,497 | 13 | 174,995 |
Provide a correct Python 3 solution for this coding contest problem.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,498 | 13 | 174,996 |
"Correct Solution:
```
import math
import sys
from typing import List
def warshall_floyd(table: List[List[int]], vertex_num: int) -> None:
for k in range(vertex_num):
for i in range(vertex_num):
for j in range(vertex_num):
table[i][j] = min(table[i][j], table[i][k] + table[k][j... | output | 1 | 87,498 | 13 | 174,997 |
Provide a correct Python 3 solution for this coding contest problem.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,499 | 13 | 174,998 |
"Correct Solution:
```
#!python3
iim = lambda: map(int, input().rstrip().split())
from heapq import heappush, heappop
def resolve():
V, E = iim()
inf = float("inf")
ad = [[inf]*V for i in range(V)]
bi = [1<<i for i in range(V)]
ans = 0
odd = 0
for i in range(E):
s, t, d = iim()
... | output | 1 | 87,499 | 13 | 174,999 |
Provide a correct Python 3 solution for this coding contest problem.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,500 | 13 | 175,000 |
"Correct Solution:
```
import sys
f_i = sys.stdin
V, E = map(int, f_i.readline().split())
# adjacency matrix
no_edge = 14001
adj = [[no_edge] * V for i in range(V)]
for i in range(V):
adj[i][i] = 0
odd_b = 0 # bit DP to record odd vertex
ans = 0
# acceptance of input
for l_i in f_i:
s, t, d = map(int, l... | output | 1 | 87,500 | 13 | 175,001 |
Provide a correct Python 3 solution for this coding contest problem.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constr... | instruction | 0 | 87,501 | 13 | 175,002 |
"Correct Solution:
```
def warshall_floyd(n, dists):
prev = [t.copy() for t in dists]
for k in range(n):
current = [t.copy() for t in prev]
prev_k = prev[k]
for i in range(n):
prev_i, current_i = prev[i], current[i]
prev_i_k = prev_i[k]
for j in range... | output | 1 | 87,501 | 13 | 175,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,502 | 13 | 175,004 |
Yes | output | 1 | 87,502 | 13 | 175,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,503 | 13 | 175,006 |
Yes | output | 1 | 87,503 | 13 | 175,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,504 | 13 | 175,008 |
Yes | output | 1 | 87,504 | 13 | 175,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,505 | 13 | 175,010 |
No | output | 1 | 87,505 | 13 | 175,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,506 | 13 | 175,012 |
No | output | 1 | 87,506 | 13 | 175,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,507 | 13 | 175,014 |
No | output | 1 | 87,507 | 13 | 175,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The... | instruction | 0 | 87,508 | 13 | 175,016 |
No | output | 1 | 87,508 | 13 | 175,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the programming classes Vasya was assigned a difficult problem. However, he doesn't know how to code and was unable to find the solution in the Internet, so he asks you to help.
You are ... | instruction | 0 | 88,888 | 13 | 177,776 |
No | output | 1 | 88,888 | 13 | 177,777 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,197 | 13 | 178,394 |
"Correct Solution:
```
def solve():
import sys
file_input = sys.stdin
while True:
N, Q = map(int, file_input.readline().split())
if N == 0:
break
parent = [None, None]
parent += [int(file_input.readline()) for _ in range(N - 1)]
unmarked = [True] * (N + 1)... | output | 1 | 89,197 | 13 | 178,395 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,198 | 13 | 178,396 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
class UnionFind():
def __init__(self,n):
self.n = n
self.parents = [-1]*n
def find(self,x): #根を見つける、繋ぎ直す
if self.parents[x] < 0:
return x
else:
self.parent... | output | 1 | 89,198 | 13 | 178,397 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,199 | 13 | 178,398 |
"Correct Solution:
```
def root(x):
while P[x-1]!=x:
x = P[x-1]
return x
def mark(x):
P[x-1] = x
while True:
n,q = map(int,input().split())
res = 0
if n==0:
break
P = [1]
for _ in range(n-1):
P.append(int(input()))
for _ in range(q):
com,num=map... | output | 1 | 89,199 | 13 | 178,399 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,200 | 13 | 178,400 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 89,200 | 13 | 178,401 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,201 | 13 | 178,402 |
"Correct Solution:
```
class UnionFind:
def __init__(self, size):
self.parent = list(range(size))
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def unite(self, x, y):
x = self.find(x)
y = self... | output | 1 | 89,201 | 13 | 178,403 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,202 | 13 | 178,404 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10 ** 6)
class UnionFindTree:
"""Disjoint-Set Data Structure
Union-Find Tree
complexity:
init: O(n)
find, unite, same: O(alpha(n))
used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
"""
def __init__(self, n):
... | output | 1 | 89,202 | 13 | 178,405 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,203 | 13 | 178,406 |
"Correct Solution:
```
def root(x):
while P[x] != x:
x = P[x]
return x
def mark(x):
P[x-1] = x-1
def query(x):
v = root(x-1) +1
return v
while True:
N,Q = map(int,input().strip().split(" "))
if N == Q == 0:
break
P = []
P.append(0)
for i in range(N-1):
p_... | output | 1 | 89,203 | 13 | 178,407 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node v.
* Q v: (Query) Print the index of the nearest marked ... | instruction | 0 | 89,204 | 13 | 178,408 |
"Correct Solution:
```
class UnionFind:
def __init__(self, size):
self.table = [None] * size
def find(self, x):
if self.table[x] == None:
return x
else:
# compression of the path
self.table[x] = self.find(self.table[x])
return self.table[x... | output | 1 | 89,204 | 13 | 178,409 |
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 T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node ... | instruction | 0 | 89,205 | 13 | 178,410 |
Yes | output | 1 | 89,205 | 13 | 178,411 |
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 T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node ... | instruction | 0 | 89,206 | 13 | 178,412 |
No | output | 1 | 89,206 | 13 | 178,413 |
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 T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node ... | instruction | 0 | 89,207 | 13 | 178,414 |
No | output | 1 | 89,207 | 13 | 178,415 |
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 T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node ... | instruction | 0 | 89,208 | 13 | 178,416 |
No | output | 1 | 89,208 | 13 | 178,417 |
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 T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:
* M v: (Mark) Mark node ... | instruction | 0 | 89,209 | 13 | 178,418 |
No | output | 1 | 89,209 | 13 | 178,419 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 89,503 | 13 | 179,006 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
import sys
input = sys.stdin.readline
testcase = int(input())
for _ in range(testcase):
n,m,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
if k == 1:
print(2)
print(1)
continue
if k*(k-... | output | 1 | 89,503 | 13 | 179,007 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 89,504 | 13 | 179,008 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division,print_function
from heapq import*
import sys
le = sys.__stdin__.read().split("\n")[::-1]
af = []
for ezo in range(int(le.pop())):
n,m,k = list(map(int, le.pop().split()))
ar = [set() for _ in range(n)]
... | output | 1 | 89,504 | 13 | 179,009 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 89,505 | 13 | 179,010 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from collections import deque
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m, k = map(int, input().split())
G = [set() for _ in range(n + 1)]
deg = [0] * (n + 1)
for _ in range(m):
i, j = map(i... | output | 1 | 89,505 | 13 | 179,011 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 89,506 | 13 | 179,012 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division,print_function
from heapq import*
import sys
t = list(map(int, sys.stdin.readline().strip().split()))[0]
af = []
for _ in range(t):
n,m,k = list(map(int, sys.stdin.readline().strip().split()))
ar = [set... | output | 1 | 89,506 | 13 | 179,013 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph with n vertices and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this subset has at least k neighbors in the subset. I... | instruction | 0 | 89,507 | 13 | 179,014 |
Tags: constructive algorithms, data structures, graphs
Correct Solution:
```
from __future__ import division, print_function
from heapq import *
import sys
le = sys.__stdin__.read().split("\n")[::-1]
af = []
for ezo in range(int(le.pop())):
n, m, k = list(map(int, le.pop().split()))
ar = [set() for i in range(... | output | 1 | 89,507 | 13 | 179,015 |
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 and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 89,508 | 13 | 179,016 |
No | output | 1 | 89,508 | 13 | 179,017 |
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 and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 89,509 | 13 | 179,018 |
No | output | 1 | 89,509 | 13 | 179,019 |
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 and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 89,510 | 13 | 179,020 |
No | output | 1 | 89,510 | 13 | 179,021 |
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 and m edges. Also, you are given an integer k.
Find either a clique of size k or a non-empty subset of vertices such that each vertex of this s... | instruction | 0 | 89,511 | 13 | 179,022 |
No | output | 1 | 89,511 | 13 | 179,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected graph that consists of n vertices and m edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edge... | instruction | 0 | 89,739 | 13 | 179,478 |
Tags: dfs and similar, graphs
Correct Solution:
```
from collections import deque
n, m = map(int, input().split())
adj = [[] for i in range(n)]
for i in range(m):
u, v, c = input().split()
u, v = int(u)-1, int(v)-1
adj[u].append((v, c))
adj[v].append((u, c))
visited = S = T = None
def bfs(i, k):
... | output | 1 | 89,739 | 13 | 179,479 |
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 that consists of n vertices and m edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of ... | instruction | 0 | 89,740 | 13 | 179,480 |
No | output | 1 | 89,740 | 13 | 179,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree (a connected acyclic undirected graph) of n vertices. Vertices are numbered from 1 to n and each vertex is assigned a character from a to t.
A path in the tree is said to be palindromic if at least one permutation of th... | instruction | 0 | 89,834 | 13 | 179,668 |
Tags: bitmasks, data structures, divide and conquer, trees
Correct Solution:
```
import sys, os
def centroid_decomp(coupl):
n = len(coupl)
bfs = [n - 1]
for node in bfs:
bfs += coupl[node]
for nei in coupl[node]:
coupl[nei].remove(node)
size = [0] * n
for node ... | output | 1 | 89,834 | 13 | 179,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
C: AA グラフ (AA Graph)
Problem
Given a graph as an ASCII Art (AA), please print the length of shortest paths from the vertex s to the vertex t. The AA of the graph satisfies the following constr... | instruction | 0 | 90,061 | 13 | 180,122 |
No | output | 1 | 90,061 | 13 | 180,123 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,122 | 13 | 180,244 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from collections import defaultdict
n, k = map(int, input().split())
connections = defaultdict(set)
for _ in range(n-1):
u, v = map(int, input().split())
connections[u].add(v)
connections[v].add(u)
leafs = set()
for node in connections:
if len(... | output | 1 | 90,122 | 13 | 180,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,123 | 13 | 180,246 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from collections import deque
n, k = list(map(int, input().split()))
G = [set() for _ in range(n + 1)]
q, nq = deque(), deque()
for _ in range(n - 1):
u, v = list(map(int, input().split()))
G[u].add(v)
G[v].add(u)
for u in range(1... | output | 1 | 90,123 | 13 | 180,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,124 | 13 | 180,248 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from collections import deque
n, k = list(map(int, input().split()))
G = [set() for _ in range(n + 1)]
q, nq = deque(), deque()
for _ in range(n - 1):
u, v = list(map(int, input().split()))
G[u].add(v)
G[v].add(u)
for u in range(1... | output | 1 | 90,124 | 13 | 180,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,125 | 13 | 180,250 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from collections import deque
n,k = map(int,input().split())
d = {}
for i in range(n):
d[i+1] = set()
for i in range(n-1):
u,v = map(int,input().split())
d[u].add(v)
d[v].add(u)
dist = {}
prev = {}
dist[1] = 0
q = deque()
q.append(1)
wh... | output | 1 | 90,125 | 13 | 180,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,126 | 13 | 180,252 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
# https://codeforces.com/problemset/problem/1067/B
def push(d, u, v):
if u not in d:
d[u] = []
if v not in d:
d[v] = []
d[u].append(v)
d[v].append(u)
def push_v(d, u, val):
if u not in d:
d[u] = 0
d[u] +... | output | 1 | 90,126 | 13 | 180,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,127 | 13 | 180,254 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from collections import deque
n, k = list(map(int, input().split()))
Gg = [set() for _ in range(n + 1)]
q, nq = deque(), deque()
for _ in range(n - 1):
u, v = list(map(int, input().split()))
Gg[u].add(v)
Gg[v].add(u)
for u in rang... | output | 1 | 90,127 | 13 | 180,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,128 | 13 | 180,256 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
from sys import stdin
from collections import deque
n, k = map(int, stdin.readline().split())
graph = [[] for _ in range(n)]
leaf = -1
for _ in range(n-1):
a,b = map(int,stdin.readline().split())
graph[a - 1].append(b - 1)
graph[b - 1].... | output | 1 | 90,128 | 13 | 180,257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and... | instruction | 0 | 90,129 | 13 | 180,258 |
Tags: dfs and similar, graphs, shortest paths
Correct Solution:
```
import math
n,k=map(int,input().split())
edges=[]
for i in range(n-1):
edges.append(tuple(map(int,input().split())))
degreelist=[]
for i in range(min(k+1,math.floor(math.log2(n))+10)):
degreelist.append({})
degrees=degreelist[0]
for i in range(... | output | 1 | 90,129 | 13 | 180,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ... | instruction | 0 | 90,130 | 13 | 180,260 |
Yes | output | 1 | 90,130 | 13 | 180,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree ... | instruction | 0 | 90,131 | 13 | 180,262 |
Yes | output | 1 | 90,131 | 13 | 180,263 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.