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 |
|---|---|---|---|---|---|
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 connected graph with N vertices and M edges that does not contain self-loops and double edges.
The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.
An... | instruction | 0 | 83,250 | 13 | 166,500 |
No | output | 1 | 83,250 | 13 | 166,501 |
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 connected graph with N vertices and M edges that does not contain self-loops and double edges.
The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.
An... | instruction | 0 | 83,251 | 13 | 166,502 |
No | output | 1 | 83,251 | 13 | 166,503 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.
Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $.
First, the b... | instruction | 0 | 83,355 | 13 | 166,710 |
"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.readline().split()]
def I(): return int(sys.stdin.readline())
def LS... | output | 1 | 83,355 | 13 | 166,711 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,356 | 13 | 166,712 |
"Correct Solution:
```
def topological_sort(nodes, edges) -> []:
visited = set()
result = []
def dfs(v):
if v not in visited:
visited.add(v)
for u in edges[v]:
dfs(u)
result.append(v)
for s in nodes:
dfs(s)
return result
def ao... | output | 1 | 83,356 | 13 | 166,713 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,357 | 13 | 166,714 |
"Correct Solution:
```
from collections import deque
N,E=map(int,input().split())
G=[[] for i in range(N)]
In=[0]*N
for i in range(E):
s,t=map(int,input().split())
G[s].append(t)
In[t]+=1
S=deque([i for i in range(N) if In[i]==0])
res=[]
while S:
b=S.popleft()
for nv in G[b]:
In[nv]-=1
... | output | 1 | 83,357 | 13 | 166,715 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,358 | 13 | 166,716 |
"Correct Solution:
```
from collections import defaultdict
vertice, edge = (int(n) for n in input().split(" "))
connect = defaultdict(list)
indegree = [0 for n in range(vertice)]
for _ in range(edge):
s, t = (int(n) for n in input().split(" "))
connect[s].append(t)
indegree[t] += 1
answer = []
zeroin = []
f... | output | 1 | 83,358 | 13 | 166,717 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,359 | 13 | 166,718 |
"Correct Solution:
```
from collections import deque
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
G = [[] for _ in [0]*N]
deg = [0]*N
for _ in [0]*M:
a, b = map(int, input().split())
G[a].append(b)
deg[b] += 1
q = deque()
for v, d in enumerate(deg):
if d == 0:
print(v... | output | 1 | 83,359 | 13 | 166,719 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,360 | 13 | 166,720 |
"Correct Solution:
```
from collections import deque
v, e = map(int, input().split())
adj = [[] for _ in range( v)]
inflow = [0] * v
for _ in range(e):
s, t = map(int, input().split())
inflow[t] += 1
adj[s].append(t)
def topological_sort(adj, inflow):
is_visited = [False] * len(inflow)
res = []
... | output | 1 | 83,360 | 13 | 166,721 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,361 | 13 | 166,722 |
"Correct Solution:
```
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
s, t = map(int, input().split())
G[s].append(t)
ans = []
V = set()
def dfs(n):
for e in G[n]:
if e not in V:
dfs(e)
ans.append(n)
V.add(n)
for i in range(N):
if i not in ... | output | 1 | 83,361 | 13 | 166,723 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,362 | 13 | 166,724 |
"Correct Solution:
```
from collections import deque
# 幅優先と深さ優先でトポロジカルソート
def topologicalSortBfs(n):
for i in range(n):
color[i] = WHITE
for i in range(0, n):
if indeg[i] == 0 and color[i] == WHITE:
bfs(i)
def bfs(s):
Q.appendleft(s)
color[s] = GRAY
while Q:
... | output | 1 | 83,362 | 13 | 166,725 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can u... | instruction | 0 | 83,363 | 13 | 166,726 |
"Correct Solution:
```
from sys import stdin
from collections import deque
V, E = map(int, stdin.readline().split())
adj_list = [[] for _ in [0] * V]
is_visited = [False] * V
for _ in [0] * E:
s, t = map(int, stdin.readline().split())
adj_list[s].append(t)
out = deque()
def dfs(u):
is_visited[u] = True
... | output | 1 | 83,363 | 13 | 166,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,364 | 13 | 166,728 |
Yes | output | 1 | 83,364 | 13 | 166,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,365 | 13 | 166,730 |
Yes | output | 1 | 83,365 | 13 | 166,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,366 | 13 | 166,732 |
Yes | output | 1 | 83,366 | 13 | 166,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,367 | 13 | 166,734 |
Yes | output | 1 | 83,367 | 13 | 166,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,368 | 13 | 166,736 |
No | output | 1 | 83,368 | 13 | 166,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,369 | 13 | 166,738 |
No | output | 1 | 83,369 | 13 | 166,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,370 | 13 | 166,740 |
No | output | 1 | 83,370 | 13 | 166,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represente... | instruction | 0 | 83,371 | 13 | 166,742 |
No | output | 1 | 83,371 | 13 | 166,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,473 | 13 | 166,946 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter
import math
def rsingle_int():
return int(stdin.readline().rstrip())
def rmult_int():
return [ int(x) for x in stdin.readline().rstrip().split() ]... | output | 1 | 83,473 | 13 | 166,947 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,474 | 13 | 166,948 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
n = int(input())
c = []
c.append([int(x) for x in input().split()])
c.append([int(x) for x in input().split()])
c.append([int(x) for x in input().split()])
ngbr = {}
flag = 1
for i in range(n - 1):
i, j = [int(x) for... | output | 1 | 83,474 | 13 | 166,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,475 | 13 | 166,950 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
n = int(input())
r1 = input()
r1 = r1.split()
r2 = input()
r2 = r2.split()
r3 = input()
r3 = r3.split()
costs = list()
vertices = list()
powers = list()
i = 0
while(i < n):
costs.append(list())
costs[i].append(... | output | 1 | 83,475 | 13 | 166,951 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,476 | 13 | 166,952 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
n = int(input())
r1 = input()
r1 = r1.split()
r2 = input()
r2 = r2.split()
r3 = input()
r3 = r3.split()
costs = list()
vertices = list()
powers = list()
i = 0
while(i < n):
costs.append(list())
costs[i].append(... | output | 1 | 83,476 | 13 | 166,953 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,477 | 13 | 166,954 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
n = int(input())
c = [list(map(int, input().split())) for _ in range(3)]
g = [[] for _ in range(n)]
l = [0] * n
for i in range(n - 1):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a... | output | 1 | 83,477 | 13 | 166,955 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,478 | 13 | 166,956 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
from itertools import product, combinations
from math import sqrt
def count(tree, c_first, c_second, c_third, n, color_list):
ans = 0
for i in range(n):
if i % 3 == 0:
ans += color_list[c_fi... | output | 1 | 83,478 | 13 | 166,957 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,479 | 13 | 166,958 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
# -*- coding: utf-8 -*-
import sys
from itertools import permutations
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c fo... | output | 1 | 83,479 | 13 | 166,959 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a tree consisting of n vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every c... | instruction | 0 | 83,480 | 13 | 166,960 |
Tags: brute force, constructive algorithms, dp, graphs, implementation, trees
Correct Solution:
```
def main():
from sys import stdin, stdout
n = int(stdin.readline())
from itertools import chain
c1 = tuple(map(int, input().split()))
c2 = tuple(map(int, input().split()))
c3 = tuple(map(int, inpu... | output | 1 | 83,480 | 13 | 166,961 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,481 | 13 | 166,962 |
Yes | output | 1 | 83,481 | 13 | 166,963 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,482 | 13 | 166,964 |
Yes | output | 1 | 83,482 | 13 | 166,965 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,483 | 13 | 166,966 |
Yes | output | 1 | 83,483 | 13 | 166,967 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,484 | 13 | 166,968 |
Yes | output | 1 | 83,484 | 13 | 166,969 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,485 | 13 | 166,970 |
No | output | 1 | 83,485 | 13 | 166,971 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,486 | 13 | 166,972 |
No | output | 1 | 83,486 | 13 | 166,973 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,487 | 13 | 166,974 |
No | output | 1 | 83,487 | 13 | 166,975 |
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 vertices. A tree is an undirected connected acyclic graph.
<image> Example of a tree.
You have to paint each vertex into one of three colors. For each vert... | instruction | 0 | 83,488 | 13 | 166,976 |
No | output | 1 | 83,488 | 13 | 166,977 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex.
The weight of a subtree is the sum of all numbers in this subtr... | instruction | 0 | 83,740 | 13 | 167,480 |
No | output | 1 | 83,740 | 13 | 167,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex.
The weight of a subtree is the sum of all numbers in this subtr... | instruction | 0 | 83,741 | 13 | 167,482 |
No | output | 1 | 83,741 | 13 | 167,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex.
The weight of a subtree is the sum of all numbers in this subtr... | instruction | 0 | 83,742 | 13 | 167,484 |
No | output | 1 | 83,742 | 13 | 167,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rooted tree with n vertices. In each leaf vertex there's a single integer — the number of apples in this vertex.
The weight of a subtree is the sum of all numbers in this subtr... | instruction | 0 | 83,743 | 13 | 167,486 |
No | output | 1 | 83,743 | 13 | 167,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected graph on n vertices and m edges. Find the shortest path from vertex s to vertex t or else state that such path doesn't exist.
Input
The first line of the in... | instruction | 0 | 83,776 | 13 | 167,552 |
No | output | 1 | 83,776 | 13 | 167,553 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected graph on n vertices and m edges. Find the shortest path from vertex s to vertex t or else state that such path doesn't exist.
Input
The first line of the in... | instruction | 0 | 83,777 | 13 | 167,554 |
No | output | 1 | 83,777 | 13 | 167,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected graph on n vertices and m edges. Find the shortest path from vertex s to vertex t or else state that such path doesn't exist.
Input
The first line of the in... | instruction | 0 | 83,778 | 13 | 167,556 |
No | output | 1 | 83,778 | 13 | 167,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a weighted undirected graph on n vertices and m edges. Find the shortest path from vertex s to vertex t or else state that such path doesn't exist.
Input
The first line of the in... | instruction | 0 | 83,779 | 13 | 167,558 |
No | output | 1 | 83,779 | 13 | 167,559 |
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, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple (u, v, s) interesting, if 1 ≤ u... | instruction | 0 | 83,879 | 13 | 167,758 |
No | output | 1 | 83,879 | 13 | 167,759 |
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, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple (u, v, s) interesting, if 1 ≤ u... | instruction | 0 | 83,880 | 13 | 167,760 |
No | output | 1 | 83,880 | 13 | 167,761 |
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, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple (u, v, s) interesting, if 1 ≤ u... | instruction | 0 | 83,881 | 13 | 167,762 |
No | output | 1 | 83,881 | 13 | 167,763 |
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, constisting of n vertices and m edges. Each edge of the graph has some non-negative integer written on it.
Let's call a triple (u, v, s) interesting, if 1 ≤ u... | instruction | 0 | 83,882 | 13 | 167,764 |
No | output | 1 | 83,882 | 13 | 167,765 |
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,908 | 13 | 167,816 |
Tags: dfs and similar, dp, graphs, greedy
Correct Solution:
```
n, m = [int(x) for x in input().split()]
tps = {i:int(t) for i, t in enumerate(input().split())}
deps = {i:0 for i in range(n)}
parents = {i:[] for i in range(n)}
leafs = {i for i in range(n)}
for i in range(m):
x, y = [int(x) for x in input().split()]... | output | 1 | 83,908 | 13 | 167,817 |
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,909 | 13 | 167,818 |
Tags: dfs and similar, dp, graphs, greedy
Correct Solution:
```
from collections import deque
import sys
input = sys.stdin.readline
def put():
return map(int, input().split())
def bfs_(main, co, flag):
curr = main if flag else co
while curr:
x = curr.popleft()
for y in graph[x]:
... | output | 1 | 83,909 | 13 | 167,819 |
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,910 | 13 | 167,820 |
Tags: dfs and similar, dp, graphs, greedy
Correct Solution:
```
from sys import stdin
from collections import deque
n,m = [int(x) for x in stdin.readline().split()]
e = [int(x) for x in stdin.readline().split()]
graph = [set() for x in range(n)]
reverse = [set() for x in range(n)]
root = set([x for x in range(n)])
f... | output | 1 | 83,910 | 13 | 167,821 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.