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 directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,493 | 13 | 168,986 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
from collections import deque
def cyc(n,path):
visi,poi = [2]+[0]*(n-1),[0]*n
inf = []
multi = []
st = [0]
while len(st):
... | output | 1 | 84,493 | 13 | 168,987 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,494 | 13 | 168,988 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
#!/usr/bin/env python
import os
import sys
from io import BytesIO,IOBase
from collections import deque
def cyc(n,path):
visi,poi = [2]+[0]*(n-1),[0]*n
inf = []
multi = []
st = [0]
while len(st):
x,y = st[-1],poi[st[-1]]
... | output | 1 | 84,494 | 13 | 168,989 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,495 | 13 | 168,990 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
import sys
sys.stderr = sys.stdout
from collections import deque
def solve(n, m, E):
D = [[] for _ in range(n)]
for u, v in E:
D[u].append(v)
P = [None] * n
K = [0] * n
V = [0] * n
V[0] = 1
A = {0}
i = 0
while... | output | 1 | 84,495 | 13 | 168,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,496 | 13 | 168,992 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
x = input()
n,m = map(int,input().split())
# kosaraju's algorithm to find sccs and create compressed graph
adj = [[] for i in range(n+1)]
radj = [[] for i in r... | output | 1 | 84,496 | 13 | 168,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,497 | 13 | 168,994 |
Tags: dfs and similar, dp, graphs, 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.buffer = BytesIO... | output | 1 | 84,497 | 13 | 168,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,498 | 13 | 168,996 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
x = input()
n,m = map(int,input().split())
# kosaraju's algorithm to find sccs and create compressed graph
adj = [[] for i in range(n+1)]
radj = [[] for i in r... | output | 1 | 84,498 | 13 | 168,997 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v. Vertices are numbered from 1 to n.
A pa... | instruction | 0 | 84,499 | 13 | 168,998 |
Tags: dfs and similar, dp, graphs, trees
Correct Solution:
```
#!/usr/bin/env python
import os
import sys
from io import BytesIO,IOBase
from collections import deque
def cyc(n,path):
visi,poi = [2]+[0]*(n-1),[0]*n
inf = []
multi = []
st = [0]
while len(st):
x,y = st[-1],poi[st[-1]]
... | output | 1 | 84,499 | 13 | 168,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,500 | 13 | 169,000 |
Yes | output | 1 | 84,500 | 13 | 169,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,501 | 13 | 169,002 |
Yes | output | 1 | 84,501 | 13 | 169,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,502 | 13 | 169,004 |
Yes | output | 1 | 84,502 | 13 | 169,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,503 | 13 | 169,006 |
Yes | output | 1 | 84,503 | 13 | 169,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,504 | 13 | 169,008 |
No | output | 1 | 84,504 | 13 | 169,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,505 | 13 | 169,010 |
No | output | 1 | 84,505 | 13 | 169,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,506 | 13 | 169,012 |
No | output | 1 | 84,506 | 13 | 169,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u... | instruction | 0 | 84,507 | 13 | 169,014 |
No | output | 1 | 84,507 | 13 | 169,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.
A non-oriented graph is a hydra, if i... | instruction | 0 | 84,508 | 13 | 169,016 |
No | output | 1 | 84,508 | 13 | 169,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.
A non-oriented graph is a hydra, if i... | instruction | 0 | 84,509 | 13 | 169,018 |
No | output | 1 | 84,509 | 13 | 169,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.
A non-oriented graph is a hydra, if i... | instruction | 0 | 84,510 | 13 | 169,020 |
No | output | 1 | 84,510 | 13 | 169,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.
A non-oriented graph is a hydra, if i... | instruction | 0 | 84,511 | 13 | 169,022 |
No | output | 1 | 84,511 | 13 | 169,023 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1... | instruction | 0 | 84,798 | 13 | 169,596 |
No | output | 1 | 84,798 | 13 | 169,597 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1... | instruction | 0 | 84,799 | 13 | 169,598 |
No | output | 1 | 84,799 | 13 | 169,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1... | instruction | 0 | 84,800 | 13 | 169,600 |
No | output | 1 | 84,800 | 13 | 169,601 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1... | instruction | 0 | 84,801 | 13 | 169,602 |
No | output | 1 | 84,801 | 13 | 169,603 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,894 | 13 | 169,788 |
"Correct Solution:
```
import sys
n = int(sys.stdin.buffer.readline())
mp = map(int, sys.stdin.buffer.read().split())
links = [set() for _ in range(n)]
for x, y in zip(mp, mp):
x -= 1
y -= 1
links[x].add(y)
links[y].add(x)
stack = [(0, -2)]
grundy = [0] * n
while stack:
v, p = stack.pop()
if p... | output | 1 | 84,894 | 13 | 169,789 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,895 | 13 | 169,790 |
"Correct Solution:
```
class Tree():
def __init__(self, n, decrement=1):
self.n = n
self.edges = [[] for _ in range(n)]
self.root = None
self.depth = [-1]*n
self.size = [1]*n # 部分木のノードの数
self.decrement = decrement
def add_edge(self, u, v):
u, v = u-... | output | 1 | 84,895 | 13 | 169,791 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,896 | 13 | 169,792 |
"Correct Solution:
```
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.read... | output | 1 | 84,896 | 13 | 169,793 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,897 | 13 | 169,794 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(9**9)
n=int(input())
T=[[]for _ in"_"*(n+1)]
for _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,
def d(v,p):
r=0
for s in T[v]:
if s!=p:r^=d(s,v)+1
return r
print("ABloibc e"[d(1,1)<1::2])
``` | output | 1 | 84,897 | 13 | 169,795 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,898 | 13 | 169,796 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10**6)
n = int(input())
adj = [[] for _ in range(n)]
for _ in range(n-1):
x, y = map(int, input().split())
adj[x-1].append(y-1)
adj[y-1].append(x-1)
visited = [False for _ in range(n)]
def dfs(x):
global visited
nim = 0
for v in adj[x]:
if visited[v] == F... | output | 1 | 84,898 | 13 | 169,797 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,899 | 13 | 169,798 |
"Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
x, y = map(int, input().split())
X[x-1].append(y-1)
X[y-1].append(x-1)
P = [-1] * N
Q = deque([0])
R = []
while Q:
i = deque.pop... | output | 1 | 84,899 | 13 | 169,799 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,900 | 13 | 169,800 |
"Correct Solution:
```
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# m... | output | 1 | 84,900 | 13 | 169,801 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alternately perform the following operation:
* Select an e... | instruction | 0 | 84,901 | 13 | 169,802 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
a, b = map(int, input().split())
graph[a-1].append(b-1)
graph[b-1].append(a-1)
checked = [False]*N
def dfs(p):
checked[p] = True
g = 0
... | output | 1 | 84,901 | 13 | 169,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,902 | 13 | 169,804 |
Yes | output | 1 | 84,902 | 13 | 169,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,903 | 13 | 169,806 |
Yes | output | 1 | 84,903 | 13 | 169,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,904 | 13 | 169,808 |
Yes | output | 1 | 84,904 | 13 | 169,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,905 | 13 | 169,810 |
Yes | output | 1 | 84,905 | 13 | 169,811 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,906 | 13 | 169,812 |
No | output | 1 | 84,906 | 13 | 169,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,907 | 13 | 169,814 |
No | output | 1 | 84,907 | 13 | 169,815 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,908 | 13 | 169,816 |
No | output | 1 | 84,908 | 13 | 169,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree with N vertices numbered 1, 2, ..., N. The edges of the tree are denoted by (x_i, y_i).
On this tree, Alice and Bob play a game against each other. Starting from Alice, they alt... | instruction | 0 | 84,909 | 13 | 169,818 |
No | output | 1 | 84,909 | 13 | 169,819 |
Provide a correct Python 3 solution for this coding contest problem.
Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree... | instruction | 0 | 84,946 | 13 | 169,892 |
"Correct Solution:
```
# AOJ 1001: Binary Tree Intersection And Union
# Python3 2018.7.5 bal4u
def parse(p, i):
global sz
node[i][2] += 1
del p[0]
if p[0] != ',':
if node[i][0] == 0:
node[i][0] = sz
sz += 1
parse(p, node[i][0])
del p[0]
if p[0] != ')':
if node[i][1] == 0:
node[i][1] = sz
sz += ... | output | 1 | 84,946 | 13 | 169,893 |
Provide a correct Python 3 solution for this coding contest problem.
Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree... | instruction | 0 | 84,947 | 13 | 169,894 |
"Correct Solution:
```
class Node:
def __init__(self, left, right):
self.left = left
self.right = right
self.val = ''
@classmethod
def fromString(cls, s):
pos = 1
if s[pos] == '(':
e = getEnd(s, 1)
left = cls.fromString(s[1:e+1])
... | output | 1 | 84,947 | 13 | 169,895 |
Provide a correct Python 3 solution for this coding contest problem.
Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree... | instruction | 0 | 84,948 | 13 | 169,896 |
"Correct Solution:
```
import re
class bintree():
def __init__(self, str1):
self.str1 = str1
if self.str1[1] != ",":
c = 0
counter = 0
for s in str1[1:]:
counter += 1
if s == "(":
c += 1
elif s =... | output | 1 | 84,948 | 13 | 169,897 |
Provide a correct Python 3 solution for this coding contest problem.
Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree... | instruction | 0 | 84,949 | 13 | 169,898 |
"Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
def tree_left(node, it):
c = next(it)
if c == "(":
node[0] = [None, None]
tree_left(node[0], it)
c = next(it)
if c == ",":
tree_right(node, it)
else:
assert False
def tree_right(... | output | 1 | 84,949 | 13 | 169,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,042 | 13 | 170,084 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
# n,m = map(int,input().split())
# G = [[] for _ in range(n+1)]
# V = [1]*(n+1)
# for i in range(m):
# x,y = map(int,input().split())
# G[x].append(y)
# G[y].append(x)
# l = [1]
# V[1] = 0
# q = []
# q.extend(G[1])
... | output | 1 | 85,042 | 13 | 170,085 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,043 | 13 | 170,086 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
import heapq
from collections import defaultdict
graph = defaultdict(list)
n,m = list(map(int,input().split()))
for i in range(m):
u,v = list(map(int,input().split()))
u-=1
v-=1
graph[u].append(v)
graph[v].a... | output | 1 | 85,043 | 13 | 170,087 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,044 | 13 | 170,088 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
import heapq
n, m = map(int,input().split())
vertices = [ [] for i in range(n)]
for _ in range(m):
v1, v2 = map(int,input().split())
vertices[v1-1].append(v2-1)
vertices[v2 - 1].append(v1 - 1)
heap = []
heapq.h... | output | 1 | 85,044 | 13 | 170,089 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,045 | 13 | 170,090 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
import math
#import math
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self... | output | 1 | 85,045 | 13 | 170,091 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,046 | 13 | 170,092 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
import sys
from heapq import heappush,heappop
from collections import defaultdict as dd
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def inpu... | output | 1 | 85,046 | 13 | 170,093 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,047 | 13 | 170,094 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
from collections import defaultdict
import heapq
graph=defaultdict(list)
nodes,edges=map(int,input().split())
for i in range(edges):
vertex1,vertex2=map(int,input().split())
graph[vertex1].append(vertex2)
graph[vertex2].... | output | 1 | 85,047 | 13 | 170,095 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Lunar New Year is approaching, and Bob decides to take a wander in a nearby park.
The park can be represented as a connected graph with n nodes and m bidirectional edges. Initially Bob is at the node 1 and he records 1 on his notebook. He c... | instruction | 0 | 85,048 | 13 | 170,096 |
Tags: data structures, dfs and similar, graphs, greedy, shortest paths
Correct Solution:
```
from heapq import heappush, heappop
n, m = map(int, input().split())
adj = [[] for i in range(n+1)]
for i in range(m):
u, v = map(int, input().split())
adj[u].append(v)
adj[v].append(u)
v = [False for i in ra... | output | 1 | 85,048 | 13 | 170,097 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.