message stringlengths 2 22.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 16 109k | cluster float64 1 1 | __index_level_0__ int64 32 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 92,999 | 1 | 185,998 |
Yes | output | 1 | 92,999 | 1 | 185,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,000 | 1 | 186,000 |
Yes | output | 1 | 93,000 | 1 | 186,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,001 | 1 | 186,002 |
Yes | output | 1 | 93,001 | 1 | 186,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,002 | 1 | 186,004 |
Yes | output | 1 | 93,002 | 1 | 186,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,003 | 1 | 186,006 |
No | output | 1 | 93,003 | 1 | 186,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,004 | 1 | 186,008 |
No | output | 1 | 93,004 | 1 | 186,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,005 | 1 | 186,010 |
No | output | 1 | 93,005 | 1 | 186,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from... | instruction | 0 | 93,006 | 1 | 186,012 |
No | output | 1 | 93,006 | 1 | 186,013 |
Provide tags and a correct Python 2 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,235 | 1 | 186,470 |
Tags: dfs and similar, graphs, greedy
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(s... | output | 1 | 93,235 | 1 | 186,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,236 | 1 | 186,472 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)
n, m, s = map(int, input().split())
s = s - 1
def read_graph():
g = defaultdict(list)
for _ in range(m):
(u, v) = map(lambda x: int(x) - 1, input().split())
... | output | 1 | 93,236 | 1 | 186,473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,237 | 1 | 186,474 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
import sys
n, m, s = map(int, input().split())
adj = [[] for _ in range(500005)]
ar = []
vis = [0] * 500005
sys.setrecursionlimit(6000)
def dfs(s):
vis[s] = 1
for i in range(len(adj[s])):
if(vis[adj[s][i]] == 0):
dfs(adj[s][i])
... | output | 1 | 93,237 | 1 | 186,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,238 | 1 | 186,476 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
from __future__ import print_function
from queue import Queue
from random import shuffle
import sys
import math
import os.path
sys.setrecursionlimit(100000)
# LOG
def log(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
# INPUT
def ni():
... | output | 1 | 93,238 | 1 | 186,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,239 | 1 | 186,478 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
import sys
sys.setrecursionlimit(10**4)
from collections import deque
n, m, s = map(int, input().split())
s -= 1
graph = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
graph[u-1].append(v-1)
seen = [False]*n
li = deque()
def... | output | 1 | 93,239 | 1 | 186,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,240 | 1 | 186,480 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
from collections import defaultdict
import sys
def dfs(u):
avail[u] = False
for v in g[u]:
if avail[v]:
dfs(v)
topo.append(u)
sys.setrecursionlimit(6000)
n, m, s = map(int, input().split())
g = [[] for _ in range(n)]
for _ in ... | output | 1 | 93,240 | 1 | 186,481 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,241 | 1 | 186,482 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
def main():
import sys
sys.setrecursionlimit(10**5)
from collections import deque
n, m, s = map(int, input().split())
s -= 1
graph = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
graph[u-... | output | 1 | 93,241 | 1 | 186,483 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,242 | 1 | 186,484 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
import sys
input = sys.stdin.readline
n, m, s = map(int, input().split())
s -= 1
adj = [[] for _ in range(n)]
rev = [[] for _ in range(n)]
for u, v in (map(int, input().split()) for _ in range(m)):
adj[u-1].append(v-1)
rev[v-1].append(u-1)
group = [... | output | 1 | 93,242 | 1 | 186,485 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?
New roads wi... | instruction | 0 | 93,243 | 1 | 186,486 |
Tags: dfs and similar, graphs, greedy
Correct Solution:
```
import sys
sys.setrecursionlimit(100001)
from collections import *
d=deque()
def dfs2(start):
vis[start]=1
for child in adj[start]:
if vis[child]==0:
dfs2(child)
def dfs(start):
vis[start]=1
for child in adj[start]:
... | output | 1 | 93,243 | 1 | 186,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,244 | 1 | 186,488 |
Yes | output | 1 | 93,244 | 1 | 186,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,245 | 1 | 186,490 |
Yes | output | 1 | 93,245 | 1 | 186,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,246 | 1 | 186,492 |
Yes | output | 1 | 93,246 | 1 | 186,493 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,247 | 1 | 186,494 |
Yes | output | 1 | 93,247 | 1 | 186,495 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,248 | 1 | 186,496 |
No | output | 1 | 93,248 | 1 | 186,497 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,249 | 1 | 186,498 |
No | output | 1 | 93,249 | 1 | 186,499 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,250 | 1 | 186,500 |
No | output | 1 | 93,250 | 1 | 186,501 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n cities and m roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.
What is the minimum number of new roads that need to be built to make all the c... | instruction | 0 | 93,251 | 1 | 186,502 |
No | output | 1 | 93,251 | 1 | 186,503 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,252 | 1 | 186,504 |
"Correct Solution:
```
class UnionFind:
def __init__(self, n):
self.g = [i for i in range(n)]
self.n = n
def whichclass(self, x):
if self.g[x]==x:
return x
else:
self.g[x] = self.whichclass(self.g[x])
return self.g[x]
def union(self, x, y):
cx = self.whichclass(x)
cy = se... | output | 1 | 93,252 | 1 | 186,505 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,253 | 1 | 186,506 |
"Correct Solution:
```
N, M = map(int, input().split())
F = [[] for _ in range(N)]
P = [0] * N
for i in range(M):
A, B = map(int, input().split())
F[A-1].append(B-1)
F[B-1].append(A-1)
c=0
l = []
for i in range(N):
if P[i] == 0:
c+=1
l.append(i)
while len(l)>0:
p=l.po... | output | 1 | 93,253 | 1 | 186,507 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,254 | 1 | 186,508 |
"Correct Solution:
```
N,M=map(int,input().split())
road=[[] for _ in range(N)]
for i in range(M):
a,b=map(int,input().split())
road[a-1].append(b-1)
road[b-1].append(a-1)
ischecked=[0]*(N)
ans=0
for i in range(N):
if ischecked[i]==1:
continue
ischecked[i]=1
q=[i]
while q:
no... | output | 1 | 93,254 | 1 | 186,509 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,255 | 1 | 186,510 |
"Correct Solution:
```
N, M = map(int, input().split())
cla = [i for i in range(N)]
count = set()
def root(a):
change = []
while cla[a] != a:
change.append(a)
a = cla[a]
for i in change:
cla[i] = a
return a
for _ in range(M):
a, b = map(int, input().split())
a -= 1
b ... | output | 1 | 93,255 | 1 | 186,511 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,256 | 1 | 186,512 |
"Correct Solution:
```
N, M = map(int, input().split())
P = [-1 for i in range(N)]
def par(a):
L = []
while P[a] >= 0:
L.append(a)
a = P[a]
for l in L:
P[l] = a
return a
def unite(a, b):
if par(a) != par(b):
if P[par(b)] >= P[par(a)]:
if P[par(b)] == P[par... | output | 1 | 93,256 | 1 | 186,513 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,257 | 1 | 186,514 |
"Correct Solution:
```
N,M = map(int,input().split())
par = [0]+[-1 for i in range(N)]
def find(x):
if par[x] == -1:
return x
else:
par[x] = find(par[x]) #็ต่ทฏๅง็ธฎ
return par[x]
def same(x,y):
return find(x) == find(y)
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
... | output | 1 | 93,257 | 1 | 186,515 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,258 | 1 | 186,516 |
"Correct Solution:
```
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
def unite(x,y):
if same(x,y)==False:
rx=root(x);ry=root(y)
if rank[rx]>rank[ry]:
parent[ry]=rx
size[rx]+=size[ry]
else:
parent[rx]=ry
size[ry]+=size[rx]
if rank[rx]==rank[ry]:
rank[ry]+=1
def root(x):
if x... | output | 1 | 93,258 | 1 | 186,517 |
Provide a correct Python 3 solution for this coding contest problem.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* Choose two distinct cities that are not directly connect... | instruction | 0 | 93,259 | 1 | 186,518 |
"Correct Solution:
```
import sys
class UnionFind():
def __init__(self, n):
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x,... | output | 1 | 93,259 | 1 | 186,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,260 | 1 | 186,520 |
Yes | output | 1 | 93,260 | 1 | 186,521 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,261 | 1 | 186,522 |
Yes | output | 1 | 93,261 | 1 | 186,523 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,262 | 1 | 186,524 |
Yes | output | 1 | 93,262 | 1 | 186,525 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,263 | 1 | 186,526 |
Yes | output | 1 | 93,263 | 1 | 186,527 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,264 | 1 | 186,528 |
No | output | 1 | 93,264 | 1 | 186,529 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,265 | 1 | 186,530 |
No | output | 1 | 93,265 | 1 | 186,531 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,266 | 1 | 186,532 |
No | output | 1 | 93,266 | 1 | 186,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.
Snuke can perform the following operation zero or more times:
* ... | instruction | 0 | 93,267 | 1 | 186,534 |
No | output | 1 | 93,267 | 1 | 186,535 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,391 | 1 | 186,782 |
"Correct Solution:
```
import sys,heapq
from collections import defaultdict,deque
input = sys.stdin.readline
n,m = map(int,input().split())
#+่ทฏ็ท*chg : ใใฎ่ทฏ็ทใใผใ
chg = 10**6
edge=defaultdict(set)
used =defaultdict(bool)
for i in range(m):
p,q,c = map(int,input().split())
edge[p].add(p+c*chg)
edge[p+c*chg].ad... | output | 1 | 93,391 | 1 | 186,783 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,392 | 1 | 186,784 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
from collections import defaultdict
"""
(้ง
ใไผ็คพ)ใ้ ็นใซใฐใฉใใๆใคใ้ ็นๆฐO(M)ใ
ใใฎใพใพ่พบใ่ฒผใใจ่พบใๅคใใชใใใใใ
(้ง
ใไผ็คพ) -> (้ง
ใ็กๅฑๆง) -> (้ง
ใไผ็คพ)
"""
L = 32
mask = (1 << L) - 1
N,M = map(int,input().split())
graph = defaultdict(list)
for _ in range(M):
p,q,c = map(int,input().split())... | output | 1 | 93,392 | 1 | 186,785 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,393 | 1 | 186,786 |
"Correct Solution:
```
import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
de... | output | 1 | 93,393 | 1 | 186,787 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,394 | 1 | 186,788 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_repla... | output | 1 | 93,394 | 1 | 186,789 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,395 | 1 | 186,790 |
"Correct Solution:
```
from collections import deque,defaultdict
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
mod =10**7
table=defaultdict(set)
visit=defaultdict(int)
for i in range(M):
a,b,c=map(int,input().split())
table[a].add(a+c*mod)
table[b].add(b+c*mod)
table[a+c*mod].add(a)... | output | 1 | 93,395 | 1 | 186,791 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,396 | 1 | 186,792 |
"Correct Solution:
```
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read
n,m = map(int, readline().split())
g = {}
for _ in range(m):
p,q,c = map(int, readline().split())
pc = ((p-1)<<20)+c
qc = ((q-1)<<20)+c
pp = (p-1)<<20
qq = (q-1)<<20
if... | output | 1 | 93,396 | 1 | 186,793 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,397 | 1 | 186,794 |
"Correct Solution:
```
import sys
from collections import deque, defaultdict
def bfs01(s, t, links):
q = deque([(0, s, -1)]) # cost, station, last-company
visited = set()
while q:
d, v, e = q.popleft()
if v == t:
return d
if (v, e) in visited:
continue
... | output | 1 | 93,397 | 1 | 186,795 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification number.
The i-th ( 1 \leq i \leq M ) line connects station ... | instruction | 0 | 93,398 | 1 | 186,796 |
"Correct Solution:
```
from collections import defaultdict,deque
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
N,M=map(int,input().split())
if M==0:
print(-1)
exit()
G=defaultdict(set)
for i in range(M):
a,b,c=map(int,input().split())
G[a+(c<<30)].add(b+(c<<30))
G[b+(c<<30)].add(a+(c<<30))
... | output | 1 | 93,398 | 1 | 186,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke's town has a subway system, consisting of N stations and M railway lines. The stations are numbered 1 through N. Each line is operated by a company. Each company has an identification numb... | instruction | 0 | 93,399 | 1 | 186,798 |
Yes | output | 1 | 93,399 | 1 | 186,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.