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've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,612 | 13 | 125,224 |
Tags: dfs and similar, graphs
Correct Solution:
```
def cycle(G, K):
path = [1]
pos = [-1 for i in range(len(G) + 1)]
while True:
v = path[-1]
pos[v] = len(path) - 1
#print(path, v, G[v])
for u in G[v]:
if pos[u] == -1:
path.append(u)
break
elif len(path) - pos[u] > K:
return path[pos[u]::]... | output | 1 | 62,612 | 13 | 125,225 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,613 | 13 | 125,226 |
Tags: dfs and similar, graphs
Correct Solution:
```
import random
def solve(G, k):
d, mark, pi = [[0] * (len(G) + 1) for _ in range(3)]
back_edge = [-1] * 2
pi[0] = -1
DFS_VISIT(G, 0, mark, d, pi, k, back_edge)
current = back_edge[0]
cycle = []
while(current != pi[back_edge[1]]):
... | output | 1 | 62,613 | 13 | 125,227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,614 | 13 | 125,228 |
Tags: dfs and similar, graphs
Correct Solution:
```
n,l,k=map(int,input().split())
c=list([] for i in range(n+1))
for i in range(l):
x,y=map(int,input().split())
c[x].append(y)
c[y].append(x)
d=list(0 for i in range(n+1))
d[1]=1
now=1
time=1
f=True
while f:
time+=1
v=0
while v>=0:
if d[c... | output | 1 | 62,614 | 13 | 125,229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,615 | 13 | 125,230 |
Tags: dfs and similar, graphs
Correct Solution:
```
n, m, k = [int(x) for x in input().split()]
adj = [[] for _ in range(n + 1)]
for _ in range(m):
u, v = [int(x) for x in input().split()]
adj[u].append(v)
adj[v].append(u)
mark = [False for _ in range(n + 1)]
c = [1]
while True:
mark[c[-1]] = True
f... | output | 1 | 62,615 | 13 | 125,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,616 | 13 | 125,232 |
Tags: dfs and similar, graphs
Correct Solution:
```
def find_cycle_optimum(n,m,k,adj):
path = [1]
visited = [-1 for _ in range(n+1)]
visited[1] = 1
while True:
v = path[-1]
visited[v] = len(path) - 1
for w in adj[v]:
if visited[w] == -1:
path.append(w)... | output | 1 | 62,616 | 13 | 125,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is ... | instruction | 0 | 62,617 | 13 | 125,234 |
Tags: dfs and similar, graphs
Correct Solution:
```
import sys
import threading
def put():
return map(int, sys.stdin.readline().split())
def dfs(i, h):
vis[i] =h
done[i]=1
element.append(i)
for j in graph[i]:
if vis[j]!=0 and h-vis[j]>=k:
ind = element.index(j)
... | output | 1 | 62,617 | 13 | 125,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,618 | 13 | 125,236 |
Yes | output | 1 | 62,618 | 13 | 125,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,619 | 13 | 125,238 |
Yes | output | 1 | 62,619 | 13 | 125,239 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,620 | 13 | 125,240 |
Yes | output | 1 | 62,620 | 13 | 125,241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,621 | 13 | 125,242 |
Yes | output | 1 | 62,621 | 13 | 125,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,622 | 13 | 125,244 |
No | output | 1 | 62,622 | 13 | 125,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,623 | 13 | 125,246 |
No | output | 1 | 62,623 | 13 | 125,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,624 | 13 | 125,248 |
No | output | 1 | 62,624 | 13 | 125,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at l... | instruction | 0 | 62,625 | 13 | 125,250 |
No | output | 1 | 62,625 | 13 | 125,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,813 | 13 | 125,626 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
import sys
from heapq import heappop, heappush
n, m = map(int, sys.stdin.buffer.readline().decode('utf-8').split())
rev = [[] for _ in range(n)]
outdeg = [0]*n
for u, v in (map(int, line.decode('utf-8').split()) for line in sys.stdin.buffer)... | output | 1 | 62,813 | 13 | 125,627 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,814 | 13 | 125,628 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
import sys, heapq
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
n, m = map(int, input().split())
g = [[] for _ in range(n + 1)]
indeg = [0] * (n + 1)
for _ in range(m):
u, v = map(int, input().split())
g[v].appe... | output | 1 | 62,814 | 13 | 125,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,815 | 13 | 125,630 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
from heapq import *
n, m = map(int, input().split())
g = [[] for _ in range(n + 1)]
out = [0] * (n + 1)
for _ in range(m):
u, v = map(int, input().split())
g[v].append(u)
out[u] += 1
q = [-u for u in range(1, n + 1) if not out[u]]
heapify... | output | 1 | 62,815 | 13 | 125,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,816 | 13 | 125,632 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
import collections
import heapq
def constructGraph(n, edges):
graph = collections.defaultdict(list)
inDegree = [0 for _ in range(n)]
for edge in edges:
a, b = edge[0]-1, edge[1]-1
graph[b].append(a)
inDe... | output | 1 | 62,816 | 13 | 125,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,817 | 13 | 125,634 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
from heapq import heappush, heappop
q = lambda:map(int, input().split())
n, m = q()
a = d = [0] * n
e = [[] for _ in range(n)]
h = []
while(m):
l, r = q()
d[l - 1] += 1
e[r - 1] += [l - 1]
m -= 1
for i in range(n):
if(d[i] ... | output | 1 | 62,817 | 13 | 125,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,818 | 13 | 125,636 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
from queue import Queue
import heapq
n, m = input().split()
n = int(n)
m = int(m)
f = [0] * (n + 1)
sol = [0] * (n + 1)
adya = [[] for _ in range(n + 1)]
for i in range(m):
n1, n2 = input().split()
n1 = int(n1)
n2 = int(n2)
... | output | 1 | 62,818 | 13 | 125,637 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,819 | 13 | 125,638 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
#!/usr/local/bin/python3
from collections import defaultdict
import heapq
num_nodes, num_edges = map(int, input().split())
ins = defaultdict(set)
out = defaultdict(int)
for _ in range(num_edges):
node_out, node_in = map(int, input().sp... | output | 1 | 62,819 | 13 | 125,639 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels ... | instruction | 0 | 62,820 | 13 | 125,640 |
Tags: data structures, dfs and similar, graphs, greedy
Correct Solution:
```
n,m=map(int,input().split())
d=[0]*n
e=[[] for i in range(n)]
for i in range(m):
u,v=map(int,input().split())
u-=1
v-=1
d[u]+=1
e[v].append(u)
from heapq import heappush, heappop
pq=[]
for i in range(n):
if d[i]==0:
heappush(pq,-i)
ind... | output | 1 | 62,820 | 13 | 125,641 |
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 acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels t... | instruction | 0 | 62,821 | 13 | 125,642 |
No | output | 1 | 62,821 | 13 | 125,643 |
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 acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels t... | instruction | 0 | 62,822 | 13 | 125,644 |
No | output | 1 | 62,822 | 13 | 125,645 |
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 acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels t... | instruction | 0 | 62,823 | 13 | 125,646 |
No | output | 1 | 62,823 | 13 | 125,647 |
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 acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels t... | instruction | 0 | 62,824 | 13 | 125,648 |
No | output | 1 | 62,824 | 13 | 125,649 |
Provide a correct Python 3 solution for this coding contest problem.
There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.
Snuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T. (There are 2^{N - 1} differ... | instruction | 0 | 62,998 | 13 | 125,996 |
"Correct Solution:
```
# doc: git.io/vy4co
def graph(inp):
nodes = dict()
N = None
for line in inp.splitlines():
if N is None:
N = int(line.strip())
for k in range(1, N + 1):
nodes[k] = set()
continue
i, k = map(int, line.split())
n... | output | 1 | 62,998 | 13 | 125,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.
Snuke is constructing a directed graph T' by arbitrarily assigning ... | instruction | 0 | 62,999 | 13 | 125,998 |
No | output | 1 | 62,999 | 13 | 125,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.
Snuke is constructing a directed graph T' by arbitrarily assigning ... | instruction | 0 | 63,000 | 13 | 126,000 |
No | output | 1 | 63,000 | 13 | 126,001 |
Provide a correct Python 3 solution for this coding contest problem.
C: Namo .. Cut
problem
-Defeat the mysterious giant jellyfish, codenamed "Nari"-
"Nari" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making trial and error every day to find out ... | instruction | 0 | 63,113 | 13 | 126,226 |
"Correct Solution:
```
import copy ; import sys ;input = sys.stdin.readline; sys.setrecursionlimit(11451419);from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n):
a,b=map(int,input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
seen=[0 for i in range(n)]
hist=deque([]... | output | 1 | 63,113 | 13 | 126,227 |
Provide a correct Python 3 solution for this coding contest problem.
C: Namo .. Cut
problem
-Defeat the mysterious giant jellyfish, codenamed "Nari"-
"Nari" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making trial and error every day to find out ... | instruction | 0 | 63,114 | 13 | 126,228 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque
def dfs(v, p):
global pos
seen[v] = True
hist.append(v)
for nv in adj_list[v]:
if nv==p:
continue
if seen[nv]:
pos = nv
... | output | 1 | 63,114 | 13 | 126,229 |
Provide a correct Python 3 solution for this coding contest problem.
C: Namo .. Cut
problem
-Defeat the mysterious giant jellyfish, codenamed "Nari"-
"Nari" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making trial and error every day to find out ... | instruction | 0 | 63,115 | 13 | 126,230 |
"Correct Solution:
```
#=============================================================================
# サイクル検出 AOJ2891の解答例
#=============================================================================
import queue
N=int(input())
Graph=[[] for _ in range(N)]
deg=[0 for _ in range(N)]
que=queue.Queue()
circle=[True for... | output | 1 | 63,115 | 13 | 126,231 |
Provide a correct Python 3 solution for this coding contest problem.
C: Namo .. Cut
problem
-Defeat the mysterious giant jellyfish, codenamed "Nari"-
"Nari" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making trial and error every day to find out ... | instruction | 0 | 63,116 | 13 | 126,232 |
"Correct Solution:
```
# サイクル検出
import sys
sys.setrecursionlimit(10**7)
def dfs(G, v, p):
global pos
seen[v] = True
hist.append(v)
for nv in G[v]:
# 逆流を禁止する
if nv == p:
continue
# 完全終了した頂点はスルー
if finished[nv]:
continue
# サイクルを検出
... | output | 1 | 63,116 | 13 | 126,233 |
Provide a correct Python 3 solution for this coding contest problem.
C: Namo .. Cut
problem
-Defeat the mysterious giant jellyfish, codenamed "Nari"-
"Nari" has a very strong vitality, so if you don't keep cutting quickly, it will be revived in a blink of an eye. We are making trial and error every day to find out ... | instruction | 0 | 63,117 | 13 | 126,234 |
"Correct Solution:
```
# https://onlinejudge.u-aizu.ac.jp/beta/room.html#ACPC2018Day3/problems/C
import collections
n = int(input().rstrip())
g = [[] for i in range(n)]
deg = [0 for i in range(n)]
for i in range(n):
u, v = map(lambda x: x-1, map(int, input().rstrip().split(' ')))
g[u].append(v)
g[v].ap... | output | 1 | 63,117 | 13 | 126,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,152 | 13 | 126,304 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
input=sys.stdin.readline
n=int(input())
stack=[]
children=[]
for i in range(n):
children.append([])
parent=[-1]*n
nodes=[-1]*n
inputs=[]
functions=[-1]*n
for i in range(n):
a=list(map(str,input().split()))
r=a[0]
if r=='IN':
... | output | 1 | 63,152 | 13 | 126,305 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,153 | 13 | 126,306 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
n=int(input())
f={'AND':(lambda a,b:a&b),'OR':(lambda a,b:a|b),'XOR':(lambda a,b:a^b),'NOT':(lambda a:a^1)}
g={'0':(lambda:0),'1':(lambda:1)}
d=[(g[v[0]],[]) if o=='IN' else (f[o],[int(a)-1 for a in v]) for o,*v in map(str.split,sys.s... | output | 1 | 63,153 | 13 | 126,307 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,154 | 13 | 126,308 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
n = int(input())
g = {
'A': lambda a, b: v[a] & v[b],
'O': lambda a, b: v[a] | v[b],
'X': lambda a, b: v[a] ^ v[b],
'N': lambda a: v[a] ^ 1,
'I': lambda a: a + 1
}
def f(q):
q = q.split()
return q.pop(0)[0]... | output | 1 | 63,154 | 13 | 126,309 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,155 | 13 | 126,310 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
n=int(input())
f={'AND':(lambda a,b:a&b),'OR':(lambda a,b:a|b),'XOR':(lambda a,b:a^b),'NOT':(lambda a:a^1)}
g={'0':(lambda:0),'1':(lambda:1)}
d=[(g[v[0]],[]) if o=='IN' else (f[o],[int(a)-1 for a in v]) for o,*v in map(str.split,sys.s... | output | 1 | 63,155 | 13 | 126,311 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,156 | 13 | 126,312 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
n=int(input())
f={'AND':(lambda a,b:a&b),'OR':(lambda a,b:a|b),'XOR':(lambda a,b:a^b),'NOT':(lambda a:a^1)}
g={'0':(lambda:0),'1':(lambda:1)}
d=[(g[v[0]],[]) if o=='IN' else (f[o],[int(a)-1 for a in v]) for o,*v in map(str.split,sys.s... | output | 1 | 63,156 | 13 | 126,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,157 | 13 | 126,314 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
# https://codeforces.com/problemset/problem/1010/D
# TLE
import sys
input=sys.stdin.readline
def handle(type_, val_, u, g, S):
if type_ == 'NOT':
S.append(g[u][0])
else:
v1, v2 = g[u]
val1, val2 = Val[v1],... | output | 1 | 63,157 | 13 | 126,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,158 | 13 | 126,316 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
import sys
n=int(input())
f={
'AND':(lambda a:a[0]&a[1]),
'OR':(lambda a:a[0]|a[1]),
'XOR':(lambda a:a[0]^a[1]),
'NOT':(lambda a:a[0]^1),
}
g={'0':(lambda a:0), '1':(lambda a:1)}
d=[(g[v[0]],[]) if o=='IN' else (f[o],[int(a)-1 for a in v]) f... | output | 1 | 63,158 | 13 | 126,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is... | instruction | 0 | 63,159 | 13 | 126,318 |
Tags: dfs and similar, graphs, implementation, trees
Correct Solution:
```
AND = "AND"
OR = "OR"
XOR = "XOR"
NOT = "NOT"
IN = "IN"
OPS = {
AND: AND,
OR: OR,
XOR: XOR,
NOT: NOT,
}
class Node:
def __init__(self, num):
self.num = num
self.op = None
self.parent = None
... | output | 1 | 63,159 | 13 | 126,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the ve... | instruction | 0 | 63,160 | 13 | 126,320 |
Yes | output | 1 | 63,160 | 13 | 126,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the ve... | instruction | 0 | 63,161 | 13 | 126,322 |
No | output | 1 | 63,161 | 13 | 126,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the ve... | instruction | 0 | 63,162 | 13 | 126,324 |
No | output | 1 | 63,162 | 13 | 126,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the ve... | instruction | 0 | 63,163 | 13 | 126,326 |
No | output | 1 | 63,163 | 13 | 126,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the ve... | instruction | 0 | 63,164 | 13 | 126,328 |
No | output | 1 | 63,164 | 13 | 126,329 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Once upon a time there was only one router in the well-known company Bmail. Years went by and over time new routers were purchased. Every time they bought a new router, they connected it to one of the routers bought before it. You are given ... | instruction | 0 | 63,170 | 13 | 126,340 |
Tags: *special, dfs and similar, trees
Correct Solution:
```
def bfs(start,end,g):
vis = {start:-1}
q = [start]
found = False
while q and not found:
curr = q.pop(0)
if curr == end:
break
for v in g[curr]:
if v not in vis:
vis[v] = curr
... | output | 1 | 63,170 | 13 | 126,341 |
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, the root of the tree is the vertex 1. Each vertex has some non-negative price. A leaf of the tree is a non-root vertex that has degree 1.
Arkady and... | instruction | 0 | 63,187 | 13 | 126,374 |
No | output | 1 | 63,187 | 13 | 126,375 |
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, the root of the tree is the vertex 1. Each vertex has some non-negative price. A leaf of the tree is a non-root vertex that has degree 1.
Arkady and... | instruction | 0 | 63,188 | 13 | 126,376 |
No | output | 1 | 63,188 | 13 | 126,377 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.