message stringlengths 2 44.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 276 109k | cluster float64 23 23 | __index_level_0__ int64 552 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,768 | 23 | 41,536 |
Tags: brute force, sortings
Correct Solution:
```
count = int(input())
nums = sorted([int(num) for num in input().split()])
print(nums[(count - 1) // 2])
``` | output | 1 | 20,768 | 23 | 41,537 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,769 | 23 | 41,538 |
Tags: brute force, sortings
Correct Solution:
```
import sys
from statistics import median
from math import floor
sys.stdin.readline()
numbers = sorted(int(a) for a in sys.stdin.readline().split())
print(numbers[floor((len(numbers) - 1) / 2)])
``` | output | 1 | 20,769 | 23 | 41,539 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,770 | 23 | 41,540 |
Tags: brute force, sortings
Correct Solution:
```
n=int(input())
a=list(map(int, input().split()))
a.sort()
k=0
r=0
for i in range(1,n):
k=k+abs((a[i]-a[0]))
if n%2==1:
print(a[n//2])
else:
for j in range(n):
r=r+abs(a[n//2-1]-a[j])
for i in range(n):
k=k+abs(a[n//2]-a[i])
if r<=k:
... | output | 1 | 20,770 | 23 | 41,541 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,771 | 23 | 41,542 |
Tags: brute force, sortings
Correct Solution:
```
n=int(input())
li=list(map(int, input().split()))
li.sort()
print(li[(n-1)//2])
``` | output | 1 | 20,771 | 23 | 41,543 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,772 | 23 | 41,544 |
Tags: brute force, sortings
Correct Solution:
```
'''
You are given n points on a line with their coordinates x_i.
Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1ββ€βnββ€β3Β·105)
β the number of points on the line.
The second line contains n integers ... | output | 1 | 20,772 | 23 | 41,545 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β the number of points on the line.
The second li... | instruction | 0 | 20,773 | 23 | 41,546 |
Tags: brute force, sortings
Correct Solution:
```
n, x = int(input()), sorted(list(map(int, input().split())))
print(x[(n - 1) // 2])
``` | output | 1 | 20,773 | 23 | 41,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β t... | instruction | 0 | 20,774 | 23 | 41,548 |
Yes | output | 1 | 20,774 | 23 | 41,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β t... | instruction | 0 | 20,775 | 23 | 41,550 |
Yes | output | 1 | 20,775 | 23 | 41,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β t... | instruction | 0 | 20,778 | 23 | 41,556 |
No | output | 1 | 20,778 | 23 | 41,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β t... | instruction | 0 | 20,779 | 23 | 41,558 |
No | output | 1 | 20,779 | 23 | 41,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
Input
The first line contains integer n (1 β€ n β€ 3Β·105) β t... | instruction | 0 | 20,780 | 23 | 41,560 |
No | output | 1 | 20,780 | 23 | 41,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,798 | 23 | 41,596 |
Tags: data structures
Correct Solution:
```
n, k = map(int, input().split())
if n // 2 < k:
k = n - k
i = 1
count = 1
ans = [1]
for _ in range(n):
i += k
if i > n + 1:
count += 1
ans.append(ans[-1] + count)
count += 1
i -= n
else:
ans.append(ans[-1] + count)
print... | output | 1 | 20,798 | 23 | 41,597 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,799 | 23 | 41,598 |
Tags: data structures
Correct Solution:
```
def euclid(a, b): ##return [m, n] with am + bn = gcd(a, b)
if b == 0:
return [1, 0]
if b > a:
l = euclid(b, a)
l.reverse()
return l
else:
quo = a // b
rem = a % b
l = euclid(b, rem)
m = l[0]
n... | output | 1 | 20,799 | 23 | 41,599 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,800 | 23 | 41,600 |
Tags: data structures
Correct Solution:
```
import sys
inf = (1 << 31) - 1
def solve():
n, k = map(int, input().split())
if k > n - k:
k = n - k
bit = BinaryIndexedTree([0]*n)
s = 0
res = 1
ans = []
for i in range(n):
t = (s + k) % n
if s < t:
res +... | output | 1 | 20,800 | 23 | 41,601 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,801 | 23 | 41,602 |
Tags: data structures
Correct Solution:
```
n, k = map(int, input().split())
if k << 1 > n: k = n - k
s = 1
for i in range(n):
s += 1 + i * k // n + (i * k + k - 1) // n
print(s)
``` | output | 1 | 20,801 | 23 | 41,603 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,802 | 23 | 41,604 |
Tags: data structures
Correct Solution:
```
# input = raw_input
# range = xrange
class Fen:
def __init__(self, n):
self.value = [0] * n
def get(self, fro, to):
return self.get1(to) - self.get1(fro - 1)
def get1(self, to):
to = min(to, len(self.value))
result = 0
while to >= 0:
result += self.value[to]
... | output | 1 | 20,802 | 23 | 41,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,803 | 23 | 41,606 |
Tags: data structures
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
# from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt',... | output | 1 | 20,803 | 23 | 41,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,804 | 23 | 41,608 |
Tags: data structures
Correct Solution:
```
import sys
inf = (1 << 31) - 1
def solve():
n, k = map(int, input().split())
if k > n - k:
k = n - k
s = 0
res = 1
a = 1
ans = [0]*n
for i in range(n):
t = (s + k) % n
if t < s and t > 0:
res += a + 1
... | output | 1 | 20,804 | 23 | 41,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number k such that gcd(n, k) = 1. Vertices of the poly... | instruction | 0 | 20,805 | 23 | 41,610 |
Tags: data structures
Correct Solution:
```
if __name__ == "__main__":
n,k = list(map(int, input().strip().split()))
if k > n//2:
k = n - k
intersection = n * [0]
count = 1
done = False
i=0
result = []
for i in range(1,n+1):
nn = (i*k) // n
j = (i*k)%n
... | output | 1 | 20,805 | 23 | 41,611 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,806 | 23 | 41,612 |
Yes | output | 1 | 20,806 | 23 | 41,613 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,807 | 23 | 41,614 |
Yes | output | 1 | 20,807 | 23 | 41,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,808 | 23 | 41,616 |
No | output | 1 | 20,808 | 23 | 41,617 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,809 | 23 | 41,618 |
No | output | 1 | 20,809 | 23 | 41,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,810 | 23 | 41,620 |
No | output | 1 | 20,810 | 23 | 41,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.
He chose a number ... | instruction | 0 | 20,811 | 23 | 41,622 |
No | output | 1 | 20,811 | 23 | 41,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a set of n vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector vi = (xi, yi) can be transformed into one of the followin... | instruction | 0 | 21,277 | 23 | 42,554 |
No | output | 1 | 21,277 | 23 | 42,555 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a set of n vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector vi = (xi, yi) can be transformed into one of the followin... | instruction | 0 | 21,278 | 23 | 42,556 |
No | output | 1 | 21,278 | 23 | 42,557 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a set of n vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector vi = (xi, yi) can be transformed into one of the followin... | instruction | 0 | 21,279 | 23 | 42,558 |
No | output | 1 | 21,279 | 23 | 42,559 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a set of n vectors on a plane. For each vector you are allowed to multiply any of its coordinates by -1. Thus, each vector vi = (xi, yi) can be transformed into one of the followin... | instruction | 0 | 21,280 | 23 | 42,560 |
No | output | 1 | 21,280 | 23 | 42,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are given three segments on the plane. They form the ... | instruction | 0 | 21,379 | 23 | 42,758 |
Tags: geometry, implementation
Correct Solution:
```
""" A : Determine if three line segments form A """
def cross(vecA, vecB):
return vecA[0] * vecB[1] - vecA[1] * vecB[0]
def dot(vecA, vecB):
return vecA[0] * vecB[0] + vecA[1] * vecB[1]
def angle(lineA, lineB):
x1, y1 = (lineA[0][0] - lineA[1][0], l... | output | 1 | 21,379 | 23 | 42,759 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are given three segments on the plane. They form the ... | instruction | 0 | 21,381 | 23 | 42,762 |
Tags: geometry, implementation
Correct Solution:
```
import sys
input = sys.stdin.buffer.readline
def dot(a,b):
return a[0]*b[0] + a[1]*b[1]
for _ in range(int(input())):
points = [list(map(int,input().split())) for i in range(3)]
points = [[points[i][:2],points[i][2:]] for i in range(3)]
diff = [[[p... | output | 1 | 21,381 | 23 | 42,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are given three segments on the plane. They form the ... | instruction | 0 | 21,382 | 23 | 42,764 |
Tags: geometry, implementation
Correct Solution:
```
#13B - Letter A
import math
r = lambda: map(int,input().split())
#Function to check if the lines cross
def cross(a, b):
return a[0] * b[1] - a[1] * b[0]
def dot(a, b):
return a[0] * b[0] + a[1] * b[1]
# def l(v):
# return math.hypot(*v)
def on_line(a, b):
ret... | output | 1 | 21,382 | 23 | 42,765 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are given three segments on the plane. They form the ... | instruction | 0 | 21,384 | 23 | 42,768 |
Tags: geometry, implementation
Correct Solution:
```
import random
from math import sqrt as s
def dist(x1, y1, x2, y2):
return s((x2 - x1) ** 2 + (y2 - y1) ** 2)
def is_dot_on_line(c1, c2, dot):
A = c1[1] - c2[1]
B = c2[0] - c1[0]
C = c1[0] * c2[1] - c2[0] * c1[1]
maxx, minx = max(c1[0], c2[0])... | output | 1 | 21,384 | 23 | 42,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are gi... | instruction | 0 | 21,385 | 23 | 42,770 |
No | output | 1 | 21,385 | 23 | 42,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are gi... | instruction | 0 | 21,386 | 23 | 42,772 |
No | output | 1 | 21,386 | 23 | 42,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are gi... | instruction | 0 | 21,387 | 23 | 42,774 |
No | output | 1 | 21,387 | 23 | 42,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.
You are gi... | instruction | 0 | 21,388 | 23 | 42,776 |
No | output | 1 | 21,388 | 23 | 42,777 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,554 | 23 | 43,108 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
n , m = map(int,input().split())
if n == 0 :
print (0, 1)
print (0, m)
print (0, 0)
print (0, m - 1)
elif m == 0 :
print (1, 0)
print (n, 0)
print (0, 0)
print (n - 1, 0)
elif m >= n :
if 2 * (m ** 2 + ... | output | 1 | 21,554 | 23 | 43,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,555 | 23 | 43,110 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
def dist(x1, y1, x2, y2):
return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
def ddist(a):
res = 0.0
for i in range(3):
res += dist(a[i][0], a[i][1], a[i + 1][0], a[i + 1][1])
return res;
n, m = map(int, input().spl... | output | 1 | 21,555 | 23 | 43,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,556 | 23 | 43,112 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
import math
n, m = map(int, input().split())
def check(a):
return 0 <= a[0] <= n and 0 <= a[1] <= m
def dist(a, b):
if not check(a) or not check(b):
return -1324345543
return math.hypot(0.0 + a[0] - b[0], a[1] - b... | output | 1 | 21,556 | 23 | 43,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,557 | 23 | 43,114 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
import math
a,b=map(int,input().split(' '))
if a==0:
print(0,' ',1)
print(0,' ',b)
print(0,' ',0)
print(0,' ',b-1)
elif b==0:
print(1,' ',0)
print(a,' ',0)
print(0,' ',0)
print(a-1,' ',0)
elif a>=b:
if ... | output | 1 | 21,557 | 23 | 43,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,558 | 23 | 43,116 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
n, m = map(int, input().split())
A = set((i, j) for i in range(2) for j in range(2) if i <= n and j <= m)
A |= set((n - i, m - j) for i in range(2) for j in range(2) if i <= n and j <= m)
A |= set((i, m - j) for i in range(2) for j in ra... | output | 1 | 21,558 | 23 | 43,117 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,559 | 23 | 43,118 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
def main():
a=input().split()
for i in range(len(a)):
a[i]=int(a[i])
m=a[1]
n=a[0]
if n==0:
c1={(0, 0), (0, 1), (0, m-1), (0, m)}
elif m==0:
c1={(0, 0), (1, 0), (n-1, 0), (n, 0)}
else:
c1={(0, 0), (0, 1), (1, 0), (1, 1), (0... | output | 1 | 21,559 | 23 | 43,119 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,560 | 23 | 43,120 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
from math import *
def d(p1x,p1y,p2x,p2y,p3x,p3y,p4x,p4y):
if len(set([(p1x,p1y),(p2x,p2y),(p3x,p3y),(p4x,p4y)])) != 4:
return (0,0)
dis = sqrt((p2x-p1x)*(p2x-p1x) + (p2y-p1y)*(p2y-p1y)) + \
sqrt((p3x-p2x)*(p3x-p2x) + (p3y-p2y)*(p3... | output | 1 | 21,560 | 23 | 43,121 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as poss... | instruction | 0 | 21,561 | 23 | 43,122 |
Tags: brute force, constructive algorithms, geometry, trees
Correct Solution:
```
def dist(v):
ans = 0
for i in range(4):
for j in range(4):
if i != j and v[i] == v[j]:
return 0
for i in range(3):
ans += (v[i][0] - v[i + 1][0]) ** 2 + (v[i][1] - v[i + 1][1]) ** 2
... | output | 1 | 21,561 | 23 | 43,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-to... | instruction | 0 | 21,562 | 23 | 43,124 |
Yes | output | 1 | 21,562 | 23 | 43,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-to... | instruction | 0 | 21,563 | 23 | 43,126 |
Yes | output | 1 | 21,563 | 23 | 43,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-to... | instruction | 0 | 21,564 | 23 | 43,128 |
Yes | output | 1 | 21,564 | 23 | 43,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-to... | instruction | 0 | 21,565 | 23 | 43,130 |
Yes | output | 1 | 21,565 | 23 | 43,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular grid of lattice points from (0, 0) to (n, m) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-to... | instruction | 0 | 21,566 | 23 | 43,132 |
No | output | 1 | 21,566 | 23 | 43,133 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.