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 program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circula... | instruction | 0 | 83,911 | 13 | 167,822 |
Tags: dfs and similar, dp, graphs, greedy
Correct Solution:
```
n, m = (int(x) for x in input().strip().split())
coproc = [int(x) for x in input().strip().split()]
edges = []
for _ in range(m):
edges.append((int(x) for x in input().strip().split()))
inorder = [0] * n
adj = [[] for _ in range(n)]
for u, v in edges... | output | 1 | 83,911 | 13 | 167,823 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,060 | 13 | 168,120 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
"""
次数1のところにちょっかいを出すことを繰り返す。ダブルリーチが実現できたら勝ち。
"""
N = int(input())
AB = [tuple(int(x)-1 for x in row.split()) for row in sys.stdin.readlines()]
graph = [set() for _ in range(N)]
for a,b in AB:
graph[a].add(b)
graph[b].add(a)
deg = [len(x) for x in ... | output | 1 | 84,060 | 13 | 168,121 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,061 | 13 | 168,122 |
"Correct Solution:
```
N = int(input())
if N%2==1:
print("First")
exit()
elif N==2:
print("Second")
exit()
E = [[] for _ in range(N+1)]
for _ in range(N-1):
a, b = map(int, input().split())
E[a].append(b)
E[b].append(a)
E_dim = [len(e) for e in E]
E_set = [set(e) for e in E]
q = []
for v,... | output | 1 | 84,061 | 13 | 168,123 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,062 | 13 | 168,124 |
"Correct Solution:
```
from collections import deque
n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
tree = [[] for i in range(n)]
for a, b in info:
a -= 1
b -= 1
tree[a].append(b)
tree[b].append(a)
root = 0
par = {root: -1}
q = deque([root])
topo = []
while q:
... | output | 1 | 84,062 | 13 | 168,125 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,063 | 13 | 168,126 |
"Correct Solution:
```
from collections import deque
n=int(input())
E=[[] for i in range(n)]
for i in range(n-1):
a,b=map(int,input().split())
a=a-1
b=b-1
E[a].append(b)
E[b].append(a)
D=deque([0])
V=[0]*n
V[0]=1
A=[0]
P=[-1]*n
while len(D)>0:
x=D[0]
D.popleft()
for c in E[x]:
if V[c]==0:
D.ap... | output | 1 | 84,063 | 13 | 168,127 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,064 | 13 | 168,128 |
"Correct Solution:
```
N = list(map(int,input().split()))[0]
lis = [[] for i in range(N)]
for a_i,b_i in [ map(int,input().split()) for _ in range(N-1) ]:
lis[a_i-1].append(b_i-1)
lis[b_i-1].append(a_i-1)
while True:
sumsum = 0
for x in lis:
sumsum += sum(x)
if sumsum == 0:
print("Second")
quit()
for i ... | output | 1 | 84,064 | 13 | 168,129 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,065 | 13 | 168,130 |
"Correct Solution:
```
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc014/tasks/agc014_d
白にしか隣接しない白を作れれば勝ちである
黒は、直前に置かれた白に対して対策するような動きをする羽目になる
距離2の葉の対があったら100%可能
ある時点での残りの森を考える(残りのどの点も黒が隣接していないとする)
葉に白を置く→葉において阻止
葉に隣接する点にしろを置く→葉において阻止
それ以外の点は、置いたら横に置くだけ(葉ではないので、隣接頂点が存在する)
なので、十分性もおk?
距離2の葉が存在するかだけを判定すればよさそう
そ... | output | 1 | 84,065 | 13 | 168,131 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,066 | 13 | 168,132 |
"Correct Solution:
```
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
Edges=[[] for _ in range(n)]
for i in range(n-1):
a,b=map(int,input().split())
a-=1
b-=1
Edges[a].append(b)
Edges[b].append(a)
while sum([len(Edges[i]) for i in range(n)]):
for i in range(n):
... | output | 1 | 84,066 | 13 | 168,133 |
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 vertex is uncolored.
Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perfor... | instruction | 0 | 84,067 | 13 | 168,134 |
"Correct Solution:
```
def examA():
A, B, C = LI()
S = A+B+C
cur = 0
for i in range(32):
if A%2==1 or B%2==1 or C%2==1:
break
A = (S-A)//2
B = (S-B)//2
C = (S-C)//2
cur +=1
if cur==32:
ans = -1
else:
ans = cur
print(ans)
... | output | 1 | 84,067 | 13 | 168,135 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,068 | 13 | 168,136 |
Yes | output | 1 | 84,068 | 13 | 168,137 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,069 | 13 | 168,138 |
Yes | output | 1 | 84,069 | 13 | 168,139 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,070 | 13 | 168,140 |
Yes | output | 1 | 84,070 | 13 | 168,141 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,071 | 13 | 168,142 |
Yes | output | 1 | 84,071 | 13 | 168,143 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,072 | 13 | 168,144 |
No | output | 1 | 84,072 | 13 | 168,145 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,073 | 13 | 168,146 |
No | output | 1 | 84,073 | 13 | 168,147 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,074 | 13 | 168,148 |
No | output | 1 | 84,074 | 13 | 168,149 |
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 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Initially, each vertex is uncolored.
Takahashi and Aoki is playing a game by pain... | instruction | 0 | 84,075 | 13 | 168,150 |
No | output | 1 | 84,075 | 13 | 168,151 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,092 | 13 | 168,184 |
"Correct Solution:
```
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc()... | output | 1 | 84,092 | 13 | 168,185 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,093 | 13 | 168,186 |
"Correct Solution:
```
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
from collections import deque
n, k = map(int, input().split())
radius = k // 2
edge = [[] for _ in range(n)]
uv = []
for _ in range(n - 1):
a, b = map(int, input().split())
a -= 1; b -= 1
edge[a].append(b)
edge[b].appen... | output | 1 | 84,093 | 13 | 168,187 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,094 | 13 | 168,188 |
"Correct Solution:
```
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
sys.setrecursionlimit(10**9)
n,k = map(int, input().split())
G = [[] for i in range(n)]
edges = []
for i in range(n-1):
a,b = map(int, input().split())
a,b = a-1,b-1
G[a].append(b)
G[b].append(a)
ed... | output | 1 | 84,094 | 13 | 168,189 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,095 | 13 | 168,190 |
"Correct Solution:
```
n, k = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(n-1):
a, b = map(int, input().split())
adj[a-1].append(b-1)
adj[b-1].append(a-1)
def bfs(start, x):
vis = [-1 for _ in range(n)]
vis[start] = 0
s = [start]
cnt = 0
while s:
l = s.pop()
cnt += 1
if vis[l] <... | output | 1 | 84,095 | 13 | 168,191 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,096 | 13 | 168,192 |
"Correct Solution:
```
# coding:utf-8
import sys
from collections import defaultdict, deque
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline(... | output | 1 | 84,096 | 13 | 168,193 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,097 | 13 | 168,194 |
"Correct Solution:
```
from collections import deque
N, K = map(int, input().split())
T = [[] for i in range(N)]
E = []
for i in range(N-1):
a, b = map(int, input().split())
a, b = a-1, b-1
T[a].append(b)
T[b].append(a)
E.append((a, b))
def bfs(n):
visited = [False] * N
dist = [0] * N
... | output | 1 | 84,097 | 13 | 168,195 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,098 | 13 | 168,196 |
"Correct Solution:
```
from collections import deque
N, K, *AB = map(int, open(0).read().split())
E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
E[a].append(b)
E[b].append(a)
def solve(a, b):
D = [-1] * (N + 1)
if a == b:
Q = deque([a])
r = K // 2
D[a] = 0
... | output | 1 | 84,098 | 13 | 168,197 |
Provide a correct Python 3 solution for this coding contest problem.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its... | instruction | 0 | 84,099 | 13 | 168,198 |
"Correct Solution:
```
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import deque
N,K = map(int,readline().split())
m = map(int,read().split())
AB = list(zip(m,m))
graph = [[] for _ in range(N+1)]
for a,b in AB:
graph[a].appen... | output | 1 | 84,099 | 13 | 168,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,100 | 13 | 168,200 |
Yes | output | 1 | 84,100 | 13 | 168,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,101 | 13 | 168,202 |
Yes | output | 1 | 84,101 | 13 | 168,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,102 | 13 | 168,204 |
Yes | output | 1 | 84,102 | 13 | 168,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,103 | 13 | 168,206 |
Yes | output | 1 | 84,103 | 13 | 168,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,104 | 13 | 168,208 |
No | output | 1 | 84,104 | 13 | 168,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,105 | 13 | 168,210 |
No | output | 1 | 84,105 | 13 | 168,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,106 | 13 | 168,212 |
No | output | 1 | 84,106 | 13 | 168,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v. The diameter of a tree is the maximum among the distances between any t... | instruction | 0 | 84,107 | 13 | 168,214 |
No | output | 1 | 84,107 | 13 | 168,215 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,195 | 13 | 168,390 |
"Correct Solution:
```
# Python program to find articulation points in an undirected graph
import sys
sys.setrecursionlimit(100000)
from collections import defaultdict
# This class represents an undirected graph
# using adjacency list representation
class Graph:
def __init__(self, vertices):
self.V = v... | output | 1 | 84,195 | 13 | 168,391 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,196 | 13 | 168,392 |
"Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5 4
0 1
1 2
2 3
3 4
output:
1
2
3
"""
import sys
sys.setrecursionlimit(int(1e6))
def generate_adj_table(_v_info):
for v_detail in _v_info:
source, target = map(int, v_detail)
init_adj_table[source].append(target)
... | output | 1 | 84,196 | 13 | 168,393 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,197 | 13 | 168,394 |
"Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5 4
0 1
1 2
2 3
3 4
output:
1
2
3
"""
import sys
sys.setrecursionlimit(int(1e6))
def generate_adj_table(_v_info):
for v_detail in _v_info:
source, target = map(int, v_detail)
init_adj_table[source].append(target)
... | output | 1 | 84,197 | 13 | 168,395 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,198 | 13 | 168,396 |
"Correct Solution:
```
from sys import stdin
readline = stdin.readline
def main():
v, e = map(int, readline().split())
from collections import defaultdict
g = defaultdict(list)
for _ in range(e):
s, t = map(int, readline().split())
g[s].append(t)
g[t].append(s)
visited = ... | output | 1 | 84,198 | 13 | 168,397 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,199 | 13 | 168,398 |
"Correct Solution:
```
# Acceptance of input
import sys
f_i = sys.stdin
V, E = map(int, f_i.readline().split())
adj_sets = [set() for i in range(V)]
for l_i in f_i:
s, t = map(int, l_i.split())
adj_sets[s].add(t)
adj_sets[t].add(s)
# dfs traverse
prenum = [0] * V
parent = [0] * V
lowest = [V] * V
i... | output | 1 | 84,199 | 13 | 168,399 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,200 | 13 | 168,400 |
"Correct Solution:
```
# Acceptance of input
import sys
f_i = sys.stdin
V, E = map(int, f_i.readline().split())
adj = [[] for i in range(V)]
for l_i in f_i:
s, t = map(int, l_i.split())
adj[s].append(t)
adj[t].append(s)
# dfs traverse
prenum = [1] + [None] * (V - 1)
parent = [0] * V
lowest = [V] * V... | output | 1 | 84,200 | 13 | 168,401 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,201 | 13 | 168,402 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
N, M = map(int, input().split())
G = [[] for _ in [0]*N]
for _ in [0]*M:
a, b = map(int, input().split())
G[a].append(b)
G[b].append(a)
INF = 10**10
pre = [0]*N
visited = [0]*N
min_x = [INF]*N
is_articulation = [0]*... | output | 1 | 84,201 | 13 | 168,403 |
Provide a correct Python 3 solution for this coding contest problem.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connec... | instruction | 0 | 84,202 | 13 | 168,404 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
if __name__ == '__main__':
n, m = [int(s) for s in input().split()]
E = [set() for _ in range(n)]
for _ in range(m):
s, t = [int(s) for s in input().split(" ")]
E[s].add(t)
E[t].add(s)
de... | output | 1 | 84,202 | 13 | 168,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,203 | 13 | 168,406 |
Yes | output | 1 | 84,203 | 13 | 168,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,204 | 13 | 168,408 |
Yes | output | 1 | 84,204 | 13 | 168,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,205 | 13 | 168,410 |
Yes | output | 1 | 84,205 | 13 | 168,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,206 | 13 | 168,412 |
Yes | output | 1 | 84,206 | 13 | 168,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,207 | 13 | 168,414 |
No | output | 1 | 84,207 | 13 | 168,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,208 | 13 | 168,416 |
No | output | 1 | 84,208 | 13 | 168,417 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,209 | 13 | 168,418 |
No | output | 1 | 84,209 | 13 | 168,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find articulation points of a given undirected graph G(V, E).
A vertex in an undirected graph is an articulation point (or cut vertex) iff removing it disconnects the graph.
Constraints
* 1 ≤... | instruction | 0 | 84,210 | 13 | 168,420 |
No | output | 1 | 84,210 | 13 | 168,421 |
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,492 | 13 | 168,984 |
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())
adj = [[] for i in range(n+1)]
radj = [[] for i in range(n+1)]
# setup adj and radj
for i in range(m):
... | output | 1 | 84,492 | 13 | 168,985 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.