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 |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,156 | 1 | 86,312 |
Tags: dp
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
... | output | 1 | 43,156 | 1 | 86,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,157 | 1 | 86,314 |
Tags: dp
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.... | output | 1 | 43,157 | 1 | 86,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,158 | 1 | 86,316 |
Tags: dp
Correct Solution:
```
import sys
input = sys.stdin.readline
r, n = [int(i) for i in input().split()]
m = 2*r
cs = []
for _ in range(n):
c = tuple(int(i) for i in input().split())
if c[1]+c[2]-2 <= c[0]:
cs.append(c)
if cs:
ans = [-1]*n
k = 0
best = 0
best2 = 0
for i in range(len(cs)):
while cs[k]... | output | 1 | 43,158 | 1 | 86,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,159 | 1 | 86,318 |
Tags: dp
Correct Solution:
```
import os, sys, atexit
from io import BytesIO
sys.stdout = BytesIO()
_write = sys.stdout.write
sys.stdout.write = lambda s: _write(s.encode())
atexit.register(lambda: os.write(1, sys.stdout.getvalue()))
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
r, n = map(int, input().sp... | output | 1 | 43,159 | 1 | 86,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,160 | 1 | 86,320 |
Tags: dp
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.... | output | 1 | 43,160 | 1 | 86,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,161 | 1 | 86,322 |
Tags: dp
Correct Solution:
```
import sys
from io import BytesIO, IOBase
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
... | output | 1 | 43,161 | 1 | 86,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,162 | 1 | 86,324 |
Tags: dp
Correct Solution:
```
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
"""
def solveBrute(R, N, T, X, Y):
inf = float("inf")
TXY = list(zip(T, X, Y))
assert TXY[0] == (0, 1, 1)
dp = [-inf for i in range(N + 1)] # longest ending at the ith coord
dp[0] = 0
... | output | 1 | 43,162 | 1 | 86,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r in order from south to north. Each of the r so... | instruction | 0 | 43,163 | 1 | 86,326 |
Tags: dp
Correct Solution:
```
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
import os
self.os = os
self._fd = file.fileno()
self.buffer = BytesIO()
self.... | output | 1 | 43,163 | 1 | 86,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,164 | 1 | 86,328 |
Yes | output | 1 | 43,164 | 1 | 86,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,165 | 1 | 86,330 |
Yes | output | 1 | 43,165 | 1 | 86,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,166 | 1 | 86,332 |
Yes | output | 1 | 43,166 | 1 | 86,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,167 | 1 | 86,334 |
Yes | output | 1 | 43,167 | 1 | 86,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,168 | 1 | 86,336 |
No | output | 1 | 43,168 | 1 | 86,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,169 | 1 | 86,338 |
No | output | 1 | 43,169 | 1 | 86,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,170 | 1 | 86,340 |
No | output | 1 | 43,170 | 1 | 86,341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are a paparazzi working in Manhattan.
Manhattan has r south-to-north streets, denoted by numbers 1, 2,…, r in order from west to east, and r west-to-east streets, denoted by numbers 1,2,…,r... | instruction | 0 | 43,171 | 1 | 86,342 |
No | output | 1 | 43,171 | 1 | 86,343 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,746 | 1 | 87,492 |
"Correct Solution:
```
import bisect
while 1:
n,m = map(int, input().split())
if n == m == 0:
break
h = [int(input()) for i in range(n)]
w = [int(input()) for j in range(m)]
for i in range(n-1):
h[i+1] += h[i]
for i in range(m-1):
w[i+1] += w[i]
h.insert(0,0)
w.i... | output | 1 | 43,746 | 1 | 87,493 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,747 | 1 | 87,494 |
"Correct Solution:
```
import sys
def main():
while True:
n,m = map(int, sys.stdin.readline().split())
if n == 0 and m == 0:
break
# input
hs = []
for i in range(n):
h = int(sys.stdin.readline())
hs.append(h)
ws = []
... | output | 1 | 43,747 | 1 | 87,495 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,748 | 1 | 87,496 |
"Correct Solution:
```
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().... | output | 1 | 43,748 | 1 | 87,497 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,749 | 1 | 87,498 |
"Correct Solution:
```
N=[int(i) for i in input().split()]
while N[0]!=0 or N[1]!=0:
h=[]
for i in range(2):
h.append([])
# print(N)
for j in range(N[i]):
h[i].append(int(input()))
# print(h)
s=0
for j in range(N[i]-1):
s=h[i][j]
# ... | output | 1 | 43,749 | 1 | 87,499 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,750 | 1 | 87,500 |
"Correct Solution:
```
from collections import Counter
while True:
N, M = map(int, input().split())
if N == 0 and M == 0:
break
H = [int(input()) for _ in range(N)]
W = [int(input()) for _ in range(M)]
all_H = []
for i in range(N):
s = 0
for j in range(i, N):
... | output | 1 | 43,750 | 1 | 87,501 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,751 | 1 | 87,502 |
"Correct Solution:
```
from collections import Counter
def main():
while True:
n, m = map(int, input().split())
if n == 0:
break
tmp = [0]
h_lst = []
for _ in range(n):
h = int(input())
new = [i + h for i in tmp]
h_lst.extend(new)
tmp = [0] + new
tmp = [0... | output | 1 | 43,751 | 1 | 87,503 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,752 | 1 | 87,504 |
"Correct Solution:
```
while True:
n,m = map(int, input().split())
if n == 0 and m == 0:
break
nlist = [0]
mlist = [0]
for i in range(n):
nlist += [nlist[-1] + int(input())]
for i in range(m):
mlist += [mlist[-1] + int(input())]
l = [0for i in range(1000*1501)]
f... | output | 1 | 43,752 | 1 | 87,505 |
Provide a correct Python 3 solution for this coding contest problem.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person w... | instruction | 0 | 43,753 | 1 | 87,506 |
"Correct Solution:
```
#演習2-16
from bisect import bisect_left, bisect_right #二分探索
from collections import Counter
def how_many(a, x):
# リストaのなかでxが何個あるのかを返す関数
return bisect_right(a, x) - bisect_left(a, x)
def solve(n, m):
# とく関数
a = [int(input()) for _ in range(n)]
b = [int(input()) for _ in rang... | output | 1 | 43,753 | 1 | 87,507 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,754 | 1 | 87,508 |
Yes | output | 1 | 43,754 | 1 | 87,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,755 | 1 | 87,510 |
Yes | output | 1 | 43,755 | 1 | 87,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,756 | 1 | 87,512 |
Yes | output | 1 | 43,756 | 1 | 87,513 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,757 | 1 | 87,514 |
Yes | output | 1 | 43,757 | 1 | 87,515 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,758 | 1 | 87,516 |
No | output | 1 | 43,758 | 1 | 87,517 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,759 | 1 | 87,518 |
No | output | 1 | 43,759 | 1 | 87,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,760 | 1 | 87,520 |
No | output | 1 | 43,760 | 1 | 87,521 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Square Route
Square root
English text is not available in this practice contest.
Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansi... | instruction | 0 | 43,761 | 1 | 87,522 |
No | output | 1 | 43,761 | 1 | 87,523 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Once Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x... | instruction | 0 | 44,301 | 1 | 88,602 |
No | output | 1 | 44,301 | 1 | 88,603 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Once Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x... | instruction | 0 | 44,302 | 1 | 88,604 |
No | output | 1 | 44,302 | 1 | 88,605 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Once Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x... | instruction | 0 | 44,303 | 1 | 88,606 |
No | output | 1 | 44,303 | 1 | 88,607 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Once Danil the student was returning home from tram stop lately by straight road of length L. The stop is located at the point x = 0, but the Danil's home — at the point x = L. Danil goes from x... | instruction | 0 | 44,304 | 1 | 88,608 |
No | output | 1 | 44,304 | 1 | 88,609 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you can reach any city from any other using these roads. Each ... | instruction | 0 | 44,321 | 1 | 88,642 |
No | output | 1 | 44,321 | 1 | 88,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mahmoud and Ehab live in a country with n cities numbered from 1 to n and connected by n - 1 undirected roads. It's guaranteed that you can reach any city from any other using these roads. Each ... | instruction | 0 | 44,322 | 1 | 88,644 |
No | output | 1 | 44,322 | 1 | 88,645 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are n junctions and m two way roads, at which one can get from each junction to any other one. The mayor wants to close s... | instruction | 0 | 44,953 | 1 | 89,906 |
Tags: bitmasks, dp
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m, k = map(int, input().split())
adj = [[] for _ in range(n)]
dp = [[0] * (1 << n) for _ in range(1 << n)]
for u, v in (map(int, input().split()) for _ in... | output | 1 | 44,953 | 1 | 89,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky a... | instruction | 0 | 45,141 | 1 | 90,282 |
No | output | 1 | 45,141 | 1 | 90,283 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky a... | instruction | 0 | 45,142 | 1 | 90,284 |
No | output | 1 | 45,142 | 1 | 90,285 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.
Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between... | instruction | 0 | 45,749 | 1 | 91,498 |
Tags: dfs and similar
Correct Solution:
```
def main():
n, m = map(int, input().split())
n += 1
cluster, dest, ab = list(range(n)), [0] * n, [[] for _ in range(n)]
def root(x):
if x != cluster[x]:
cluster[x] = x = root(cluster[x])
return x
for _ in range(m):
a, ... | output | 1 | 45,749 | 1 | 91,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,769 | 1 | 91,538 |
Tags: graphs, shortest paths
Correct Solution:
```
n, m = map(int, input().split())
rail = [ [ False for v in range(n) ] for u in range(n) ]
road = [ [ True for v in range(n) ] for u in range(n) ]
for i in range(m):
u, v = map(lambda x: x - 1, map(int, input().split()))
rail[u][v] = rail[v][u] = True
road[u... | output | 1 | 45,769 | 1 | 91,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,770 | 1 | 91,540 |
Tags: graphs, shortest paths
Correct Solution:
```
from queue import Queue
def solve( net1 , net2 , n ):
# for net1
res = [400*400]*n
visited = [False]*n
q = Queue(400*400)
q.put( (0,0) )
visited[0] = True
res[0] = 0
while not q.empty():
town , t = q.get()
for next_tow... | output | 1 | 45,770 | 1 | 91,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,771 | 1 | 91,542 |
Tags: graphs, shortest paths
Correct Solution:
```
# import sys
# sys.stdin = open('cf602c.in')
from collections import deque
n, m = map(int, input().split())
g_trn = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
g_trn[u - 1].append(v - 1)
g_trn[v - 1].append(u - 1)
g_bus = [list(set... | output | 1 | 45,771 | 1 | 91,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,772 | 1 | 91,544 |
Tags: graphs, shortest paths
Correct Solution:
```
n,m=map(int,input().split())
L=[[] for i in range(n+1)]
for i in range(m) :
a,b=map(int,input().split())
L[a].append(b)
L[b].append(a)
if n not in L[1] :
l=[1]
D=[-1 for i in range(n+1)]
D[1]=0
while len(l)>=1 :
t=l[0]
del(l[... | output | 1 | 45,772 | 1 | 91,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,773 | 1 | 91,546 |
Tags: graphs, shortest paths
Correct Solution:
```
#created by Кама Пуля
n,m=map(int,input().split())
L=[[] for i in range(n+1)]
for i in range(m) :
a,b=map(int,input().split())
L[a].append(b)
L[b].append(a)
if n not in L[1] :
l=[1]
D=[-1 for i in range(n+1)]
D[1]=0
while len(l)>=1 :
... | output | 1 | 45,773 | 1 | 91,547 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,774 | 1 | 91,548 |
Tags: graphs, shortest paths
Correct Solution:
```
# Two routes
from collections import defaultdict
from collections import deque
import sys
def bfs(graph,node,inverted,target):
q = deque()
q.append(node)
distance = {}
distance[node]=0
while len(q)>0:
current_node = q.popleft()
if inverted:
... | output | 1 | 45,774 | 1 | 91,549 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,775 | 1 | 91,550 |
Tags: graphs, shortest paths
Correct Solution:
```
from heapq import *
n,m = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(m)]
G = [[] for _ in range(n)]
R = [[] for _ in range(n)]
for k in range(m):
G[L[k][0]-1] += [L[k][1]-1]
G[L[k][1]-1] += [L[k][0]-1]
for i in range(n-1):
... | output | 1 | 45,775 | 1 | 91,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only ... | instruction | 0 | 45,776 | 1 | 91,552 |
Tags: graphs, shortest paths
Correct Solution:
```
from collections import deque as dq
import heapq as hq
class Graph:
def __init__(self,n=0):
# n : vertices
# m : edges
self.nv=n
self.g=[[] for i in range(n)]
#self.vis=[False for i in range(n)]
def readUdU... | output | 1 | 45,776 | 1 | 91,553 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.