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.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circul... | instruction | 0 | 72,540 | 1 | 145,080 |
Tags: brute force, greedy
Correct Solution:
```
from collections import defaultdict as dd, deque
n,m = map(int,input().split())
S = dd(list)
for _ in range(m):
start,dest = map(int,input().split())
S[start-1].append(dest-1)
closest = [0]*n
for i in range(n):
if S[i]:
closest[i] = min((j-i)%n for... | output | 1 | 72,540 | 1 | 145,081 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circul... | instruction | 0 | 72,541 | 1 | 145,082 |
Tags: brute force, greedy
Correct Solution:
```
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())
n,m=mii()
a=[0 for _ in range(n)]
c=[123456 for _ in range(n)]
for _ in range(m):
u,v=mii()
u%=n
v%=n
if v<u: v+=n
a[u]+=1
if c[u]>v: c[u]=v
ans=... | output | 1 | 72,541 | 1 | 145,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circul... | instruction | 0 | 72,542 | 1 | 145,084 |
Tags: brute force, greedy
Correct Solution:
```
n,m=map(int,input().split())
minima=[float("inf") for i in range(n+1)]
counted=[-1 for i in range(n+1)]
stored=[0 for i in range(n+1)]
for i in range(m):
curr,des=map(int,input().split())
curr-=1
des-=1
minima[curr] =min(minima[curr],(des -curr) % n)
c... | output | 1 | 72,542 | 1 | 145,085 |
Provide tags and a correct Python 2 solution for this coding contest problem.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and travels around the network of stations in a circul... | instruction | 0 | 72,543 | 1 | 145,086 |
Tags: brute force, 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_num():
return int(raw_input())
def in_arr():
return map(int,raw_input().split())
d... | output | 1 | 72,543 | 1 | 145,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and tra... | instruction | 0 | 72,544 | 1 | 145,088 |
Yes | output | 1 | 72,544 | 1 | 145,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and tra... | instruction | 0 | 72,545 | 1 | 145,090 |
No | output | 1 | 72,545 | 1 | 145,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and tra... | instruction | 0 | 72,546 | 1 | 145,092 |
No | output | 1 | 72,546 | 1 | 145,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and tra... | instruction | 0 | 72,547 | 1 | 145,094 |
No | output | 1 | 72,547 | 1 | 145,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of n stations, enumerated from 1 through n. The train occupies one station at a time and tra... | instruction | 0 | 72,548 | 1 | 145,096 |
No | output | 1 | 72,548 | 1 | 145,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,803 | 1 | 145,606 |
Tags: dsu, graphs, trees
Correct Solution:
```
n = int(input())
parent = list(range(n + 1))
def find(i):
while i != parent[i]:
i = parent[i]
return i
to_delete = []
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a_id = find(a)
b_id = find(b)
if a_id == b_id:
to... | output | 1 | 72,803 | 1 | 145,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,804 | 1 | 145,608 |
Tags: dsu, graphs, trees
Correct Solution:
```
class Graph:
def __init__(self,n):
self.rank=[1]*(n+1)
self.parent=[0]+[i for i in range(1,n+1)]
def find(self,a):
if self.parent[a]==a:
return a
if self.parent[a]!=a:
self.parent[a]=self.find(self.parent... | output | 1 | 72,804 | 1 | 145,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,805 | 1 | 145,610 |
Tags: dsu, graphs, trees
Correct Solution:
```
class DSU:
nodes = []
duplicates = []
def __init__(self,n):
self.nodes = [[0,0] for i in range(n)]
def find(self,x):
return self.nodes[x]
def union(self,x,y):
xRoot,yRoot = self.find(x),self.find(y)
if xRoot[0] == yRoot[0]:
self.duplicates.append([x,y])
... | output | 1 | 72,805 | 1 | 145,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,806 | 1 | 145,612 |
Tags: dsu, graphs, trees
Correct Solution:
```
def main():
from random import getrandbits
def find_set(v):
if v == parent[v]: return v
parent[v] = find_set(parent[v])
return parent[v]
def unite(a, b):
a, b = find_set(a), find_set(b)
if a == b: return False
... | output | 1 | 72,806 | 1 | 145,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,807 | 1 | 145,614 |
Tags: dsu, graphs, trees
Correct Solution:
```
def way(v):
if vertices[v] == v:
return v
else:
vertices[v] = way(vertices[v])
return vertices[v]
n = int(input())
vertices = [i for i in range(n + 1)]
useless = []
useful = []
for i in range(n - 1):
a, b = map(int, input().split())
... | output | 1 | 72,807 | 1 | 145,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,808 | 1 | 145,616 |
Tags: dsu, graphs, trees
Correct Solution:
```
#import math
#from functools import lru_cache
#import heapq
#from collections import defaultdict
#from collections import Counter
#from sys import stdout
#from sys import setrecursionlimit
from sys import stdin
input = stdin.readline
n = int(input())
parents = list(range(n... | output | 1 | 72,808 | 1 | 145,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,809 | 1 | 145,618 |
Tags: dsu, graphs, trees
Correct Solution:
```
# Author : nitish420 --------------------------------------------------------------------
import os
import sys
from io import BytesIO, IOBase
maxval=1000
rank=[0]*(maxval+1)
parent=[i for i in range(maxval+1)]
def find(x):
if x==parent[x]:
return x
parent[x]=find(p... | output | 1 | 72,809 | 1 | 145,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became possible to reach all the others. There are n c... | instruction | 0 | 72,810 | 1 | 145,620 |
Tags: dsu, graphs, trees
Correct Solution:
```
from sys import stdin, stdout
def find(node):
x = []
while dsu[node] > 0:
x.append(node)
node = dsu[node]
for i in x:
dsu[i] = node
return node
def union(node1, node2):
if dsu[node1] > dsu[node2]:
node1, node2 = node2, ... | output | 1 | 72,810 | 1 | 145,621 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,811 | 1 | 145,622 |
Yes | output | 1 | 72,811 | 1 | 145,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,812 | 1 | 145,624 |
Yes | output | 1 | 72,812 | 1 | 145,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,813 | 1 | 145,626 |
Yes | output | 1 | 72,813 | 1 | 145,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,814 | 1 | 145,628 |
Yes | output | 1 | 72,814 | 1 | 145,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,815 | 1 | 145,630 |
Yes | output | 1 | 72,815 | 1 | 145,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,816 | 1 | 145,632 |
No | output | 1 | 72,816 | 1 | 145,633 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,817 | 1 | 145,634 |
No | output | 1 | 72,817 | 1 | 145,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,818 | 1 | 145,636 |
No | output | 1 | 72,818 | 1 | 145,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,819 | 1 | 145,638 |
No | output | 1 | 72,819 | 1 | 145,639 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
Berland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it became ... | instruction | 0 | 72,820 | 1 | 145,640 |
No | output | 1 | 72,820 | 1 | 145,641 |
Provide a correct Python 3 solution for this coding contest problem.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that star... | instruction | 0 | 73,110 | 1 | 146,220 |
"Correct Solution:
```
import sys
input = sys.stdin.readline
import itertools
N = int(input())
A = [1,2,4]
for _ in range(12):
sum_2 = set(x+y for x,y in itertools.combinations(A,2))
avoid = set(x-y for x,y in itertools.product(sum_2,A))
x = min(set(range(1,1000)) - avoid - sum_2 - set(A))
A.append(x... | output | 1 | 73,110 | 1 | 146,221 |
Provide a correct Python 3 solution for this coding contest problem.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that star... | instruction | 0 | 73,111 | 1 | 146,222 |
"Correct Solution:
```
from itertools import combinations, permutations
N = int(input())
# 整数列の生成
# s = [1]
# while len(s) < 10 :
# i = s[-1] + 1
# while True :
# path = s.copy() + [i]
# flag = True
# for comb in combinations(s + [i], 2) :
# if not sum(comb) in path :
... | output | 1 | 73,111 | 1 | 146,223 |
Provide a correct Python 3 solution for this coding contest problem.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that star... | instruction | 0 | 73,112 | 1 | 146,224 |
"Correct Solution:
```
N = int(input())
s = []
t = []
i = 1
while len(s) < N :
if i in t or any(i + s_ in t for s_ in s) :
i += 1
continue
t.append(i)
for s_ in s :
t.append(i+s_)
s.append(i)
i += 1
w = [[0] * 10 for _ in range(10)]
w[0][1] = w[1][0] = 1
M = 1
fo... | output | 1 | 73,112 | 1 | 146,225 |
Provide a correct Python 3 solution for this coding contest problem.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that star... | instruction | 0 | 73,113 | 1 | 146,226 |
"Correct Solution:
```
def solve(n):
if n == 2:
print('0 1\n1 0')
return
can = []
ban = set()
k = 1
while len(can) < 9:
if k in ban or any(k + l in ban for l in can):
k += 1
continue
ban.add(k)
ban.update(k + l for l in can)
c... | output | 1 | 73,113 | 1 | 146,227 |
Provide a correct Python 3 solution for this coding contest problem.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided.
A Hamiltonian path is a path that star... | instruction | 0 | 73,114 | 1 | 146,228 |
"Correct Solution:
```
from itertools import permutations
import sys
sys.setrecursionlimit(10 ** 6)
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 LI(): return list(map(int, sys.stdin.readline().spli... | output | 1 | 73,114 | 1 | 146,229 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each ro... | instruction | 0 | 73,115 | 1 | 146,230 |
No | output | 1 | 73,115 | 1 | 146,231 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each ro... | instruction | 0 | 73,116 | 1 | 146,232 |
No | output | 1 | 73,116 | 1 | 146,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each ro... | instruction | 0 | 73,117 | 1 | 146,234 |
No | output | 1 | 73,117 | 1 | 146,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N.
The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each ro... | instruction | 0 | 73,118 | 1 | 146,236 |
No | output | 1 | 73,118 | 1 | 146,237 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,211 | 1 | 146,422 |
"Correct Solution:
```
b=[[0,6,10,12,14,27,33],
[6,0,7,9,12,23,30],
[13,7,0,5,8,20,27],
[18,12,5,0,5,17,26],
[23,17,10,5,0,12,23],
[43,37,30,25,20,0,10],
[58,52,45,40,35,15,0]]
while 1:
d=int(input())
if d==0:break
e,f=map(int,input().split())
t=e*60+f
a=int(input())
e,f=map(in... | output | 1 | 73,211 | 1 | 146,423 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,212 | 1 | 146,424 |
"Correct Solution:
```
def answer(price, flag):
if flag == True:
price //= 2
if price % 50 != 0:
price += price % 50
print(price)
else:
print(price)
table = [[0, 300, 500, 600, 700, 1350, 1650], [6, 0, 350, 450, 600, 1150, 1500],
[13, 7, 0, 250, 400, 1000, ... | output | 1 | 73,212 | 1 | 146,425 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,213 | 1 | 146,426 |
"Correct Solution:
```
A = [
[0, 300, 500, 600, 700, 1350, 1650],
[6, 0, 350, 450, 600, 1150, 1500],
[13, 7, 0, 250, 400, 1000, 1350],
[18, 12, 5, 0, 250, 850, 1300],
[23, 17, 10, 5, 0, 600, 1150],
[43, 37, 30, 25, 20, 0, 500],
[58, 52, 45, 40, 35, 15, 0],
]
while 1:
d = int(input()); d... | output | 1 | 73,213 | 1 | 146,427 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,214 | 1 | 146,428 |
"Correct Solution:
```
import math
t = [ [ None, 300, 500, 600, 700, 1350, 1650 ],
[ None, None, 350, 450, 600, 1150, 1500 ],
[ None, None, None, 250, 400, 1000, 1350 ],
[ None, None, None, None, 250, 850, 1300 ],
[ None, None, None, None, None, 600, 1150 ],
[ None, None, None... | output | 1 | 73,214 | 1 | 146,429 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,215 | 1 | 146,430 |
"Correct Solution:
```
distance = [
[ 0, 6, 13, 18, 23, 43, 58],
[ 6, 0, 7, 12, 17, 37, 52],
[13, 7, 0, 5, 10, 30, 45],
[18, 12, 5, 0, 5, 25, 40],
[23, 17, 10, 5, 0, 20, 35],
[43, 37, 30, 25, 20, 0, 15],
[58, 52, 45, 45, 40, 35, 0]
]
price = [
[ 0, 300, 500, 600, 700, ... | output | 1 | 73,215 | 1 | 146,431 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,216 | 1 | 146,432 |
"Correct Solution:
```
from collections import namedtuple
Data = namedtuple("Data", "rate distance")
SENTINEL = None
NOTHING = None
RATE_TABLE = [
[SENTINEL],
[SENTINEL, NOTHING, Data(300, 6), Data(500, 13), Data(600, 18), Data(700, 23), Data(1350, 43), Data(1650, 58)],
[SENTINEL, Data(300, 6), NOTHING, D... | output | 1 | 73,216 | 1 | 146,433 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,217 | 1 | 146,434 |
"Correct Solution:
```
# Aizu Problem 00163: Highway Tooll
#
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
M = [[0, 300, 500, 600, 700,1350,1650],
[6, 0, 350, 450, 600,1150,1500],
[13, 7, 0, 250, 400,1000,135... | output | 1 | 73,217 | 1 | 146,435 |
Provide a correct Python 3 solution for this coding contest problem.
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.
For half a year after opening, the toll will be halved for vehicles that ... | instruction | 0 | 73,218 | 1 | 146,436 |
"Correct Solution:
```
# AOJ 0163 Highway Toll
# Python3 2018.6.23 bal4u
g = [ \
[ 0, 6, 13, 18, 23, 43, 58], \
[ 6, 0, 7, 12, 17, 37, 52], \
[13, 7, 0, 5, 10, 30, 45], \
[18, 12, 5, 0, 5, 25, 40], \
[23, 17, 10, 5, 0, 20, 35], \
[43, 37, 30, 25, 20, 0, 15], \
[58, 52, 45, 40, 35, 15, 0]]
f = [ \
... | output | 1 | 73,218 | 1 | 146,437 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,104 | 1 | 148,208 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189
AC
"""
import sys
from sys import stdin
input = stdin.readline
def warshallFloyd(V, dp):
for k in range(V):
for i in range(V):
for j in range(V):
dp_ik = dp[i][k]
... | output | 1 | 74,104 | 1 | 148,209 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,105 | 1 | 148,210 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
INF = 10**9
def solve():
N = int(readline())
if N == 0:
return False
K = 0
E = [[INF]*10 for i in range(10)]
for i in range(N):
a, b, c = map(int, readline().split())
E[a][b] = E[b][a] =... | output | 1 | 74,105 | 1 | 148,211 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,106 | 1 | 148,212 |
"Correct Solution:
```
INF = 10000000
while True:
n = int(input())
if n == 0:
break
table = [[INF for i in range(10)] for j in range(10)]
for l in range(n):
a,b,c = [int(i) for i in input().split()]
table[a][b] = c
table[b][a] = c
for k in range(1... | output | 1 | 74,106 | 1 | 148,213 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,107 | 1 | 148,214 |
"Correct Solution:
```
INF = float('inf')
TOWN_NUM = 10
while True:
way_num = int(input())
if way_num == 0:
break
table = [[INF for i in range(TOWN_NUM)] for j in range(TOWN_NUM)]
for _ in range(way_num):
a,b,c = [int(i) for i in input().split()]
table[a][b] = c
table[... | output | 1 | 74,107 | 1 | 148,215 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,108 | 1 | 148,216 |
"Correct Solution:
```
class WarshallFloyd():
"""Warshall-Floyd Algorithm:
find the lengths of the shortest paths between all pairs of vertices
used in GRL1C(AOJ), aoj0189
"""
def __init__(self, V, E, INF=10**9):
""" V: the number of vertexes
E: adjacency list
... | output | 1 | 74,108 | 1 | 148,217 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short t... | instruction | 0 | 74,109 | 1 | 148,218 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189
AC
"""
import sys
from sys import stdin
input = stdin.readline
def warshallFloyd(V, dp):
for k in range(V):
for i in range(V):
for j in range(V):
dp_ik = dp[i][k]
... | output | 1 | 74,109 | 1 | 148,219 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.