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.
Our brave travelers reached an island where pirates had buried treasure. However as the ship was about to moor, the captain found out that some rat ate a piece of the treasure map.
The treasure map can be represented as a rectangle n × m in... | instruction | 0 | 98,622 | 1 | 197,244 |
Tags: brute force, implementation
Correct Solution:
```
from sys import stdin
n, m = map(int, stdin.readline().rstrip().split())
island = []
pos = {}
for i in range(n):
island.append(stdin.readline().rstrip())
for j, c in enumerate(island[i]):
if c >= 'A' and c <= 'Z':
pos[c] = [i, j]
l_... | output | 1 | 98,622 | 1 | 197,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In addition to complaints about lighting, a lot of complaints about insufficient radio signal covering has been received by Bertown city hall recently. n complaints were sent to the mayor, all of which are suspiciosly similar to each other: ... | instruction | 0 | 98,709 | 1 | 197,418 |
Tags: 2-sat
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------- fast io --------------------
def find_SCC(graph):
SCC, S, P = [], [], []
depth = [0] * len(graph)
stack = list(range(len(... | output | 1 | 98,709 | 1 | 197,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.
It is widely known that Uzhlyandia has n cities connected with m bidire... | instruction | 0 | 99,152 | 1 | 198,304 |
No | output | 1 | 99,152 | 1 | 198,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.
It is widely known that Uzhlyandia has n cities connected with m bidire... | instruction | 0 | 99,153 | 1 | 198,306 |
No | output | 1 | 99,153 | 1 | 198,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.
It is widely known that Uzhlyandia has n cities connected with m bidire... | instruction | 0 | 99,154 | 1 | 198,308 |
No | output | 1 | 99,154 | 1 | 198,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his motherland — Uzhlyandia.
It is widely known that Uzhlyandia has n cities connected with m bidire... | instruction | 0 | 99,155 | 1 | 198,310 |
No | output | 1 | 99,155 | 1 | 198,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Leha and Noora decided to go on a trip in the Baltic States. As you know from the previous problem, Leha has lost his car on the parking of the restaurant. Unfortunately, requests to the watchma... | instruction | 0 | 99,156 | 1 | 198,312 |
No | output | 1 | 99,156 | 1 | 198,313 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Leha and Noora decided to go on a trip in the Baltic States. As you know from the previous problem, Leha has lost his car on the parking of the restaurant. Unfortunately, requests to the watchma... | instruction | 0 | 99,157 | 1 | 198,314 |
No | output | 1 | 99,157 | 1 | 198,315 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Leha and Noora decided to go on a trip in the Baltic States. As you know from the previous problem, Leha has lost his car on the parking of the restaurant. Unfortunately, requests to the watchma... | instruction | 0 | 99,158 | 1 | 198,316 |
No | output | 1 | 99,158 | 1 | 198,317 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Leha and Noora decided to go on a trip in the Baltic States. As you know from the previous problem, Leha has lost his car on the parking of the restaurant. Unfortunately, requests to the watchma... | instruction | 0 | 99,159 | 1 | 198,318 |
No | output | 1 | 99,159 | 1 | 198,319 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,383 | 1 | 198,766 |
"Correct Solution:
```
import sys
import heapq
if sys.version[0] == '2':
range, input = xrange, raw_input
MAX_SPEED = 30
dvs = (-1, 0, 1)
while True:
N, M = map(int, input().split())
if not (N | M):
break
S, G = map(lambda x: int(x) - 1, input().split())
edge = [[] for _ in range(N)]
for... | output | 1 | 99,383 | 1 | 198,767 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,384 | 1 | 198,768 |
"Correct Solution:
```
from collections import defaultdict
from heapq import heappop, heappush
while True:
n, m = map(int, input().split())
if n==0 and m==0:
break
s, g = map(int, input().split())
graph = defaultdict(list)
for _ in range(m):
x, y, d, c = map(int, input().split())
graph[x].append... | output | 1 | 99,384 | 1 | 198,769 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,385 | 1 | 198,770 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 99,385 | 1 | 198,771 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,386 | 1 | 198,772 |
"Correct Solution:
```
def solve():
import sys
from heapq import heappush, heappop
file_input = sys.stdin
inf = float('inf')
while True:
n, m = map(int, file_input.readline().split())
if n == 0:
break
s, g = map(int, file_input.readline().split())
... | output | 1 | 99,386 | 1 | 198,773 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,387 | 1 | 198,774 |
"Correct Solution:
```
import sys
import heapq
if sys.version[0] == '2':
range, input = xrange, raw_input
MAX_SPEED = 30
while True:
N, M = map(int, input().split())
if not (N | M):
break
S, G = map(lambda x: int(x) - 1, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
... | output | 1 | 99,387 | 1 | 198,775 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,388 | 1 | 198,776 |
"Correct Solution:
```
from heapq import heappush, heappop
def main():
while True:
n, m = map(int, input().split())
if n == 0:
break
s, g = map(int, input().split())
s -= 1
g -= 1
edges = [[] for _ in range(n)]
for _ in range(m):
x, y... | output | 1 | 99,388 | 1 | 198,777 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,389 | 1 | 198,778 |
"Correct Solution:
```
#2006_D
"""
import sys
from collections import defaultdict
def dfs(d,y,x,f):
global ans
if d >= 10:
return
f_ = defaultdict(int)
for i in f.keys():
f_[i] = f[i]
for t,s in vr[(y,x)]:
if a[t][s] == 3:
ans = min(ans,d+1)
break
... | output | 1 | 99,389 | 1 | 198,779 |
Provide a correct Python 3 solution for this coding contest problem.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can... | instruction | 0 | 99,390 | 1 | 198,780 |
"Correct Solution:
```
# AOJ 1162: Discrete Speed
# Python3 2018.7.15 bal4u
INF = 10e8
import heapq
def dijkstra(V, to, start, goal):
node = [[[INF for k in range(31)] for j in range(V)] for i in range(V)]
Q = []
node[start][0][0] = 0
heapq.heappush(Q, (0, start, -1, 0))
while Q:
t, s, p, v = heapq.heappop(Q)
... | output | 1 | 99,390 | 1 | 198,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,391 | 1 | 198,782 |
Yes | output | 1 | 99,391 | 1 | 198,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,392 | 1 | 198,784 |
Yes | output | 1 | 99,392 | 1 | 198,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,393 | 1 | 198,786 |
Yes | output | 1 | 99,393 | 1 | 198,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,394 | 1 | 198,788 |
No | output | 1 | 99,394 | 1 | 198,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,395 | 1 | 198,790 |
No | output | 1 | 99,395 | 1 | 198,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,396 | 1 | 198,792 |
No | output | 1 | 99,396 | 1 | 198,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are accelera... | instruction | 0 | 99,397 | 1 | 198,794 |
No | output | 1 | 99,397 | 1 | 198,795 |
Provide a correct Python 3 solution for this coding contest problem.
Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who was trying to kill the princess a... | instruction | 0 | 99,398 | 1 | 198,796 |
"Correct Solution:
```
from heapq import heappop, heappush
def dijkstra(links, n, m, freezables, s, t):
queue = [(0, 0, s, m)]
visited = [0] * n
while queue:
link_cost, cost, node, remain = heappop(queue)
if node == t:
# Congratulations!
if link_cost <= m:
... | output | 1 | 99,398 | 1 | 198,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. ... | instruction | 0 | 99,399 | 1 | 198,798 |
No | output | 1 | 99,399 | 1 | 198,799 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. ... | instruction | 0 | 99,400 | 1 | 198,800 |
No | output | 1 | 99,400 | 1 | 198,801 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. ... | instruction | 0 | 99,401 | 1 | 198,802 |
No | output | 1 | 99,401 | 1 | 198,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Princess in Danger
Princess crisis
English text is not available in this practice contest.
A brave princess in a poor country's tomboy is married to another country for a political marriage. ... | instruction | 0 | 99,402 | 1 | 198,804 |
No | output | 1 | 99,402 | 1 | 198,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,909 | 1 | 199,818 |
Tags: binary search, math
Correct Solution:
```
raw = input().split()
import decimal
n = int(raw[0])
k = int(raw[4])
def get(n,k):
if(n%k==0):
return n//k
else:
return n//k + 1
n = decimal.Decimal(str(get(n,k)))
l = decimal.Decimal(str(raw[1]))
v1 = decimal.Decimal(str(raw[2]))
v2 = decimal.De... | output | 1 | 99,909 | 1 | 199,819 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,910 | 1 | 199,820 |
Tags: binary search, math
Correct Solution:
```
import math
n,L,v1,v2,k = [int(x) for x in input().split()]
n = int(math.ceil(n/k))
a = v2/v1
x = (2*L)/(a+2*n-1)
y = L-(n-1)*x
print((y*n+(n-1)*(y-x))/v2)
``` | output | 1 | 99,910 | 1 | 199,821 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,911 | 1 | 199,822 |
Tags: binary search, math
Correct Solution:
```
n, L, v1, v2, k = map(int, input().split())
dif = v2 - v1
n = (n + k - 1) // k * 2
p1 = (n * v2 - dif) * L
p2 = (n * v1 + dif) * v2
print(p1 / p2)
``` | output | 1 | 99,911 | 1 | 199,823 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,912 | 1 | 199,824 |
Tags: binary search, math
Correct Solution:
```
import math
n, l, v1, v2, k = map(int, input().split(' '))
p = math.ceil(n/k)
def calc(d):
cyc = ((d-d/v2*v1)/(v1+v2))
t = cyc + d/v2
#t is the time per cycle
ans = -1
for i in range(p):
tb4 = t * i;
db4 = tb4 * v1
ans = max(an... | output | 1 | 99,912 | 1 | 199,825 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,913 | 1 | 199,826 |
Tags: binary search, math
Correct Solution:
```
#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
import math
inputParams = input().split()
n = int(inputParams[0])
l = int(inputParams[1])
v1 = int(inputParams[2])
v2 = int(inputParams[3])
k = int(inputParams[4])
# 运送次数
times = math.ceil(n / k)
t1 = l / (v2 + (2 * v2 /... | output | 1 | 99,913 | 1 | 199,827 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,914 | 1 | 199,828 |
Tags: binary search, math
Correct Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections im... | output | 1 | 99,914 | 1 | 199,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,915 | 1 | 199,830 |
Tags: binary search, math
Correct Solution:
```
n,l,v1,v2,k=map(int,input().split())
m=(n-1)//k+1
v=v1+v2
x=l/(1+(m-1)*(v1*(1-v1/v2)/(v2+v1)+v1/v2))
print(x/v2+(l-x)/v1)
``` | output | 1 | 99,915 | 1 | 199,831 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent... | instruction | 0 | 99,916 | 1 | 199,832 |
Tags: binary search, math
Correct Solution:
```
n,l,v1,v2,k=map(int,input().split())
n=(n+k-1)//k
a=(v2-v1)/(v1+v2)
t=l/v2/(n-(n-1)*a)
print(n*t+(n-1)*a*t)
# Made By Mostafa_Khaled
``` | output | 1 | 99,916 | 1 | 199,833 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,917 | 1 | 199,834 |
Yes | output | 1 | 99,917 | 1 | 199,835 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,918 | 1 | 199,836 |
Yes | output | 1 | 99,918 | 1 | 199,837 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,919 | 1 | 199,838 |
Yes | output | 1 | 99,919 | 1 | 199,839 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,920 | 1 | 199,840 |
Yes | output | 1 | 99,920 | 1 | 199,841 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,921 | 1 | 199,842 |
No | output | 1 | 99,921 | 1 | 199,843 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,922 | 1 | 199,844 |
No | output | 1 | 99,922 | 1 | 199,845 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,923 | 1 | 199,846 |
No | output | 1 | 99,923 | 1 | 199,847 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get t... | instruction | 0 | 99,924 | 1 | 199,848 |
No | output | 1 | 99,924 | 1 | 199,849 |
Provide a correct Python 3 solution for this coding contest problem.
A taxi driver, Nakamura, was so delighted because he got a passenger who wanted to go to a city thousands of kilometers away. However, he had a problem. As you may know, most taxis in Japan run on liquefied petroleum gas (LPG) because it is cheaper t... | instruction | 0 | 100,275 | 1 | 200,550 |
"Correct Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int... | output | 1 | 100,275 | 1 | 200,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a ca... | instruction | 0 | 100,336 | 1 | 200,672 |
Tags: data structures, dp, trees
Correct Solution:
```
n=int(input())
w=list(map(int,input().split()))
edges=[[] for i in range(n)]
for i in range(n-1):
a,b,c=map(int,input().split())
edges[a-1].append((b-1,c))
edges[b-1].append((a-1,c))
parents=[None]*n
layers=[{0}]
while True:
newlayer=[]
for guy ... | output | 1 | 100,336 | 1 | 200,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a ca... | instruction | 0 | 100,337 | 1 | 200,674 |
Tags: data structures, dp, trees
Correct Solution:
```
import sys
from collections import deque
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
n=int(input())
W=list(map(int,input().split()))
EDGE=[list(map(int,input().split())) for i in range(n-1)]
#n=30000
#W=[10 for i in range(n)]
#EDGE=[[i+1,i+2,1] for... | output | 1 | 100,337 | 1 | 200,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a ca... | instruction | 0 | 100,338 | 1 | 200,676 |
Tags: data structures, dp, trees
Correct Solution:
```
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n=int(input())
w=list(map(int,input().split()))
ans=max(w)
graph=[]
for i in range(n):
graph.append([])
for i in range(n-1):
u,v,c=map(int,input().split())
graph[u-1].append((v-1,c))
gra... | output | 1 | 100,338 | 1 | 200,677 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.