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 a correct Python 3 solution for this coding contest problem.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i... | instruction | 0 | 63,068 | 1 | 126,136 |
"Correct Solution:
```
dp=[[1<<30 for _ in range(1001)] for _ in range(1001)]
dp[0][0]=0
n,m=map(int,input().split())
d=[int(input()) for _ in range(n)]+[0]
c=[int(input()) for _ in range(m)]+[0]
for i in range(m):
for j in range(n+1):
if dp[i][j]< dp[i+1][j]:dp[i+1][j]=dp[i][j]
e=d[j]*c[i]
... | output | 1 | 63,068 | 1 | 126,137 |
Provide a correct Python 3 solution for this coding contest problem.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i... | instruction | 0 | 63,069 | 1 | 126,138 |
"Correct Solution:
```
n,m=map(int,input().split())
d=[int(input()) for _ in range(n)]
c=[int(input()) for _ in range(m)]
dp=[[0]*m for _ in range(n)]
for i in range(n):
for j in range(i,m):
if i==j:
dp[i][j]=dp[i-1][j-1]+c[j]*d[i]
else:
dp[i][j]=min(dp[i-1][j-1]+c[j]*d[i... | output | 1 | 63,069 | 1 | 126,139 |
Provide a correct Python 3 solution for this coding contest problem.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i... | instruction | 0 | 63,070 | 1 | 126,140 |
"Correct Solution:
```
N,M = map(int,input().split())
D = [0]
for _ in range(N):
D.append(int(input()))
C = [0]
for _ in range(M):
C.append(int(input()))
INF = float('inf')
dp = [ [INF]*(N+1) for _ in range(M+1) ]
dp[0][0] = 0
# i日目
for i in range(M):
c = C[i+1]
# 都市j
for j in range(min(i+1,N)):
d = D[... | output | 1 | 63,070 | 1 | 126,141 |
Provide a correct Python 3 solution for this coding contest problem.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i... | instruction | 0 | 63,071 | 1 | 126,142 |
"Correct Solution:
```
INF = 10 ** 20
n, m = map(int, input().split())
dist = [int(input()) for _ in range(n)]
weth = [int(input()) for _ in range(m)]
dp = [INF] * (n + 1)
dp[0] = 0
for i in range(m):
for j in range(n, 0, -1):
dp[j] = min(dp[j], dp[j - 1] + dist[j - 1] * weth[i])
print(dp[n])
``` | output | 1 | 63,071 | 1 | 126,143 |
Provide a correct Python 3 solution for this coding contest problem.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≤ i... | instruction | 0 | 63,072 | 1 | 126,144 |
"Correct Solution:
```
# AOJ 0611: Silk Road
# Python3 2018.7.4 bal4u
import sys
from sys import stdin
input = stdin.readline
INF = 0x7fffffff
n, m = map(int, input().split())
d = [int(input()) for i in range(n)]
c = [int(input()) for i in range(m)]
dp = [[INF for j in range(n+1)] for i in range(m+1)]
dp[0][0] = 0
fo... | output | 1 | 63,072 | 1 | 126,145 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,073 | 1 | 126,146 |
Yes | output | 1 | 63,073 | 1 | 126,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,074 | 1 | 126,148 |
Yes | output | 1 | 63,074 | 1 | 126,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,075 | 1 | 126,150 |
Yes | output | 1 | 63,075 | 1 | 126,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,076 | 1 | 126,152 |
Yes | output | 1 | 63,076 | 1 | 126,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,077 | 1 | 126,154 |
No | output | 1 | 63,077 | 1 | 126,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,078 | 1 | 126,156 |
No | output | 1 | 63,078 | 1 | 126,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,079 | 1 | 126,158 |
No | output | 1 | 63,079 | 1 | 126,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road".
There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., ... | instruction | 0 | 63,080 | 1 | 126,160 |
No | output | 1 | 63,080 | 1 | 126,161 |
Provide a correct Python 3 solution for this coding contest problem.
In the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day.
All freight trains travel at night, so these trains containing various types of cars are settl... | instruction | 0 | 63,084 | 1 | 126,168 |
"Correct Solution:
```
def solve(file_input, x, y):
exch1 = [] # forward - forward
exch2 = [] # forward - reverse
exch3 = [] # reverse - forward
for i in range(y):
p, P, space, q, Q = file_input.readline().rstrip()
p = int(p)
q = int(q)
if P == 'E':
i... | output | 1 | 63,084 | 1 | 126,169 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,217 | 1 | 128,434 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
# Author: yumtam
# Created at: 2021-05-04 03:29
import sys
def input_as_list(offset=0):
return [int(t)+offset for t in sys.stdin.readline().split()]
n, m, x = input_as_list()
a = input_as_list()
if sum(a) < (n-... | output | 1 | 64,217 | 1 | 128,435 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,218 | 1 | 128,436 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
from collections import deque
class UnionFind:
def __init__(self, n): self.parent = list(range(n))
def find(self, a):
acopy = a
while a != self.parent[a]: a = self.parent[a]
... | output | 1 | 64,218 | 1 | 128,437 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,219 | 1 | 128,438 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
from collections import deque
class UnionFind:
def __init__(self, n): self.parent = list(range(n))
def find(self, a):
acopy = a
while a != self.parent[a]: a = self.parent[a]
... | output | 1 | 64,219 | 1 | 128,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,220 | 1 | 128,440 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
from bisect import bisect,bisect_left
from collections import *
from heapq import *
from math import gcd,ceil,sqrt,floor,inf
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools im... | output | 1 | 64,220 | 1 | 128,441 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,221 | 1 | 128,442 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
from collections import deque
class UnionFind:
def __init__(self, n): self.parent = list(range(n))
def find(self, a):
acopy = a
while a != self.parent[a]: a = self.parent[a]
... | output | 1 | 64,221 | 1 | 128,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,222 | 1 | 128,444 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
import sys
f = sys.stdin
def line():
return f.readline().strip().split()
def dfs(st):
seen=[-1]*N
q=[st]
seen[st]=0
parent=[None]*N
road=[None]*N
front=[]
back=[]
while q:
... | output | 1 | 64,222 | 1 | 128,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,223 | 1 | 128,446 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from collections import deque
class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
def find(self, a):
aco... | output | 1 | 64,223 | 1 | 128,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again.
The i-th ci... | instruction | 0 | 64,224 | 1 | 128,448 |
Tags: constructive algorithms, dfs and similar, dsu, graphs, greedy, trees
Correct Solution:
```
import sys
from heapq import heapify, heappop, _heapify_max, heappush, _heappop_max
f = sys.stdin
def line():
return f.readline().strip().split()
class UnionFind:
def __init__(self, n):
self.link = [-1]*n... | output | 1 | 64,224 | 1 | 128,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,225 | 1 | 128,450 |
Yes | output | 1 | 64,225 | 1 | 128,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,226 | 1 | 128,452 |
Yes | output | 1 | 64,226 | 1 | 128,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,227 | 1 | 128,454 |
No | output | 1 | 64,227 | 1 | 128,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,228 | 1 | 128,456 |
No | output | 1 | 64,228 | 1 | 128,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,229 | 1 | 128,458 |
No | output | 1 | 64,229 | 1 | 128,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that al... | instruction | 0 | 64,230 | 1 | 128,460 |
No | output | 1 | 64,230 | 1 | 128,461 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,446 | 1 | 128,892 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n,m=map(int,input().split())
if m%2==1:
m+=1
m//=2
print(m)
else :
n+=2
n-=m
n//=2
print(n)
``` | output | 1 | 64,446 | 1 | 128,893 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,447 | 1 | 128,894 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n,a=map(int,input().split())
if a%2==0:
s=1
k=n
while k!=a:
s+=1
k-=2
else:
s=1
k=1
while k!=a:
s+=1
k+=2
print(s)
``` | output | 1 | 64,447 | 1 | 128,895 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,448 | 1 | 128,896 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n,a=map(int,input().split())
print(a-(a-1)//2if a%2else(n-a)//2+1)
``` | output | 1 | 64,448 | 1 | 128,897 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,449 | 1 | 128,898 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n,a=[int(x) for x in input().split()]
t=0
if a%2==1:
t=a//2+1
else:
t=n//2-a//2+1
print(t)
``` | output | 1 | 64,449 | 1 | 128,899 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,450 | 1 | 128,900 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n, m = map(int, input().split())
if (m % 2 == 0) :
m = n - m + 1
print(m // 2 + 1)
``` | output | 1 | 64,450 | 1 | 128,901 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,451 | 1 | 128,902 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
s = input()
n,a = int(s.split()[0]),int(s.split()[1])
if a%2==0:
t = (n-a)//2 + 1
else:
t = (a-1)//2 + 1
print(t)
``` | output | 1 | 64,451 | 1 | 128,903 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,452 | 1 | 128,904 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
amount, dest = map(int, input().split())
answ = 0
if dest % 2 != 1:
answ = (amount - dest) / 2 + 1
else:
answ = (dest + 1) / 2
print(int(answ))
``` | output | 1 | 64,452 | 1 | 128,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 ... | instruction | 0 | 64,453 | 1 | 128,906 |
Tags: *special, constructive algorithms, math
Correct Solution:
```
n,a = [int(i) for i in input().split()]
if a%2==0:
t = n//2-a//2
else:
t = a//2
print(t+1)
``` | output | 1 | 64,453 | 1 | 128,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,454 | 1 | 128,908 |
Yes | output | 1 | 64,454 | 1 | 128,909 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,455 | 1 | 128,910 |
Yes | output | 1 | 64,455 | 1 | 128,911 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,456 | 1 | 128,912 |
Yes | output | 1 | 64,456 | 1 | 128,913 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,457 | 1 | 128,914 |
Yes | output | 1 | 64,457 | 1 | 128,915 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,458 | 1 | 128,916 |
No | output | 1 | 64,458 | 1 | 128,917 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,459 | 1 | 128,918 |
No | output | 1 | 64,459 | 1 | 128,919 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,460 | 1 | 128,920 |
No | output | 1 | 64,460 | 1 | 128,921 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side ... | instruction | 0 | 64,461 | 1 | 128,922 |
No | output | 1 | 64,461 | 1 | 128,923 |
Provide a correct Python 3 solution for this coding contest problem.
Villages were scattered in the Wakamatsu Plain of Aizu. Several settlements are connected by straight roads that allow them to travel to and from each other, and any settlement in the plain can be traced back and forth. Each road has a lengthy mainte... | instruction | 0 | 64,754 | 1 | 129,508 |
"Correct Solution:
```
import sys
def graham_scan(vertices: list):
from math import atan2
from operator import itemgetter
vertices.sort(key=itemgetter(1))
base_x, base_y = vertices[0][:2]
vertices = sorted(vertices[1:], key=lambda p: atan2(p[1]-base_y, p[0]-base_x)) + vertices[:1]
convex = ve... | output | 1 | 64,754 | 1 | 129,509 |
Provide a correct Python 3 solution for this coding contest problem.
Villages were scattered in the Wakamatsu Plain of Aizu. Several settlements are connected by straight roads that allow them to travel to and from each other, and any settlement in the plain can be traced back and forth. Each road has a lengthy mainte... | instruction | 0 | 64,755 | 1 | 129,510 |
"Correct Solution:
```
def quickhull(l,r,s,k,il,ir):
if not s:
return
su = []
sd = []
a = (r[0]-l[0],r[1]-l[1])
for x,y in s:
b = (x-l[0],y-l[1])
cro = cross(a,b)
if cro > 0:
su.append((x,y))
elif cro < 0:
sd.append((x,y))
ind = (i... | output | 1 | 64,755 | 1 | 129,511 |
Provide a correct Python 3 solution for this coding contest problem.
Villages were scattered in the Wakamatsu Plain of Aizu. Several settlements are connected by straight roads that allow them to travel to and from each other, and any settlement in the plain can be traced back and forth. Each road has a lengthy mainte... | instruction | 0 | 64,756 | 1 | 129,512 |
"Correct Solution:
```
def dist2(A, B):
return (A[0]-B[0])**2 + (A[1]-B[1])**2
def cross(A, B, C):
return (B[0]-A[0])*(C[1]-A[1]) - (C[0]-A[0])*(B[1]-A[1])
def convex_hull(PS):
n = len(PS)
PP = sorted([p + [i] for i, p in enumerate(PS)])
Q = []
for i in range(n):
while len(Q) > 1 and cro... | output | 1 | 64,756 | 1 | 129,513 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew prefers taxi to other means of transport, but recently most taxi drivers have been acting inappropriately. In order to earn more money, taxi drivers started to drive in circles. Roads in Andrew's city are one-way, and people are not n... | instruction | 0 | 64,867 | 1 | 129,734 |
Tags: binary search, dfs and similar, graphs
Correct Solution:
```
from collections import deque
N,M=map(int,input().split())
table=[]
#ma=-1
for i in range(M):
s,t,c=map(int,input().split())
s,t=s-1,t-1
table.append((s,t,c))
#ma=max(c,ma)
def check(k):
Lin=[0]*N
edge=[[] for i in range(N)]
... | output | 1 | 64,867 | 1 | 129,735 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew prefers taxi to other means of transport, but recently most taxi drivers have been acting inappropriately. In order to earn more money, taxi drivers started to drive in circles. Roads in Andrew's city are one-way, and people are not n... | instruction | 0 | 64,868 | 1 | 129,736 |
Tags: binary search, dfs and similar, graphs
Correct Solution:
```
import copy
import sys
def find_loop(g, w, k, n):
visited = [False] * n
visited_int = [False] * n
for i in range(n):
if visited[i]:
continue
stack = [g[i][:]]
path = [i]
visited[i] = True
... | output | 1 | 64,868 | 1 | 129,737 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Andrew prefers taxi to other means of transport, but recently most taxi drivers have been acting inappropriately. In order to earn more money, taxi drivers started to drive in circles. Roads in Andrew's city are one-way, and people are not n... | instruction | 0 | 64,869 | 1 | 129,738 |
Tags: binary search, dfs and similar, graphs
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO,IOBase
def check(n,mid,path,cost,num):
ans,poi,visi = [],[0]*n,[0]*n
for i in range(n):
if visi[i]:
continue
visi[i],st... | output | 1 | 64,869 | 1 | 129,739 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.