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. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,506
23
25,012
Tags: geometry Correct Solution: ``` n = int(input()) l = list(map(int,input().split())) w = 0 c = 0 for i in range(n-1): if l[i] == 2: if i!=0 and i!=n-1: if l[i+1] == 3 or l[i-1] == 3: w = 1 break else: if i == 0: if l[i+1] == 3: w = 1 break else: if l[i-1] == 3: w = 1 break c+=3 if l[i] == 1: if l[i+1] == 2: if l[i-1] == 3 and i!=0: c+=2 else: c+=3 if l[i+1] == 3: c+=4 if l[i] == 3: if l[i+1] == 2: w = 1 break c+=4 if w == 1: print("Infinite") else: print("Finite") print(c) ```
output
1
12,506
23
25,013
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,507
23
25,014
Tags: geometry Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) cnt,f = 0,0 for i in range(1,n): if (a[i-1]-1)*(a[i]-1) > 0: f = 1 cnt += a[i-1]+a[i] if i > 1 and a[i-2] == 3 and a[i-1] == 1 and a[i] == 2: cnt -= 1 if f == 1: print("Infinite") else: print("Finite") print(cnt) ```
output
1
12,507
23
25,015
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,508
23
25,016
Tags: geometry Correct Solution: ``` n = int(input()) a = [int(i) for i in input().split()] total = 0 suma = dict() suma[1, 2] = 3 suma[1, 3] = 4 suma[2, 1] = 3 suma[2, 3] = 9999999999999999999999999999999999999999999999999 suma[3, 1] = 4 suma[3, 2] = 9999999999999999999999999999999999999999999999999 for i, j in zip(a[:-1], a[1:]): total += suma[i, j] for i in range(len(a)-2): if a[i] == 3 and a[i+1] == 1 and a[i+2] == 2: total -= 1 if total < 99999999999999999999999999999: print("Finite") print(total) else: print("Infinite") ```
output
1
12,508
23
25,017
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,509
23
25,018
Tags: geometry Correct Solution: ``` input() a = ''.join(input().split()) res = 0 for aij in zip(a, a[1:]): if '1' in aij: res += sum(map(int, aij)) else: print('Infinite') break else: print('Finite') print(res - a.count('312')) ```
output
1
12,509
23
25,019
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,510
23
25,020
Tags: geometry Correct Solution: ``` def solve(n,A): cnt=0 for i in range(n-1): a0,a1,a2=A[i],A[i+1],A[i+2] if a2==1: if a1==2: cnt+=3 else: cnt+=4 elif a2==2: if a1==1: if a0==3: cnt+=2 else: cnt+=3 else: print('Infinite') return else: if a1==1: cnt+=4 else: print('Infinite') return print('Finite') print(cnt) return n=int(input()) A=[0]+list(map(int,input().split())) solve(n,A) ```
output
1
12,510
23
25,021
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,511
23
25,022
Tags: geometry Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) flag = 0 count = 0 for i in range(1,n): if a[i] == 1: if a[i-1] == 1: flag = 1 break else: if a[i-1] == 2: count += 3 else: count += 4 elif a[i] == 2: if a[i-1] == 3 or a[i-1] == 2: flag = 1 break else: count += 3 else: if a[i-1] == 2 or a[i-1] == 3: flag = 1 break else: count += 4 for i in range(n-2): if(a[i] == 3 and a[i+1] == 1 and a[i+2] == 2): count -= 1 if flag == 1: print("Infinite") else: print("Finite") print(count) ```
output
1
12,511
23
25,023
Provide tags and a correct Python 3 solution for this coding contest problem. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image>
instruction
0
12,512
23
25,024
Tags: geometry Correct Solution: ``` n = int(input()) vals = input().replace(" ", "") if "23" in vals or "32" in vals: print("Infinite") exit(0) else: result = 0 for i in range(len(vals)-1): temp = vals[i] + vals[i+1] if temp == "12" or temp == "21": result += 3 if temp == "31" or temp == "13": result += 4 result -= vals.count("312") print("Finite") print(result) ```
output
1
12,512
23
25,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` import sys n = int(input()) nums = [int(x) for x in input().split()] fig = [] lst = 1 ans = 0 for i in range(0, len(nums)): if(lst != 1 and nums[i] != 1): print("Infinite") sys.exit() if(nums[i] != 1): fig.append(nums[i]) ans += nums[i]+1 if(i != 0 and i != n-1): ans += nums[i]+1; lst = nums[i] for i in range(0, len(fig)-1): if(fig[i] == 3 and fig[i+1] == 2): ans -= 1 print("Finite\n",ans,sep='') ```
instruction
0
12,513
23
25,026
Yes
output
1
12,513
23
25,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` import io, sys, atexit, os import math as ma from sys import exit from decimal import Decimal as dec from itertools import permutations from random import randint as rand def li (): return list (map (int, input ().split ())) def num (): return map (int, input ().split ()) def nu (): return int (input ()) def find_gcd ( x, y ): while (y): x, y = y, x % y return x def lcm ( x, y ): gg = find_gcd (x, y) return (x * y // gg) mm = 1000000007 yp = 0 def solve (): t = 1 for _ in range (t): n = nu () a = li () cc = 0 fl = True for i in range (1, n): if ((a [ i ] == 2 and a [ i - 1 ] == 3) or (a [ i ] == 3 and a [ i - 1 ] == 2)): fl = False break if ((a [ i ] == 1 and a [ i - 1 ] == 2) or ((a [ i ] == 2 and a [ i - 1 ] == 1))): cc += 3 else: if((a [ i ] == 1 and a [ i - 1 ] == 3)): if((i+1)<n): if(a[i+1]==2): cc+=3 else: cc+=4 else: cc+=4 else: cc+=4 if (fl): print ("Finite") print (cc) else: print ("Infinite") if __name__ == "__main__": solve () ```
instruction
0
12,514
23
25,028
Yes
output
1
12,514
23
25,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` def main(): n = int(input()) arr = list(map(int,input().split())) for i in range(n-1): if arr[i] == 2 and arr[i+1] == 3: print('Infinite') return if arr[i] == 3 and arr[i+1] == 2: print('Infinite') return if arr[i] == arr[i+1]: print('Infinite') return ans = 0 for i in range(n-1): if arr[i] == 1 and arr[i+1] == 2: ans += 3 if i > 0 and arr[i-1] == 3: ans -= 1 elif arr[i] == 1 and arr[i+1] == 3: ans += 4 elif arr[i] == 2 and arr[i+1] == 1: ans += 3 elif arr[i] == 3 and arr[i+1] == 1: ans += 4 print('Finite') print(ans) main() ```
instruction
0
12,515
23
25,030
Yes
output
1
12,515
23
25,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` n= int(input()) list= [int (x) for x in input().split()] a= list[0] cnt = 0 prev = a preprev = -1; inf = False; for i in range(1,n): if(list[i] == 1): if(prev == 3) :cnt += 4; else: cnt += 3; elif(list[i]== 2): if(prev == 3): inf = True; else: cnt += 3; else: if(prev == 2): inf = True; else: cnt += 4; if(preprev == 3 and prev == 1 and list[i] == 2) :cnt-=1 if(preprev == 1 and prev == 3 and list[i]== 2) :cnt -= 2; preprev = prev; prev = list[i] if(inf): print("Infinite") else: print("Finite") print(cnt) ```
instruction
0
12,516
23
25,032
Yes
output
1
12,516
23
25,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` def solve(a): res = 0 for i in range(1, len(a)): u, v = min(a[i-1], a[i]), max(a[i-1], a[i]) if u == 2 and v == 3: print("Infinite") return if v == 3: res += 4 else: res += 3 print("Finite") print(res) input() a = list(map(int, input().split())) solve(a) ```
instruction
0
12,517
23
25,034
No
output
1
12,517
23
25,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` # -*- coding: utf-8 -*- """ @Project : CodeForces @File : 1.py @Time : 2019/5/1 21:13 @Author : Koushiro """ if __name__ == "__main__": n = int(input()) nums = list(map(int, input().split())) last=nums[0] ret=0 Infinite=False for i in range(1,len(nums)): if last==1: if nums[i]==1: Infinite=True break elif nums[i]==2: ret+=3 else: ret+=4 last=nums[i] elif last==2: if nums[i]==1: ret+=3 elif nums[i]==2: ret+=3 else: Infinite=True break last=nums[i] else: if nums[i]==1: ret+=4 elif nums[i]==2: Infinite=True break else: Infinite=True break last=nums[i] if Infinite: print('Infinite') else: print('Finite') print(ret) ```
instruction
0
12,518
23
25,036
No
output
1
12,518
23
25,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` n = int(input()) A = list(map(int, input().split())) ans = 0 for i in range(n-1): if A[i] == 1 and A[i+1] == 2: ans += 3 elif A[i] == 1 and A[i+1] == 3: ans += 4 elif A[i] == 2 and A[i+1] == 1: ans += 3 elif A[i] == 2 and A[i+1] == 3: print('Infinite') exit() elif A[i] == 3 and A[i+1] == 1: ans += 4 else: print('Infinite') exit() print('Finite') print(ans) ```
instruction
0
12,519
23
25,038
No
output
1
12,519
23
25,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier. Future students will be asked just a single question. They are given a sequence of integer numbers a_1, a_2, ..., a_n, each number is from 1 to 3 and a_i β‰  a_{i + 1} for each valid i. The i-th number represents a type of the i-th figure: 1. circle; 2. isosceles triangle with the length of height equal to the length of base; 3. square. The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that: * (i + 1)-th figure is inscribed into the i-th one; * each triangle base is parallel to OX; * the triangle is oriented in such a way that the vertex opposite to its base is at the top; * each square sides are parallel to the axes; * for each i from 2 to n figure i has the maximum possible length of side for triangle and square and maximum radius for circle. Note that the construction is unique for some fixed position and size of just the first figure. The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it? So can you pass the math test and enroll into Berland State University? Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” the number of figures. The second line contains n integer numbers a_1, a_2, ..., a_n (1 ≀ a_i ≀ 3, a_i β‰  a_{i + 1}) β€” types of the figures. Output The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise. If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type. Examples Input 3 2 1 3 Output Finite 7 Input 3 1 2 3 Output Infinite Note Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way. The distinct points where figures touch are marked red. In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points. <image> Submitted Solution: ``` # import sys # sys.stdin = open("#input.txt", "r") def solve(n,ls): ans = 0 for i in range(n-1): s = ls[i] + ls[i+1] if s in [3,4]: ans += s else: return False,0 return True,ans n = int(input()) ls = list(map(int, input().split())) fin, an = solve(n,ls) if fin: print("Finite") print(an) else: print("Infinite") ```
instruction
0
12,520
23
25,040
No
output
1
12,520
23
25,041
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,586
23
25,172
Tags: geometry Correct Solution: ``` import math n = int(input()) kords = list() for _ in range(n): kords.append(list(map(int, input().split()))) if n % 2 == 0: first_part = kords[:len(kords) // 2 + 1] second_part = kords[len(kords) // 2:] + [kords[0]] for i in range(n // 2): if abs( first_part[i][0] - second_part[i + 1][0] ) == abs( first_part[i + 1][0] - second_part[i][0] ) and abs( first_part[i + 1][1] - second_part[i][1] ) == abs( first_part[i][1] - second_part[i + 1][1] ): continue else: print('NO') break else: print('YES') else: print('NO') ```
output
1
12,586
23
25,173
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,587
23
25,174
Tags: geometry Correct Solution: ``` import sys n = int(sys.stdin.readline().strip()) X = [] Y = [] for i in range (0, n): x, y = list(map(int, sys.stdin.readline().strip().split())) X.append(x) Y.append(y) X.append(X[0]) Y.append(Y[0]) if n % 2 == 1: print("NO") else: v = True m = n // 2 for i in range (0, m): if X[i+1]-X[i] != X[i+m]-X[i+m+1]: v = False if Y[i+1]-Y[i] != Y[i+m]-Y[i+m+1]: v = False if v == True: print("YES") else: print("NO") ```
output
1
12,587
23
25,175
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,588
23
25,176
Tags: geometry Correct Solution: ``` from sys import stdin from collections import deque mod = 10**9 + 7 import sys # sys.setrecursionlimit(10**6) from queue import PriorityQueue # def rl(): # return [int(w) for w in stdin.readline().split()] from bisect import bisect_right from bisect import bisect_left from collections import defaultdict from math import sqrt,factorial,gcd,log2,inf,ceil # map(int,input().split()) # # l = list(map(int,input().split())) # from itertools import permutations import heapq # input = lambda: sys.stdin.readline().rstrip() input = lambda : sys.stdin.readline().rstrip() from sys import stdin, stdout from heapq import heapify, heappush, heappop from itertools import permutations n = int(input()) ba = [] if n%2!=0: print('NO') exit() for i in range(n): a,b = map(int,input().split()) ba.append([a,b]) slope = [] seti = set() for i in range(n): a,b = ba[i] c,d = ba[(i+n//2)%n] x,y = (a+c)/2,(b+d)/2 seti.add((x,y)) # print(seti) if len(seti) == 1: print('YES') else: print('NO') ```
output
1
12,588
23
25,177
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,589
23
25,178
Tags: geometry Correct Solution: ``` # https://codeforces.com/contest/1300/problem/D n = int(input()) p = [list(map(int, input().split())) for _ in range(n)] def is_parallel(x1, y1, x2, y2): if x1 == -x2 and y1 == -y2: return True return False flg = True if n % 2 == 1: flg=False else: for i in range(n//2): p1, p2 = p[i], p[i+1] p3, p4 = p[i+n//2], p[(i+n//2+1)%n] flg = is_parallel(p2[0]-p1[0], p2[1]-p1[1], p4[0]-p3[0], p4[1]-p3[1]) if flg==False: break if flg==False: print('no') else: print('yes') ```
output
1
12,589
23
25,179
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,590
23
25,180
Tags: geometry Correct Solution: ``` def main(): N = int(input()) if N % 2: print("NO") return pts = [complex(*map(int, input().strip().split())) for _ in range(N)] for i in range(N // 2): if pts[i] + pts[i + N // 2] != pts[0] + pts[N // 2]: print("NO") return print("YES") main() ```
output
1
12,590
23
25,181
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,591
23
25,182
Tags: geometry Correct Solution: ``` def main(): from sys import stdin, stdout n = int(stdin.readline()) inp = tuple((tuple(map(float, stdin.readline().split())) for _ in range(n))) avg_xt2 = sum((inp_i[0] for inp_i in inp)) / n * 2 avg_yt2 = sum((inp_i[1] for inp_i in inp)) / n * 2 sym = tuple(((avg_xt2 - x, avg_yt2 - y) for (x, y) in inp)) nd2 = n // 2 stdout.write("YES" if inp == sym[nd2:] + sym[:nd2] else "NO") main() ```
output
1
12,591
23
25,183
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,592
23
25,184
Tags: geometry Correct Solution: ``` from __future__ import division N = int(input()) points = [] for p in range(N): x, y = [int(x) for x in input().split()] points.append((x, y)) # T always has central symmetry # To determine: if P has a point of central symmetry # function to determine the bottom and top most points of our polygon def bot_top(points): y_val = [] for p in points: y_val.append(p[1]) minn = y_val[0] maxx = y_val[1] for y in y_val: if y < minn: minn = y if y > maxx: maxx = y return minn, maxx def left_right(points): y_val = [] for p in points: y_val.append(p[0]) minn = y_val[0] maxx = y_val[0] for y in y_val: if y < minn: minn = y if y > maxx: maxx = y return minn, maxx # point of central symmetry def cs(): x_1, x_2 = left_right(points) y_1, y_2 = bot_top(points) return (x_2 + x_1)/2, (y_1 + y_2)/2 def midpoint(p1, p2): x_1, y_1 = p1 x_2, y_2 = p2 return (x_2 + x_1)/2, (y_2 + y_1)/2 CS = cs() zz = True if N % 2 == 0: for pos in range(int(N/2)): p1 = points[pos] p2 = points[pos + int(N/2)] mp = midpoint(p1, p2) if mp != CS: zz = False break if zz: print ('YES') else: print ('NO') else: print ('NO') ```
output
1
12,592
23
25,185
Provide tags and a correct Python 3 solution for this coding contest problem. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image>
instruction
0
12,593
23
25,186
Tags: geometry Correct Solution: ``` def Input(): tem = input().split() ans = [] for it in tem: ans.append(int(it)) return ans n = Input()[0] a = [] ma = {} for i in range(n): x, y = Input() a.append((x,y)) a.append(a[0]) flag = True for i in range(1,n+1): if (a[i][0]-a[i-1][0])==0: v = None else: v = (a[i][1]-a[i-1][1])/(a[i][0]-a[i-1][0]) dis = ((a[i][1]-a[i-1][1])**2+(a[i][0]-a[i-1][0])**2)**0.5 if v not in ma: ma[v]=dis else: if abs(dis-ma[v])<0.00000001: del ma[v] else: flag = False break if len(ma)>0: flag = False if flag: print('YES') else: print('NO') ```
output
1
12,593
23
25,187
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` def mid(a,b): return [(a[0]+b[0])/2,(a[1]+b[1])/2] n=int(input()) l=[] for i in range(n): l.append(list(map(int,input().split()))) if n%2==0: k=mid(l[0],l[n//2]) flag=True for i in range(1,n//2): if k!=mid(l[i],l[n//2+i]): flag=False break if flag==True: print("YES") else: print("NO") else: print("NO") ```
instruction
0
12,594
23
25,188
Yes
output
1
12,594
23
25,189
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` from sys import stdin from os import getenv if not getenv('PYCHARM'): def input(): return next(stdin)[:-1] def main(): n = int(input()) pp = [] for _ in range(n): pp.append(list(map(int, input().split()))) if n%2 != 0: print("NO") return for i in range(n//2): x1 = pp[i+1][0] - pp[i][0] y1 = pp[i+1][1] - pp[i][1] x2 = pp[(i+1+n//2) % n][0] - pp[i+n//2][0] y2 = pp[(i+1+n//2) % n][1] - pp[i+n//2][1] if x1 != -x2 or y1 != -y2: print("NO") return print("YES") if __name__ == "__main__": main() ```
instruction
0
12,595
23
25,190
Yes
output
1
12,595
23
25,191
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` import sys input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok) def isParallel(p1a,p1b,p2a,p2b): dx1=p1a[0]-p1b[0] dy1=p1a[1]-p1b[1] dx2=p2a[0]-p2b[0] dy2=p2a[1]-p2b[1] return dx1==dx2 and dy1==dy2 n=int(input()) xy=[] #[[x,y]] for _ in range(n): a,b=[int(z) for z in input().split()] xy.append([a,b]) #YES if each line is parallel to another line xy.sort(key=lambda z:(z[0],z[1])) #sort by x then y. #xy[0] will match with xy[n-1],xy[1] will match with xy[n-2] etc. if n%2==1: print('NO') else: ans='YES' for i in range(n//2): p1a=xy[i] p1b=xy[i+1] j=n-1-i p2a=xy[j-1] p2b=xy[j] if not isParallel(p1a,p1b,p2a,p2b): ans='NO' break print(ans) ```
instruction
0
12,596
23
25,192
Yes
output
1
12,596
23
25,193
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` import os,io import sys input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n=int(input()) shape=[] for _ in range(n): x,y=map(int,input().split()) shape.append([x,y]) if n%2==1: print('NO') sys.exit() for i in range(n): if shape[i][0]-shape[i-1][0]!=shape[(n//2+i-1)%n][0]-shape[(n//2+i)%n][0]: print('NO') sys.exit() if shape[i][1]-shape[i-1][1]!=shape[(n//2+i-1)%n][1]-shape[(n//2+i)%n][1]: print('NO') sys.exit() print('YES') ```
instruction
0
12,597
23
25,194
Yes
output
1
12,597
23
25,195
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` import sys input = sys.stdin.readline import math import copy import collections from collections import deque n = int(input()) points = [] for i in range(n): points.append(list(map(int,input().split()))) vec = [] for i in range(n): a = points[i] b = points[(i+1)%n] vec.append([b[0]-a[0],b[1]-a[1]]) dirs = set() for ele in vec: x,y = ele d = math.atan(y/x) if d<0: d+=math.pi if d in dirs: dirs.remove(d) else: dirs.add(d) if dirs: print("NO") else: print("YES") ```
instruction
0
12,598
23
25,196
No
output
1
12,598
23
25,197
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` # from math import factorial as fac from collections import defaultdict # from copy import deepcopy import sys, math f = None try: f = open('q1.input', 'r') except IOError: f = sys.stdin if 'xrange' in dir(__builtins__): range = xrange # print(f.readline()) sys.setrecursionlimit(10**2) def print_case_iterable(case_num, iterable): print("Case #{}: {}".format(case_num," ".join(map(str,iterable)))) def print_case_number(case_num, iterable): print("Case #{}: {}".format(case_num,iterable)) def print_iterable(A): print (' '.join(A)) def read_int(): return int(f.readline().strip()) def read_int_array(): return [int(x) for x in f.readline().strip().split(" ")] def rns(): a = [x for x in f.readline().split(" ")] return int(a[0]), a[1].strip() def read_string(): return list(f.readline().strip()) def ri(): return int(f.readline().strip()) def ria(): return [int(x) for x in f.readline().strip().split(" ")] def rns(): a = [x for x in f.readline().split(" ")] return int(a[0]), a[1].strip() def rs(): return list(f.readline().strip()) def bi(x): return bin(x)[2:] from collections import deque import math NUMBER = 10**9 + 7 # NUMBER = 998244353 def factorial(n) : M = NUMBER f = 1 for i in range(1, n + 1): f = (f * i) % M # Now f never can # exceed 10^9+7 return f def mult(a,b): return (a * b) % NUMBER def minus(a , b): return (a - b) % NUMBER def plus(a , b): return (a + b) % NUMBER def egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y) def modinv(a): m = NUMBER g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m def choose(n,k): if n < k: assert false return mult(factorial(n), modinv(mult(factorial(k),factorial(n-k)))) % NUMBER from collections import deque, defaultdict import heapq from types import GeneratorType def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc def dfs(g, timeIn, timeOut,depths,parents): # assign In-time to node u cnt = 0 # node, neig_i, parent, depth stack = [[1,0,0,0]] while stack: v,neig_i,parent,depth = stack[-1] parents[v] = parent depths[v] = depth # print (v) if neig_i == 0: timeIn[v] = cnt cnt+=1 while neig_i < len(g[v]): u = g[v][neig_i] if u == parent: neig_i+=1 continue stack[-1][1] = neig_i + 1 stack.append([u,0,v,depth+1]) break if neig_i == len(g[v]): stack.pop() timeOut[v] = cnt cnt += 1 # def isAncestor(u: int, v: int, timeIn: list, timeOut: list) -> str: # return timeIn[u] <= timeIn[v] and timeOut[v] <= timeOut[u] cnt = 0 @bootstrap def dfs(v,adj,timeIn, timeOut,depths,parents,parent=0,depth=0): global cnt parents[v] = parent depths[v] = depth timeIn[v] = cnt cnt+=1 for u in adj[v]: if u == parent: continue yield dfs(u,adj,timeIn,timeOut,depths,parents,v,depth+1) timeOut[v] = cnt cnt+=1 yield def gcd(a,b): if a == 0: return b return gcd(b % a, a) # Function to return LCM of two numbers def lcm(a,b): return (a*b) / gcd(a,b) def get_num_2_5(n): twos = 0 fives = 0 while n>0 and n%2 == 0: n//=2 twos+=1 while n>0 and n%5 == 0: n//=5 fives+=1 return (twos,fives) def shift(a,i,num): for _ in range(num): a[i],a[i+1],a[i+2] = a[i+2],a[i],a[i+1] def equal(x,y): return abs(x-y) <= 1e-9 # def leq(x,y): # return x-y <= 1e-9 def solution(a,n): if n > 3: return 'yes' return 'no' def main(): T = 1 # T = ri() for i in range(T): n = ri() # s = rs() data = [] for j in range(n): data.append(ria()) # n,m = ria() # a = ria() # b = ria() x = solution(data,n) # continue if 'xrange' not in dir(__builtins__): print(x) else: print >>output,str(x)# "Case #"+str(i+1)+':', if 'xrange' in dir(__builtins__): print(output.getvalue()) output.close() if 'xrange' in dir(__builtins__): import cStringIO output = cStringIO.StringIO() #example usage: # for l in res: # print >>output, str(len(l)) + ' ' + ' '.join(l) if __name__ == '__main__': main() ```
instruction
0
12,599
23
25,198
No
output
1
12,599
23
25,199
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` from collections import defaultdict from math import gcd n = int(input()) points = [] for i in range(n): x, y = (int(i) for i in input().split(' ')) points.append((x, y)) points.append(points[0]) if n % 2 == 1: print("NO") else: d = defaultdict(lambda: 0) for i in range(len(points) - 1): x1, y1 = points[i] x2, y2 = points[i + 1] lcm = gcd((y2 - y1), (x2 - x1)) k1 = (y2 - y1) // lcm k2 = (x2 - x1) // lcm d[(k1, k2)] += 1 flag = True for i in d: if d[i] % 2 != 0: flag = False break if flag: print("YES") else: print("NO") ```
instruction
0
12,600
23
25,200
No
output
1
12,600
23
25,201
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Guy-Manuel and Thomas are going to build a polygon spaceship. You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \overrightarrow {(x,y)}. The picture below depicts an example of the translation: <image> Define T as a set of points which is the union of all P(x,y) such that the origin (0,0) lies in P(x,y) (both strictly inside and on the boundary). There is also an equivalent definition: a point (x,y) lies in T only if there are two points A,B in P such that \overrightarrow {AB} = \overrightarrow {(x,y)}. One can prove T is a polygon too. For example, if P is a regular triangle then T is a regular hexagon. At the picture below P is drawn in black and some P(x,y) which contain the origin are drawn in colored: <image> The spaceship has the best aerodynamic performance if P and T are similar. Your task is to check whether the polygons P and T are [similar](https://tinyurl.com/vp5m7vl). Input The first line of input will contain a single integer n (3 ≀ n ≀ 10^5) β€” the number of points. The i-th of the next n lines contains two integers x_i, y_i (|x_i|, |y_i| ≀ 10^9), denoting the coordinates of the i-th vertex. It is guaranteed that these points are listed in counterclockwise order and these points form a strictly convex polygon. Output Output "YES" in a separate line, if P and T are similar. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower). Examples Input 4 1 0 4 1 3 4 0 3 Output YES Input 3 100 86 50 0 150 0 Output nO Input 8 0 0 1 0 2 1 3 3 4 6 3 6 2 5 1 3 Output YES Note The following image shows the first sample: both P and T are squares. The second sample was shown in the statements. <image> Submitted Solution: ``` q = int(input()) vertexP = [] z = True for x in range(q): x, y = input().split() x, y = float(x), float(y) vertexP.append([x, y]) minX = min([each[0] for each in vertexP]) maxX = max([each[0] for each in vertexP]) minY = min([each[1] for each in vertexP]) maxY = max([each[1] for each in vertexP]) cOmX = minX+(maxX-minX)/2 cOmY = minY+(maxY-minY)/2 print(cOmX) print(cOmY) for each in vertexP: each[0] -= cOmX each[1] -= cOmY #print(vertexP) for each in vertexP: #print([each[0]*-1, each[1]*-1]) if not [each[0]*-1, each[1]*-1] in vertexP: z = False break if z: print("YES") else: print("nO") ```
instruction
0
12,601
23
25,202
No
output
1
12,601
23
25,203
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,732
23
25,464
Tags: implementation, math Correct Solution: ``` R=lambda:map(int,input().split()) a1,b1,c1=R() a2,b2,c2=R() Z=lambda x,y,z:not x and not y and z if a1*b2-a2*b1!=0: print("1") elif Z(a1,b1,c1) or Z(a2,b2,c2) or c1*b2-b1*c2 or c1*a2-c2*a1: print("0") else: print("-1") ```
output
1
12,732
23
25,465
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,733
23
25,466
Tags: implementation, math Correct Solution: ``` a1, b1, c1 = [int(i) for i in input().split()] a2, b2, c2 = [int(i) for i in input().split()] if(b1 != 0 and b2 != 0): #paralelas: if(a1/b1 == a2/b2): if(c1/b1 == c2/b2): print(-1) #paralelas iguais else: print(0) #paralelas diferentes else: print(1) elif(b1 == 0 and b2 == 0): if(a1 != 0): if(a2 != 0): if(c1/a1 == c2/a2): print(-1) else: print(0) else: if(c2 == 0): print(-1) else: print(0) if(a1 == 0 and a2 != 0): if(c1 == 0): print(-1) else: print(0) if(a1 == 0 and a2 == 0): if(c1 == 0 and c2 == 0): print(-1) else: print(0) elif(b1 == 0 and b2 != 0): if(a1 != 0 and a2 != 0): print(1) elif(a1 == 0 and a2 != 0): if(c1 == 0): print(-1) else: print(0) elif(a1 != 0 and a2 == 0): print(1) elif(a1 == 0 and a2 == 0): if(c1 == 0): print(-1) else: print(0) elif(b1 != 0 and b2 == 0): if(a1 != 0 and a2 != 0): print(1) elif(a1 != 0 and a2 == 0): if(c2 == 0): print(-1) else: print(0) elif(a1 == 0 and a2 != 0): print(1) elif(a1 == 0 and a2 == 0): if(c2 == 0): print(-1) else: print(0) else: print(1) ```
output
1
12,733
23
25,467
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,734
23
25,468
Tags: implementation, math Correct Solution: ``` R = lambda:map(int, input().split()) a1, b1, c1 = R() a2, b2, c2 = R() if a1 == b1 == 0 and c1 != 0 or a2 == b2 == 0 and c2 != 0: print(0) elif a1 == b1 == c1 == 0 or a2 == b2 == c2 == 0: print(-1) else: if c1 != 0: a1 /= c1 b1 /= c1 c1 = 1 if c2 != 0: a2 /= c2 b2 /= c2 c2 = 1 if a1 * b2 - a2 * b1 == 0: if c1 == c2 and a1 == a2 and b1 == b2 or c1 == c2 == 0: print(-1) else: print(0) else: print(1) ```
output
1
12,734
23
25,469
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,735
23
25,470
Tags: implementation, math Correct Solution: ``` a1,b1,c1=list(map(int,input().split())) a2,b2,c2=list(map(int,input().split())) if (a1==0 and b1==0 and c1!=0) or (a2==0 and b2==0 and c2!=0): c=0 print(c) elif (a2==1 and b2==-1 and c2==-1 and c1!=-1): c=-1 print(c) elif (a2==0 and b2==0 and c2==0): c=-1 print(c) elif (a1==0 and b1==0 and c1==0): c=-1 print(c) elif (b2==0 and b1==0 and c2!=0 and c1!=0 and a2==7): c=0 print(c) elif (b2==0 and b1==0 and c2!=0 and c1!=0 and a2!=2): c=-1 print(c) elif (a1==0 and b1==0 and c1 ==0) and (a2==0 and b2==1 and c2==-1): c=-1 print(c) elif (a1==1 and b1==0 and c1==0) and (a2==1 and b2==0 and c2==0): c=-1 print(c) elif (a1==1 and b1==0 and c1 ==1) and (a2==-1 and b2==0 and c2==-1): c=-1 print(c) elif (a1==0 and b1==0 and c1 ==0) and (a2==0 and b2==0 and c2==0): c=-1 print(c) elif (a1==1 and b1==0 and c1 ==0) and (a2==1 and b2==0 and c2==1): c=-1 print(c) elif (a1==1 and b1==1 and c1 ==1) and (a2==0 and b2==0 and c2==0): c=-1 print(c) elif (a1*b2==0 and a2*b1==0) and (b1*c2==0 and b2*c1==0): c=0 print(c) elif(a1*b2==a2*b1) and (b1*c2==b2*c1): c=-1 print(c) elif(a1*b2==a2*b1) and (b1*c2!=b2*c1): c=0 print(c) else: c=1 print(c) ```
output
1
12,735
23
25,471
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,736
23
25,472
Tags: implementation, math Correct Solution: ``` #codeforces 21b intersection, math def readGen(transform): while (True): n=0 tmp=input().split() m=len(tmp) while (n<m): yield(transform(tmp[n])) n+=1 readint=readGen(int) A1,B1,C1=next(readint),next(readint),next(readint) A2,B2,C2=next(readint),next(readint),next(readint) def cross(a,b,c,d): return a*d-b*c def zero(A1,B1): return A1**2 + B1**2 == 0 def lineIntersect(A1,B1,C1,A2,B2,C2): if (cross(A1,B1,A2,B2)==0): if (cross(A1,C1,A2,C2)==0 and cross(B1,C1,B2,C2)==0): # same line return -1 else: # parallel return 0 else: # cross return 1 def judge(A1,B1,C1,A2,B2,C2): if (zero(A1,B1) and C1!=0): return 0 if (zero(A2,B2) and C2!=0): return 0 if (not zero(A1,B1) and not zero(A2,B2)): # line and line return lineIntersect(A1,B1,C1,A2,B2,C2) else: return -1 print(judge(A1,B1,C1,A2,B2,C2)) ```
output
1
12,736
23
25,473
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,737
23
25,474
Tags: implementation, math Correct Solution: ``` a1, b1, c1 = input().split(' ') a2, b2, c2 = input().split(' ') a1 = int(a1) b1 = int(b1) c1 = int(c1) a2 = int(a2) b2 = int(b2) c2 = int(c2) if((a1 == 0 and b1 == 0) and (a2 == 0 and b2 == 0) and c1 != c2): print(0) exit() if((a1 == 0 and b1 == 0 and c1 == 0) or (a2 == 0 and b2 == 0 and c2 == 0)): print(-1) exit() if((a1 == 0 and b1 == 0 and c1 != 0) or (a2 == 0 and b2 == 0 and c2 != 0) and (c1 == c2)): print(0) exit() if(a1 * b2 == b1 * a2 and b2 * c1 == c2 * b1 and c1 * a2 == c2 * a1): print(-1) exit() if(((a1 * b2) - (a2 * b1)) == 0): print(0) exit() print(1) exit() ```
output
1
12,737
23
25,475
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,738
23
25,476
Tags: implementation, math Correct Solution: ``` #! /usr/bin/python3 def solve(): x, y, z = map(int, input().strip().split()) a, b, c = map(int, input().strip().split()) ret = 0 if (x * b == y * a): if (y == 0 and b == 0): if c * x == a * z: ret = -1 else: ret = 0 elif z * b == y * c: ret = -1 else: ret = 0 else: ret = 1 if (x == y and y == a and a == b and b == 0): if (z == c and z == 0): ret = -1 else: ret = 0 print(ret) solve() ```
output
1
12,738
23
25,477
Provide tags and a correct Python 3 solution for this coding contest problem. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1
instruction
0
12,739
23
25,478
Tags: implementation, math Correct Solution: ``` def fazTudo(): ar,br,cr = map(int,input().split()); aw,bw,cw = map(int,input().split()); res=1; if(br==0 and bw==0): if(ar==0 and cr!=0 or aw==0 and cw!=0): print(0); return; if(ar==0 and br==0 and cr==0 or aw==0 and bw==0 and cw==0): print(-1); return; if(ar==0 and cr==0 or aw==0 and cw==0): print(-1); return; if(cr/ar==cw/aw): print(-1) return; if(ar==aw and cr!=cw): print(0); return; if(ar!=aw): print(0); return; if(br==0): if(ar==0 and cr!=0): print(0); return; if(ar==0 and br==0 and cr==0 or aw==0 and bw==0 and cw==0): print(-1); return; if(ar==0 and cr!=0): print(0); return; if(-aw/bw == ar and -cw/bw==cr): print(1) return; if(-aw/bw == ar and -cw/bw!=cr): print(1); return; print(1); return; if(bw==0): if(aw==0 and cw!=0): print(0); return; if(ar==0 and br==0 and cr==0 or aw==0 and bw==0 and cw==0): print(-1); return; if(aw==0 and cw!=0): print(0); return; if(-ar/br == aw and -cr/br==cw): print(1) return; if(-ar/br == aw and -cr/br!=cw): print(1); return; print(1); return; a1 = -(ar/br); b1 = -(cr/br); a2 = -(aw/bw); b2 = -(cw/bw); if(a1==a2): if(b1==b2): res = -1; else: res = 0; print(res); fazTudo(); ```
output
1
12,739
23
25,479
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` a1,b1,c1=list(map(int,input().split())) a2,b2,c2=list(map(int,input().split())) if (a1==0 and b1==0 and c1!=0) or (a2==0 and b2==0 and c2!=0): c=0 print(c) elif (a2==1 and b2==-1 and c2==-1 and c1!=-1): c=-1 print(c) elif (a2==0 and b2==0 and c2==0): c=-1 print(c) elif (a1==0 and b1==0 and c1==0): c=-1 print(c) elif (b2==0 and b1==0 and c2!=0 and c1!=0 and a2==7): c=0 print(c) elif (b2==0 and b1==0 and c2!=0 and c1!=0 and a2!=2): c=-1 print(c) elif (a1==0 and b1==0 and c1 ==0) and (a2==0 and b2==1 and c2==-1): c=-1 print(c) elif (a1==1 and b1==0 and c1==0) and (a2==1 and b2==0 and c2==0): c=-1 print(c) elif (a1==1 and b1==0 and c1 ==1) and (a2==-1 and b2==0 and c2==-1): c=-1 print(c) elif (a1==1 and b1==1 and c1 ==1) and (a2==0 and b2==0 and c2==0): c=-1 print(c) elif (a1*b2==0 and a2*b1==0) and (b1*c2==0 and b2*c1==0): c=0 print(c) elif(a1*b2==a2*b1) and (b1*c2==b2*c1): c=-1 print(c) elif(a1*b2==a2*b1) and (b1*c2!=b2*c1): c=0 print(c) else: c=1 print(c) ```
instruction
0
12,740
23
25,480
Yes
output
1
12,740
23
25,481
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` def intersection(lst1, lst2): if lst1[0] * lst2[1] != lst1[1] * lst2[0]: return 1 elif lst1[0] == lst1[1] == lst2[0] == lst2[1] == 0 and ( lst1[2] != 0 and lst2[2] == 0 or lst1[2] == 0 and lst2[2] != 0 or lst1[2] != 0 and lst2[2] != 0): return 0 elif lst1[0] * lst2[1] == lst1[1] * lst2[0] and ( lst1[2] * lst2[1] != lst2[2] * lst1[1] or lst1[0] * lst2[2] != lst1[2] * lst2[0]): return 0 elif lst1[0] * lst2[1] == lst1[1] * lst2[0] and lst1[2] * lst2[1] == lst2[2] * lst1[1]: return -1 elif lst2[0] * lst1[1] == - lst1[0] * lst2[1] and lst1[2] == lst1[2] == 0: return 1 a = [int(i) for i in input().split()] b = [int(j) for j in input().split()] print(intersection(a, b)) ```
instruction
0
12,741
23
25,482
Yes
output
1
12,741
23
25,483
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` A1, B1, C1 = tuple(map(int, input().split(" "))) A2, B2, C2 = tuple(map(int, input().split(" "))) D = A1*B2 - A2*B1 Dx = C1*B2 - C2*B1 Dy = C2*A1 - C1*A2 if(A1 == 0 and B1 == 0 and C1 != 0): print(0) elif(A2 == 0 and B2 == 0 and C2 != 0): print(0) elif(D == 0): if(Dx == 0 and Dy == 0): print(-1) else: print(0) else: print(1) ```
instruction
0
12,742
23
25,484
Yes
output
1
12,742
23
25,485
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` a1, b1, c1 = [int(i) for i in input().split()] a2, b2, c2 = [int(i) for i in input().split()] if c1 != c2 and (a1 == 0 and b1 == 0) and (a2 == 0 and b2 == 0) : print(0) elif (a1 == 0 and b1 == 0 and c1 == 0) or (a2 == 0 and b2 == 0 and c2 == 0) : print(-1) elif (a1 == 0 and b1 == 0 and c1 != 0) or (a2 == 0 and b2 == 0 and c2 != 0) and (c1 == c2): print(0) elif a1 * b2 == b1 * a2 and b2 * c1 == c2 * b1 and c1 * a2 == c2 * a1 : print(-1) elif ((a1 * b2) - (a2 * b1)) == 0: print(0) else: print(1) ```
instruction
0
12,743
23
25,486
Yes
output
1
12,743
23
25,487
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` def intersection(lst1, lst2): if lst1[0] * lst2[1] != lst1[1] * lst2[0]: return 1 elif lst1[0] * lst2[1] == lst1[1] * lst2[0] and ( lst1[2] * lst2[1] != lst2[2] * lst1[1] or lst1[0] * lst2[2] != lst1[2] * lst2[0]): return 0 elif lst1[0] * lst2[1] == lst1[1] * lst2[0] and lst1[2] * lst2[1] == lst2[2] * lst1[1]: return -1 elif lst2[0] * lst1[1] == - lst1[0] * lst2[1] and lst1[2] == lst1[2] == 0: return 1 elif lst1[0] * lst2[1] == lst1[1] * lst2[0] and (lst2[2] == 0 and lst1[2] != 0 or lst2[2] != 0 and lst1[2] == 0): return 0 a = [int(i) for i in input().split()] b = [int(j) for j in input().split()] print(intersection(a, b)) ```
instruction
0
12,745
23
25,490
No
output
1
12,745
23
25,491
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` R = lambda:map(int, input().split()) a1, b1, c1 = R() a2, b2, c2 = R() if a1 * b2 - a2 * b1 == 0: if c1 == c2 or a1 == b1 == c1 == 0 or a2 == b2 == c2 == 0: print(-1) else: print(0) else: print(1) ```
instruction
0
12,746
23
25,492
No
output
1
12,746
23
25,493
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0. Write the program which finds the number of points in the intersection of two given sets. Input The first line of the input contains three integer numbers A1, B1, C1 separated by space. The second line contains three integer numbers A2, B2, C2 separated by space. All the numbers are between -100 and 100, inclusive. Output Print the number of points in the intersection or -1 if there are infinite number of points. Examples Input 1 1 0 2 2 0 Output -1 Input 1 1 0 2 -2 0 Output 1 Submitted Solution: ``` a1, b1, c1 = [int(x) for x in input().split()] a2, b2, c2 = [int(x) for x in input().split()] det = (a1*b2) - (a2*b1) if det!=0: print(1) elif ((a1*b2)==(b1*a2) and (a1*c2)==(a2*c1) and (b1*c2)==(b2*c1)) and not (a1==0 and b1==0 and a2==0 and b2==0 and c1!=c2): print(-1) else: print(0) ```
instruction
0
12,747
23
25,494
No
output
1
12,747
23
25,495
Provide tags and a correct Python 3 solution for this coding contest problem. There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices. Input The first line contains two integers a, b (1 ≀ a, b ≀ 1000), separated by a single space. Output In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β€” the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value. Examples Input 1 1 Output NO Input 5 5 Output YES 2 1 5 5 -2 4 Input 5 10 Output YES -10 4 -2 -2 1 2
instruction
0
12,809
23
25,618
Tags: brute force, geometry, implementation, math Correct Solution: ``` a, b = map(int, input().split()) s = [i*i for i in range(1, a)] t = [i*i for i in range(1, b)] def r(x): return int(x**0.5) for i in s: if a*a-i in s: for j in t: if b*b-j in t: if i!=j and i*j-(a*a-i)*(b*b-j) == 0: print('YES') print(r(i),r(a*a-i)) print(r(j),-r(b*b-j)) print(0,0) exit() print('NO') ```
output
1
12,809
23
25,619
Provide tags and a correct Python 3 solution for this coding contest problem. There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices. Input The first line contains two integers a, b (1 ≀ a, b ≀ 1000), separated by a single space. Output In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β€” the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value. Examples Input 1 1 Output NO Input 5 5 Output YES 2 1 5 5 -2 4 Input 5 10 Output YES -10 4 -2 -2 1 2
instruction
0
12,810
23
25,620
Tags: brute force, geometry, implementation, math Correct Solution: ``` a,b=list(map(int,input().split())) f=0 x1,y1,x2,y2=0,0,0,0 for x in range(1,a+1): for y in range(1,a+1): if (x**2+y**2==a**2) and (x!=0 and y!=0): m=-x/y if float(int(b/(1+m**2)**(0.5)))==b/(1+m**2)**(0.5) and float(int((b*m)/(1+m**2)**(0.5)))==(b*m)/(1+m**2)**(0.5): x1=x y1=y x2=int(b/(1+m**2)**(0.5)) y2=int((b*m)/(1+m**2)**(0.5)) if x1==x2 or y1==y2: x2=-x2 y2=-y2 f=1 break if f: break if f: print('YES') print(0,0) print(x1,y1) print(x2,y2) else: print('NO') ```
output
1
12,810
23
25,621
Provide tags and a correct Python 3 solution for this coding contest problem. There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices. Input The first line contains two integers a, b (1 ≀ a, b ≀ 1000), separated by a single space. Output In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β€” the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value. Examples Input 1 1 Output NO Input 5 5 Output YES 2 1 5 5 -2 4 Input 5 10 Output YES -10 4 -2 -2 1 2
instruction
0
12,811
23
25,622
Tags: brute force, geometry, implementation, math Correct Solution: ``` a,b=map(int,input().split()) def get(a): return list([i,j] for i in range(1,a) for j in range(1,a) if i*i+j*j==a*a) A=get(a) B=get(b) for [a,b] in A: for [c,d] in B: if a*c==b*d and b!=d: print("YES\n0 0") print(-a,b) print(c,d) exit(0) print("NO") ```
output
1
12,811
23
25,623
Provide tags and a correct Python 3 solution for this coding contest problem. There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices. Input The first line contains two integers a, b (1 ≀ a, b ≀ 1000), separated by a single space. Output In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers β€” the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value. Examples Input 1 1 Output NO Input 5 5 Output YES 2 1 5 5 -2 4 Input 5 10 Output YES -10 4 -2 -2 1 2
instruction
0
12,812
23
25,624
Tags: brute force, geometry, implementation, math Correct Solution: ``` sqrt = {i * i: i for i in range(1, 1000)} a, b = map(int, input().split()) for y in range(1, a): x2 = a * a - y * y if x2 in sqrt: x = sqrt[x2] if b * y % a == 0 and b * x % a == 0 and b * x // a != y: print('YES') print(-x, y) print(0, 0) print(b * y // a, b * x // a) exit() print('NO') ```
output
1
12,812
23
25,625