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 tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,571 | 13 | 209,142 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
from sys import stdin
try:
n=int(stdin.readline().rstrip())
l=[0]*(n+1)
arr=[]
for _ in range(n-1):
u,v=map(int,stdin.readline().rstrip().split())
arr.append((u,v))
l[u]+=1
l[v]+=1
x,y... | output | 1 | 104,571 | 13 | 209,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,572 | 13 | 209,144 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
def solve(graph):
ans = [-1 for i in range(len(graph) - 1)]
for v in graph:
if len(graph[v]) > 2:
for i, (u, k) in enumerate(graph[v][:3]):
ans[k] = i
k = 0
for i in ra... | output | 1 | 104,572 | 13 | 209,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,573 | 13 | 209,146 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
#!/usr/bin/env python
# coding: utf-8
# In[83]:
n = int(input())
edges = []
degrees = [0]
for i in range(n):
degrees.append(0)
# In[84]:
output = []
for i in range(n-1):
output.append(-1)
# In[85]:
def d3():
... | output | 1 | 104,573 | 13 | 209,147 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,574 | 13 | 209,148 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
"""
Template written to be used by Python Programmers.
Use at your own risk!!!!
Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import heapq
from math import ceil, floor, gcd, fabs,... | output | 1 | 104,574 | 13 | 209,149 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,575 | 13 | 209,150 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
#!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
import collections
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_buil... | output | 1 | 104,575 | 13 | 209,151 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,576 | 13 | 209,152 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
n = int(input())
deg = [0]*(n+2)
es = []
for i in range(n-1):
a,b = list(map(int, input().split()))
deg[a]+=1
deg[b]+=1
es.append((a,b))
if max(deg)==2:
for i in range(n-1):
print(i)
else:
k = deg.index(max(deg))
e_012 = 0
cnt... | output | 1 | 104,576 | 13 | 209,153 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,577 | 13 | 209,154 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self... | output | 1 | 104,577 | 13 | 209,155 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.
* All the written labels are distinct.
*... | instruction | 0 | 104,578 | 13 | 209,156 |
Tags: constructive algorithms, dfs and similar, greedy, trees
Correct Solution:
```
def solve(n, queries):
node = 0
count = [0] * (n + 1)
for u, v in queries:
count[u] += 1
count[v] += 1
if count[u] == 3:
node = u
if count[v] == 3:
node = v
j ... | output | 1 | 104,578 | 13 | 209,157 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,579 | 13 | 209,158 |
Yes | output | 1 | 104,579 | 13 | 209,159 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,580 | 13 | 209,160 |
Yes | output | 1 | 104,580 | 13 | 209,161 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,581 | 13 | 209,162 |
Yes | output | 1 | 104,581 | 13 | 209,163 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,582 | 13 | 209,164 |
Yes | output | 1 | 104,582 | 13 | 209,165 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,583 | 13 | 209,166 |
No | output | 1 | 104,583 | 13 | 209,167 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,584 | 13 | 209,168 |
No | output | 1 | 104,584 | 13 | 209,169 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,585 | 13 | 209,170 |
No | output | 1 | 104,585 | 13 | 209,171 |
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 consisting of n nodes. You want to write some labels on the tree's edges such that the following conditions hold:
* Every label is an integer between 0 and n-2 inclusive.... | instruction | 0 | 104,586 | 13 | 209,172 |
No | output | 1 | 104,586 | 13 | 209,173 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,840 | 13 | 209,680 |
Tags: implementation, math, trees
Correct Solution:
```
height, n = map(int, input().split())
s = height
reverted = False
for h in range(height-1, -1, -1):
if n > 2**h:
more = True
n -= 2**h
else:
more = False
if more ^ reverted:
s += (2 * 2**h - 1)
reverted = not mor... | output | 1 | 104,840 | 13 | 209,681 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,841 | 13 | 209,682 |
Tags: implementation, math, trees
Correct Solution:
```
h, n = map(int, input().split())
h -= 1
n -= 1
l = 0
r = 2 << h
ll = True
ans = 0
i = 0
while r - l > 1:
m = (l + r) // 2
if ll == (n < m):
ans += 1
else:
ans += 1 << (h - i + 1)
if n < m:
r = m
ll = False
else:
... | output | 1 | 104,841 | 13 | 209,683 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,842 | 13 | 209,684 |
Tags: implementation, math, trees
Correct Solution:
```
h, n = map(int, input().split())
t = bin(n-1)[2:]
t = '0'*(h-len(t))+t
res = 0
flag = True
for i in range(h):
if(t[i] == ('1' if flag else '0')):
res += 2**(h-i)
else:
flag = not flag
res += 1
print(res)
``` | output | 1 | 104,842 | 13 | 209,685 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,843 | 13 | 209,686 |
Tags: implementation, math, trees
Correct Solution:
```
h, n = map(int, input().split())
ans = h
n = n - 1 + (1 << h)
for i in range(1, h+1):
if not ( ((n & (1 << i)) == 0) ^ (n & (1 << (i-1)) == 0 )):
ans += (1 << i) - 1
print(ans)
``` | output | 1 | 104,843 | 13 | 209,687 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,844 | 13 | 209,688 |
Tags: implementation, math, trees
Correct Solution:
```
H,n=map(int,input().split(" "))
res=0
s=0
for h in range(H,0,-1):
res+=1
if s ^ ( n > 1 << (h-1) ):
res+= (1 << h) - 1
else:
s^=1
if n>1<<(h-1):
n-=1<<(h-1)
print(res)
``` | output | 1 | 104,844 | 13 | 209,689 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,845 | 13 | 209,690 |
Tags: implementation, math, trees
Correct Solution:
```
h, N = tuple(int(i) for i in input().split())
L = 1
R = pow(2,h)
mode = 0
level = 0
ans = 0
while(L!=R):
M = (L+R)//2
if(N<=M):
if(mode==0):
mode = 1
ans+=1
else:
ans+=pow(2,h-level)
R = M
else:
if(mode==0):
ans+=pow(2,h-level)
else:
mo... | output | 1 | 104,845 | 13 | 209,691 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,846 | 13 | 209,692 |
Tags: implementation, math, trees
Correct Solution:
```
line = input().split()
h = int(line[0])
n = int(line[1])
last = 1
th = 2 ** h
ans = 1
l = 1
r = th
while th > 0:
mid = (l + r) // 2
if n <= mid:
if last == 1:
ans += 1
else:
ans += th
last = 0
r = m... | output | 1 | 104,846 | 13 | 209,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree i... | instruction | 0 | 104,847 | 13 | 209,694 |
Tags: implementation, math, trees
Correct Solution:
```
def n_of_nodes(h):
result = 0
for i in range(h):
result += 2 ** i
return result
h, n = tuple(map(int, input().split()))
way = ""
t = h
while t:
if n % 2:
way = "L" + way
n //= 2
n += 1
else:
way = "R" +... | output | 1 | 104,847 | 13 | 209,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b1, ..., bk. Additionally, vertices a1, ..., ak,... | instruction | 0 | 104,947 | 13 | 209,894 |
Tags: dfs and similar, dp, greedy, implementation, trees
Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): ret... | output | 1 | 104,947 | 13 | 209,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b1, ..., bk. Additionally, vertices a1, ..., ak,... | instruction | 0 | 104,948 | 13 | 209,896 |
Tags: dfs and similar, dp, greedy, implementation, trees
Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): ret... | output | 1 | 104,948 | 13 | 209,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b1, ..., bk. Additionally, vertices a1, ..., ak,... | instruction | 0 | 104,949 | 13 | 209,898 |
Tags: dfs and similar, dp, greedy, implementation, trees
Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): ret... | output | 1 | 104,949 | 13 | 209,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b1, ..., bk. Additionally, vertices a1, ..., ak,... | instruction | 0 | 104,950 | 13 | 209,900 |
Tags: dfs and similar, dp, greedy, implementation, trees
Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): ret... | output | 1 | 104,950 | 13 | 209,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b... | instruction | 0 | 104,951 | 13 | 209,902 |
No | output | 1 | 104,951 | 13 | 209,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b... | instruction | 0 | 104,952 | 13 | 209,904 |
No | output | 1 | 104,952 | 13 | 209,905 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b... | instruction | 0 | 104,953 | 13 | 209,906 |
No | output | 1 | 104,953 | 13 | 209,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vanya wants to minimize a tree. He can perform the following operation multiple times: choose a vertex v, and two disjoint (except for v) paths of equal length a0 = v, a1, ..., ak, and b0 = v, b... | instruction | 0 | 104,954 | 13 | 209,908 |
No | output | 1 | 104,954 | 13 | 209,909 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a special connected undirected graph where each vertex belongs to at most one simple cycle.
Your task is to remove as many edges as needed to convert this graph into a tree (conne... | instruction | 0 | 105,025 | 13 | 210,050 |
No | output | 1 | 105,025 | 13 | 210,051 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a special connected undirected graph where each vertex belongs to at most one simple cycle.
Your task is to remove as many edges as needed to convert this graph into a tree (conne... | instruction | 0 | 105,026 | 13 | 210,052 |
No | output | 1 | 105,026 | 13 | 210,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey just turned five years old! When he was one year old, his parents gave him a number; when he was two years old, his parents gave him an array of integers. On his third birthday he receive... | instruction | 0 | 105,252 | 13 | 210,504 |
No | output | 1 | 105,252 | 13 | 210,505 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Sergey just turned five years old! When he was one year old, his parents gave him a number; when he was two years old, his parents gave him an array of integers. On his third birthday he receive... | instruction | 0 | 105,253 | 13 | 210,506 |
No | output | 1 | 105,253 | 13 | 210,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,289 | 13 | 210,578 |
Tags: graphs
Correct Solution:
```
import sys
input = sys.stdin.readline
class Unionfind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [1]*n
def root(self, x):
p = x
while not self.par[p]<0:
p = self.par[p]
while x!=p:
... | output | 1 | 105,289 | 13 | 210,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,290 | 13 | 210,580 |
Tags: graphs
Correct Solution:
```
import math
from collections import defaultdict as dd
def printTree(s):
q = [s]
visited[s] = 1
while(q):
cur = q.pop(-1)
for i in graph[cur]:
if visited[i] == 0:
visited[i] = 1
print(cur, i)
q.app... | output | 1 | 105,290 | 13 | 210,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,291 | 13 | 210,582 |
Tags: graphs
Correct Solution:
```
from collections import deque
n, m = map(int, input().split())
e = []
a = [[] for i in range(n)]
for i in range(m):
fr, to = map(int, input().split())
e.append((fr, to))
a[fr - 1].append(to - 1)
a[to - 1].append(fr - 1)
root = 0
maxPow = 0
for i in range(n):
if ... | output | 1 | 105,291 | 13 | 210,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,292 | 13 | 210,584 |
Tags: graphs
Correct Solution:
```
n,m=[int(x) for x in input().split()]
graph={}
for i in range(m):
a,b=[int(x) for x in input().split()]
for a,b in (a,b),(b,a):
if a not in graph:
graph[a]=[b]
else:
graph[a].append(b)
def tree(new):
total=[]
for v in new:
... | output | 1 | 105,292 | 13 | 210,585 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,293 | 13 | 210,586 |
Tags: graphs
Correct Solution:
```
from collections import defaultdict,deque
n,m,d = map(int, input().split())
g = defaultdict(list)
for i in range(m):
u,v = map(int,input().split())
g[u].append(v)
g[v].append(u)
init_set = set(g[1])
if d > len(g[1]):
print('NO')
exit()
vis = set()
vis.add(1)
clu... | output | 1 | 105,293 | 13 | 210,587 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,294 | 13 | 210,588 |
Tags: graphs
Correct Solution:
```
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
E=[list(map(int,input().split())) for i in range(m)]
cost=[0]*(n+1)
EDGELIST=[[] for i in range(n+1)]
for x,y in E:
cost[x]+=1
cost[y]+=1
EDGELIST[x].append(y)
EDGELIST[y].append(x)
x=cost.index(m... | output | 1 | 105,294 | 13 | 210,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,295 | 13 | 210,590 |
Tags: graphs
Correct Solution:
```
n, m, d = map(int, input().split())
g = [[] for _ in range(n + 1)]
haveOne = [False] * (n + 1)
for i in range(m):
u, v = map(int, input().split())
g[u].append(v)
g[v].append(u)
if u == 1:
haveOne[v] = True
if v == 1:
haveOne[u] = True
count = 0
group = [-1] * (n + 1)
sel... | output | 1 | 105,295 | 13 | 210,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to find any spanning tree of this graph such that ... | instruction | 0 | 105,296 | 13 | 210,592 |
Tags: graphs
Correct Solution:
```
import sys
import collections
v, e = map(int, input().strip().split())
graph = collections.defaultdict(list)
degree = [0 for i in range(v)]
mx, src = 0, 0
for i in range(e):
a, b = map(int, input().strip().split())
degree[a-1] += 1
graph[a].append(b)
if degree[a-1] > ... | output | 1 | 105,296 | 13 | 210,593 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,297 | 13 | 210,594 |
Yes | output | 1 | 105,297 | 13 | 210,595 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,298 | 13 | 210,596 |
Yes | output | 1 | 105,298 | 13 | 210,597 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,299 | 13 | 210,598 |
Yes | output | 1 | 105,299 | 13 | 210,599 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,300 | 13 | 210,600 |
Yes | output | 1 | 105,300 | 13 | 210,601 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,301 | 13 | 210,602 |
No | output | 1 | 105,301 | 13 | 210,603 |
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 unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to ... | instruction | 0 | 105,302 | 13 | 210,604 |
No | output | 1 | 105,302 | 13 | 210,605 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.