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.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,995 | 13 | 183,990 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
n, k = map(int, input().split())
t, q = [[] for i in range(n + 1)], [1]
for j in range(n - 1):
a, b = map(int, input().split())
t[a].append(b)
t[b].append(a)
for x in q:
for y in t[x]: t[y].remove(x)
q.extend(t[x])
q.reverse()
a, s = {}, 0
for... | output | 1 | 91,995 | 13 | 183,991 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,996 | 13 | 183,992 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
n,k=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
a,b=map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
q=[0]
for x in q:
for y in g[x]:
g[y].remove(x)
q.extend(g[x])
q.reverse()
d,cnt={},0
for x in q:
d[x]=[1]
... | output | 1 | 91,996 | 13 | 183,993 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,997 | 13 | 183,994 |
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
from collections import defaultdict,Counter
from copy import deepcopy
def solve(k,path,path1,lst):
st = [1]
while len(st):
if not len(path[st... | output | 1 | 91,997 | 13 | 183,995 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,998 | 13 | 183,996 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
def main():
n,k=map(int,input().split())
tree=[[] for _ in range(n+1)]
for _ in range(n-1):
a,b=map(int,input().split... | output | 1 | 91,998 | 13 | 183,997 |
Provide tags and a correct Python 2 solution for this coding contest problem.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with n vertices and a positive number k. Fi... | instruction | 0 | 91,999 | 13 | 183,998 |
Tags: dfs and similar, dp, trees
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
def in_arr():
return map(int,raw_input().split())
def pr_num(n):
stdout.write(str(n)... | output | 1 | 91,999 | 13 | 183,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a t... | instruction | 0 | 92,000 | 13 | 184,000 |
Yes | output | 1 | 92,000 | 13 | 184,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a t... | instruction | 0 | 92,001 | 13 | 184,002 |
No | output | 1 | 92,001 | 13 | 184,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a t... | instruction | 0 | 92,002 | 13 | 184,004 |
No | output | 1 | 92,002 | 13 | 184,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a t... | instruction | 0 | 92,003 | 13 | 184,006 |
No | output | 1 | 92,003 | 13 | 184,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a t... | instruction | 0 | 92,004 | 13 | 184,008 |
No | output | 1 | 92,004 | 13 | 184,009 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,465 | 13 | 184,930 |
"Correct Solution:
```
import sys,time
sys.setrecursionlimit(10**7)
start_time = time.time()
N,M = map(int,input().split())
S = input()
src = [tuple(map(lambda x:int(x)-1,sys.stdin.readline().split())) for i in range(M)]
outdeg = [set() for i in range(2*N)]
for x,y in src:
if S[x] == S[y]:
#A0->A1, B0->B1... | output | 1 | 92,465 | 13 | 184,931 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,466 | 13 | 184,932 |
"Correct Solution:
```
def examC():
N,M = LI()
S = SI()
V = [[] for _ in range(N)]
ok = [1]*N
acnt = [0]*N; bcnt = [0]*N
for _ in range(M):
a, b = LI()
V[a-1].append(b-1)
V[b-1].append(a-1)
if S[a-1]=="A":
acnt[b-1] +=1
else:
bcnt[b... | output | 1 | 92,466 | 13 | 184,933 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,467 | 13 | 184,934 |
"Correct Solution:
```
n, m = map(int, input().split())
s = input()
g = [[] for _ in range(n)]
for _ in range(m):
a, b = map(int, input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
count = [[0, 0] for _ in range(n)]
bad = []
for i in range(n):
for v in g[i]:
if s[v] == 'A':
c... | output | 1 | 92,467 | 13 | 184,935 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,468 | 13 | 184,936 |
"Correct Solution:
```
from collections import deque
N, M = map(int, input().split())
S = input()
# 頂点iがラベルA・Bの頂点といくつ隣接しているか
connect_label = [[0, 0] for i in range(N)]
# 削除する予定の頂点を管理するキュー
queue = deque()
# 削除済みの頂点を管理する集合
deleted_set = set()
# 各頂点の連結情報
G = [[] for i in range(N)]
# 辺の情報を入力
for i in range(M):
a, ... | output | 1 | 92,468 | 13 | 184,937 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,469 | 13 | 184,938 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
S = input().rstrip()
AB = []
AA = []
BB = []
for _ in range(M):
a, b = map(int, input().split())
if S[a-1] == "A" and S[b-1] == "B":
AB.append((a-1, b-1))
elif S[a-1] == "B" and S[b-1] == "A":
AB.a... | output | 1 | 92,469 | 13 | 184,939 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,470 | 13 | 184,940 |
"Correct Solution:
```
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
"""
GC027 C
"""
n,m = map(int,input().split())
s = list(input())
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]
from collections import defaultdict
graphAB = defaultdict(list)
for i in range(m):
u,v=map(int,input().... | output | 1 | 92,470 | 13 | 184,941 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,471 | 13 | 184,942 |
"Correct Solution:
```
N,M=map(int,input().split())
S="0"+input()
E=[[] for i in range(N+1)]
AOUT=[0]*(N+1)
BOUT=[0]*(N+1)
for i in range(M):
x,y=map(int,input().split())
E[x].append(y)
E[y].append(x)
if S[x]=="A":
AOUT[y]+=1
else:
BOUT[y]+=1
if S[y]=="A":
AOUT[x]+=1
... | output | 1 | 92,471 | 13 | 184,943 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connec... | instruction | 0 | 92,472 | 13 | 184,944 |
"Correct Solution:
```
from collections import deque
n, m = map(int, input().split())
s = input()
info = [list(map(int, input().split())) for i in range(m)]
graph = [[] for i in range(n)]
for i in range(m):
a, b = info[i]
a -= 1
b -= 1
graph[a].append(b)
graph[b].append(a)
v_num = [0] * n
for i... | output | 1 | 92,472 | 13 | 184,945 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,473 | 13 | 184,946 |
Yes | output | 1 | 92,473 | 13 | 184,947 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,474 | 13 | 184,948 |
Yes | output | 1 | 92,474 | 13 | 184,949 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,475 | 13 | 184,950 |
Yes | output | 1 | 92,475 | 13 | 184,951 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,476 | 13 | 184,952 |
Yes | output | 1 | 92,476 | 13 | 184,953 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,477 | 13 | 184,954 |
No | output | 1 | 92,477 | 13 | 184,955 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,478 | 13 | 184,956 |
No | output | 1 | 92,478 | 13 | 184,957 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,479 | 13 | 184,958 |
No | output | 1 | 92,479 | 13 | 184,959 |
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 consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The... | instruction | 0 | 92,480 | 13 | 184,960 |
No | output | 1 | 92,480 | 13 | 184,961 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 tim... | instruction | 0 | 92,499 | 13 | 184,998 |
"Correct Solution:
```
import queue
n,q=int(input()),queue.Queue()
s=[set() for i in range(n+1)]
for i in range(2*n-2):
u,v=map(int,input().split())
if v in s[u]:
q.put((u,v))
else:
s[u].add(v)
s[v].add(u)
f=[i for i in range(n+1)]
def find(x):
if f[x]==x:
return x
else:
f[x]=find(f[x])
return f[x]
whi... | output | 1 | 92,499 | 13 | 184,999 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
You are given a connected undirected graph which has even numbers of nodes. A connected graph is a graph in which all nodes are connected directly or indirectly by edges.
Your task is to find a spanning tree whose median value of ... | instruction | 0 | 92,581 | 13 | 185,162 |
"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 | 92,581 | 13 | 185,163 |
Provide a correct Python 3 solution for this coding contest problem.
Problem Statement
You are given a connected undirected graph which has even numbers of nodes. A connected graph is a graph in which all nodes are connected directly or indirectly by edges.
Your task is to find a spanning tree whose median value of ... | instruction | 0 | 92,582 | 13 | 185,164 |
"Correct Solution:
```
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return li... | output | 1 | 92,582 | 13 | 185,165 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,597 | 13 | 185,194 |
"Correct Solution:
```
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)
def seq():
a = 1
while True:
yield a
a += 1
def dfs(here, went, connect, discovery, low, answer, seq):
went |= {here}
discovery[here] = low[here] = next(seq)
child = 0
for con in... | output | 1 | 92,597 | 13 | 185,195 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,598 | 13 | 185,196 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
class LowLink():
def __init__(self,G):
self.N = len(G)
self.G = G
self.low = [-1] * self.N
self.ord = [-1] * self.N
def _dfs(self,v,time,p = -1):
self.ord[v] = self.lo... | output | 1 | 92,598 | 13 | 185,197 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,599 | 13 | 185,198 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')
N,M=MAP()
nodes=[[] for i in range(N... | output | 1 | 92,599 | 13 | 185,199 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,600 | 13 | 185,200 |
"Correct Solution:
```
# Undirected Graph
class Edge:
__slots__ = ('v', 'w')
def __init__(self, v, w):
self.v = v
self.w = w
def either(self):
return self.v
def other(self, v):
if v == self.v:
return self.w
else:
return self.v
class ... | output | 1 | 92,600 | 13 | 185,201 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,601 | 13 | 185,202 |
"Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5 4
0 1
1 2
2 3
3 4
output:
0 1
1 2
2 3
3 4
"""
import sys
sys.setrecursionlimit(int(1e5))
def generate_adj_table(_v_info):
for v_detail in _v_info:
v_from, v_to = map(int, v_detail)
init_adj_table[v_from].append(v_... | output | 1 | 92,601 | 13 | 185,203 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,602 | 13 | 185,204 |
"Correct Solution:
```
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().sp... | output | 1 | 92,602 | 13 | 185,205 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,603 | 13 | 185,206 |
"Correct Solution:
```
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
# return: articulation points, bridges
# The graph must be connected.
def lowlink(adj, root=1):
N = len(adj) - 1
order = [N + 1] * (N + 1)
low = [N + 1] * (N + 1)
... | output | 1 | 92,603 | 13 | 185,207 |
Provide a correct Python 3 solution for this coding contest problem.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no par... | instruction | 0 | 92,604 | 13 | 185,208 |
"Correct Solution:
```
from math import inf
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
def dfs(v,par):
global cur
vis[v]=1 ; disc[v]=cur ;low[v]=cur
cur+=1
for i in g[v]:
if vis[i]==0:
dfs(i,v)
low[v]=min(low[i],low[v])
... | output | 1 | 92,604 | 13 | 185,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,605 | 13 | 185,210 |
Yes | output | 1 | 92,605 | 13 | 185,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,606 | 13 | 185,212 |
Yes | output | 1 | 92,606 | 13 | 185,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,607 | 13 | 185,214 |
Yes | output | 1 | 92,607 | 13 | 185,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,608 | 13 | 185,216 |
Yes | output | 1 | 92,608 | 13 | 185,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,609 | 13 | 185,218 |
No | output | 1 | 92,609 | 13 | 185,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,610 | 13 | 185,220 |
No | output | 1 | 92,610 | 13 | 185,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,611 | 13 | 185,222 |
No | output | 1 | 92,611 | 13 | 185,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |... | instruction | 0 | 92,612 | 13 | 185,224 |
No | output | 1 | 92,612 | 13 | 185,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n.
Let's call a set of integers S such that S ⊆ \{1, 2, 3, ..., n\} strange, if, for every element i of S, the foll... | instruction | 0 | 92,858 | 13 | 185,716 |
Tags: flows, math
Correct Solution:
```
from typing import NamedTuple, Optional, List, cast
class MFGraph:
class Edge(NamedTuple):
src: int
dst: int
cap: int
flow: int
class _Edge:
def __init__(self, dst: int, cap: int) -> None:
self.dst = dst
s... | output | 1 | 92,858 | 13 | 185,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."... | instruction | 0 | 93,011 | 13 | 186,022 |
Tags: bitmasks, constructive algorithms, graphs, implementation, math
Correct Solution:
```
k=str(input())
l=len(k)
paths=[]
for i in range(l):
paths.append([1]*i+[int(k[i])]+[10]*(l-i-1))
lens = [sum(p) for p in paths]
n = sum(lens)+2
m = ['']*n
m[0] = 'N'*2
for i in range(len(paths)):
m[0] += 'Y'*paths[i][0]+'N'*(l... | output | 1 | 93,011 | 13 | 186,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."... | instruction | 0 | 93,012 | 13 | 186,024 |
Tags: bitmasks, constructive algorithms, graphs, implementation, math
Correct Solution:
```
k = int(input())
edges = [['N' for i in range(1010)] for j in range(1010)]
vertices = 2
def add_edge(a, b):
global edges
edges[a][b] = edges[b][a] = 'Y'
for i in range(1, 29 + 1):
vertices += 3
add_edge(i * ... | output | 1 | 93,012 | 13 | 186,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."... | instruction | 0 | 93,013 | 13 | 186,026 |
Tags: bitmasks, constructive algorithms, graphs, implementation, math
Correct Solution:
```
n, m, cnt = int(input()), 148, 0
ans = [['N'] * m for i in range(m)]
def edge(i, j):
ans[i][j] = ans[j][i] = 'Y'
def node(*adj):
global cnt
i = cnt
cnt += 1
for j in adj:
edge(i, j)
return i
st... | output | 1 | 93,013 | 13 | 186,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel wants to write a task for a programming contest. The task is: "You are given a simple undirected graph with n vertexes. Each its edge has unit length. You should calculate the number of shortest paths between vertex 1 and vertex 2."... | instruction | 0 | 93,014 | 13 | 186,028 |
Tags: bitmasks, constructive algorithms, graphs, implementation, math
Correct Solution:
```
from collections import defaultdict
k=int(input())
mask=0
d=defaultdict(lambda:0)
while(mask<=30):
if k&(1<<mask):
d[mask]=1
ma=mask
mask+=1
adj=defaultdict(lambda:"N")
currl=1
currvu=3
prevu=[1]
prevl... | output | 1 | 93,014 | 13 | 186,029 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.