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.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1". | instruction | 0 | 65,346 | 23 | 130,692 |
Tags: constructive algorithms, geometry, math
Correct Solution:
```
import sys
n,a=(int(a) for a in input('').split())
res=-1
diff=sys.maxsize
for i in range(1,n-1):
resangle=180*i/n
if abs(resangle-a)<diff:
diff=abs(resangle-a)
res=i
print('1 '+str(res+2)+' '+str(res+1))
``` | output | 1 | 65,346 | 23 | 130,693 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1". | instruction | 0 | 65,347 | 23 | 130,694 |
Tags: constructive algorithms, geometry, math
Correct Solution:
```
n, a = list(map(int, input().split()))
c = round(n*a / 180.0) + 2
if c == 2:
c = 3
if c > n:
c = n
print(2, 1, c)
``` | output | 1 | 65,347 | 23 | 130,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1". | instruction | 0 | 65,348 | 23 | 130,696 |
Tags: constructive algorithms, geometry, math
Correct Solution:
```
n,a = map(int,input().split())
k = (a*n) // 180
asdf = (a*n) % 180
if(asdf > 90):
ans = k+1
else:
ans = k
ans = min(max(ans, 1), n-2)
print(1,2,n+1-ans)
``` | output | 1 | 65,348 | 23 | 130,697 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
n, a = list(map(int, input().split()))
best = 200
ans = 0
for i in range(1, n - 1):
if best > abs(180 * i / n - a):
best = abs(180 * i / n - a)
ans = n - i + 1
print(1, 2, ans)
``` | instruction | 0 | 65,349 | 23 | 130,698 |
Yes | output | 1 | 65,349 | 23 | 130,699 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
inf=10**6
par=[int(i) for i in str(input()).split()]
n,a=par[0],par[1]
angle_list=[[0,i] for i in range(n-1)]
angle_list[0][0]=0
inc=float(180)/float(n)
for i in range(1,n-1):
angle_list[i][0]=angle_list[i-1][0]+inc
pointer1=0
pointer2=1
min_diff=inf
#print(angle_list)
v1=0
v2=0
while True:
diff=angle_list[pointer2][0]-angle_list[pointer1][0]
d=min([[min_diff,0],[abs(a-diff),1]],key=lambda x:x[0])
min_diff=d[0]
if d[1]==1:
v1=pointer1
v2=pointer2
if diff==a:
break
if diff>a:
pointer1+=1
if pointer1==pointer2:
pointer2+=1
if diff<a:
pointer2+=1
if pointer2>=n-1:
break
#print(min_diff)
print(int(v1)+2,1,int(v2)+2)
``` | instruction | 0 | 65,350 | 23 | 130,700 |
Yes | output | 1 | 65,350 | 23 | 130,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
a,b=map(int,input().split())
k=180/a
ans=0
p=float("INF")
for i in range(1,a-1):
if abs(i*k-b)<p:ans=i;p=abs(i*k-b)
print(2,1,ans+2)
``` | instruction | 0 | 65,351 | 23 | 130,702 |
Yes | output | 1 | 65,351 | 23 | 130,703 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
from math import floor
n, a = map(int, input().split())
angle = 180 - (360 / n)
angle = angle / (n - 2)
pod = floor(a / angle)
#print(a / angle)
nad = pod + 1
#print("{} bee a {}".format(nad, pod))
if pod < 1:
pod += 1
if nad > n - 2:
nad = n - 2
pod = n - 2
#print("{} < {} ? ".format(abs(a - pod * angle), abs(a - nad * angle)))
if abs(a - pod * angle) < abs(a - nad * angle):
print("{} {} {}".format(2 + pod, 1, 2))
else:
print("{} {} {}".format(2 + nad, 1, 2))
``` | instruction | 0 | 65,352 | 23 | 130,704 |
Yes | output | 1 | 65,352 | 23 | 130,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
n,a = list(map(int,input().split())) #1e5; 180
sa = 360/n
v2 = 1
v1 = 2
vd = max(1,int(a*n/180+0.5)) #round
v3 = max(n,v1+vd) #may not allowed
print(v1,v2,v3)
``` | instruction | 0 | 65,353 | 23 | 130,706 |
No | output | 1 | 65,353 | 23 | 130,707 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
n,a = map(int,input().split())
k = round(n * a / 180)
if k == 0:
k = 1
print(1,2+k,1+k)
``` | instruction | 0 | 65,354 | 23 | 130,708 |
No | output | 1 | 65,354 | 23 | 130,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
# _
#####################################################################################################################
def main():
return bestAngle_sVertices(*map(int, input().split()))
def bestAngle_sVertices(nVertices, angle):
return f'2 1 {2 + max(1, round(angle*nVertices/180))}'
if __name__ == '__main__':
print(main())
``` | instruction | 0 | 65,355 | 23 | 130,710 |
No | output | 1 | 65,355 | 23 | 130,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides).
That's why Mister B decided to use this polygon. Now Mister B must find three distinct vertices v1, v2, v3 such that the angle <image> (where v2 is the vertex of the angle, and v1 and v3 lie on its sides) is as close as possible to a. In other words, the value <image> should be minimum possible.
If there are many optimal solutions, Mister B should be satisfied with any of them.
Input
First and only line contains two space-separated integers n and a (3 β€ n β€ 105, 1 β€ a β€ 180) β the number of vertices in the polygon and the needed angle, in degrees.
Output
Print three space-separated integers: the vertices v1, v2, v3, which form <image>. If there are multiple optimal solutions, print any of them. The vertices are numbered from 1 to n in clockwise order.
Examples
Input
3 15
Output
1 2 3
Input
4 67
Output
2 1 3
Input
4 68
Output
4 1 2
Note
In first sample test vertices of regular triangle can create only angle of 60 degrees, that's why every possible angle is correct.
Vertices of square can create 45 or 90 degrees angles only. That's why in second sample test the angle of 45 degrees was chosen, since |45 - 67| < |90 - 67|. Other correct answers are: "3 1 2", "3 2 4", "4 2 3", "4 3 1", "1 3 4", "1 4 2", "2 4 1", "4 1 3", "3 1 4", "3 4 2", "2 4 3", "2 3 1", "1 3 2", "1 2 4", "4 2 1".
In third sample test, on the contrary, the angle of 90 degrees was chosen, since |90 - 68| < |45 - 68|. Other correct answers are: "2 1 4", "3 2 1", "1 2 3", "4 3 2", "2 3 4", "1 4 3", "3 4 1".
Submitted Solution:
```
n, a = map(int, input().split())
print(n, 1, min((n+1)//2, max(round(a*n/180) + 1, 2)))
``` | instruction | 0 | 65,356 | 23 | 130,712 |
No | output | 1 | 65,356 | 23 | 130,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has a polygon consisting of n vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
<image> Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.
Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Input
The first line contain four integers x_1, y_1, x_2, y_2 (x_1 < x_2, y_2 < y_1) β the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer n (4 β€ n β€ 15 000) β the number of vertices in Petya's polygon.
Each of the following n lines contains two integers β the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed 15 000.
Output
Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Example
Input
5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8
Output
2
Note
The example corresponds to the picture above.
Submitted Solution:
```
x1, y1, x2, y2 = [int(i) for i in input().split()]
n = int(input())
isIn = False
firstIsIn = False
count = 0
xa = -1
ya = -1
for i in range(n):
x, y = [int(j) for j in input().split()]
if (not isIn) and x > x1 and x < x2 and y < y1 and y > y2:
isIn = True
count += 1
if i == 0:
firstIsIn = True
if firstIsIn and (i == n - 1):
count -= 1
elif not(x > x1 and x < x2 and y > y1 and y < y2):
vt = (x > x1 and x < x2 and ((ya >= y1 and y <= y2) or (y >= y1 and ya <= y2)))
ht = (((x <= x1 and xa >= x2) or (xa <= x1 and x >= x2)) and y < y1 and y > y2)
if not isIn and (xa != -1 and ya != -1) and (vt or ht):
count += 1
isIn = False
xa = x
ya = y
print(count)
``` | instruction | 0 | 65,391 | 23 | 130,782 |
No | output | 1 | 65,391 | 23 | 130,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has a polygon consisting of n vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
<image> Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.
Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Input
The first line contain four integers x_1, y_1, x_2, y_2 (x_1 < x_2, y_2 < y_1) β the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer n (4 β€ n β€ 15 000) β the number of vertices in Petya's polygon.
Each of the following n lines contains two integers β the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed 15 000.
Output
Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Example
Input
5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8
Output
2
Note
The example corresponds to the picture above.
Submitted Solution:
```
x1, y1, x2, y2 = map(int, input().split())
n = int(input())
def in_(x, y):
global x1, x2, y1, y2
return min(x1, x2) < x < max(x1, x2) and min(y1, y2) < y < max(y1, y2)
total = 0
lastin = False
for _ in range(n):
x, y = map(int, input().split())
if in_(x, y) and not lastin:
total += 1
lastin = True
elif not in_(x, y):
lastin = False
print(total)
``` | instruction | 0 | 65,392 | 23 | 130,784 |
No | output | 1 | 65,392 | 23 | 130,785 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has a polygon consisting of n vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
<image> Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.
Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Input
The first line contain four integers x_1, y_1, x_2, y_2 (x_1 < x_2, y_2 < y_1) β the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer n (4 β€ n β€ 15 000) β the number of vertices in Petya's polygon.
Each of the following n lines contains two integers β the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed 15 000.
Output
Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Example
Input
5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8
Output
2
Note
The example corresponds to the picture above.
Submitted Solution:
```
x1, y1, x2, y2 = map(int, input().split())
n = int(input())
def in_(x, y):
global x1, x2, y1, y2
return min(x1, x2) < x < max(x1, x2) and min(y1, y2) < y < max(y1, y2)
def side(lx, ly, x, y):
global x1, x2, y1, y2
if lx < x1 and x > x1:
return "LEFT"
elif lx > x2 and x < x2:
return "RIGHT"
elif ly < y2 and y > y2:
return "BOTTOM"
else:
return "TOP"
total = 0
lx, ly = map(int, input().split())
newshape = False
side_ = None
for _ in range(n - 1):
x, y = map(int, input().split())
if in_(x, y) and not newshape:
newshape = True
side_ = side(lx, ly, x, y)
elif not in_(x, y) and newshape:
newside = side(lx, ly, x, y)
if newside == side_:
total += 1
newshape = False
print(total)
``` | instruction | 0 | 65,393 | 23 | 130,786 |
No | output | 1 | 65,393 | 23 | 130,787 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petya has a polygon consisting of n vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.
Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.
<image> Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.
Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Input
The first line contain four integers x_1, y_1, x_2, y_2 (x_1 < x_2, y_2 < y_1) β the coordinates of top-left and bottom-right corners of the rectangular window.
The second line contains a single integer n (4 β€ n β€ 15 000) β the number of vertices in Petya's polygon.
Each of the following n lines contains two integers β the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.
All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed 15 000.
Output
Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.
Example
Input
5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8
Output
2
Note
The example corresponds to the picture above.
Submitted Solution:
```
x1, y1, x2, y2 = map(int, input().split())
n = int(input())
def in_(x, y):
global x1, x2, y1, y2
return min(x1, x2) < x < max(x1, x2) and min(y1, y2) < y < max(y1, y2)
def side(lx, ly, x, y):
global x1, x2, y1, y2
if lx < x1 and x > x1:
return "LEFT"
elif lx > x2 and x < x2:
return "RIGHT"
elif ly < y2 and y > y2:
return "BOTTOM"
else:
return "TOP"
total = 0
lx, ly = map(int, input().split())
newshape = False
side_ = None
for _ in range(n - 1):
x, y = map(int, input().split())
if in_(x, y) and not newshape:
newshape = True
side_ = side(lx, ly, x, y)
#print("From side {}".format(side_))
elif not in_(x, y) and newshape:
newside = side(lx, ly, x, y)
if newside == side_:
#print(newside)
total += 1
newshape = False
lx, ly = x, y
print(total + (1 if newshape else 0))
``` | instruction | 0 | 65,394 | 23 | 130,788 |
No | output | 1 | 65,394 | 23 | 130,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It happened at the times of the Great Berland Empire. Once the Emperor dreamt that the Messenger from the gods ordered to build a temple whose base would be a convex polygon with n angles. Next morning the Emperor gave the command to build a temple whose base was a regular polygon with n angles. The temple was built but soon the Empire was shaken with disasters and crop failures. After an earthquake destroyed the temple, the Emperor understood that he somehow caused the wrath of gods to fall on his people. He ordered to bring the wise man. When the wise man appeared, the Emperor retold the dream to him and asked "Oh the wisest among the wisest, tell me how could I have infuriated the Gods?". "My Lord," the wise man answered. "As far as I can judge, the gods are angry because you were too haste to fulfill their order and didn't listen to the end of the message".
Indeed, on the following night the Messenger appeared again. He reproached the Emperor for having chosen an imperfect shape for the temple. "But what shape can be more perfect than a regular polygon!?" cried the Emperor in his dream. To that the Messenger gave a complete and thorough reply.
* All the vertices of the polygon should be positioned in the lattice points.
* All the lengths of its sides should be different.
* From the possible range of such polygons a polygon which maximum side is minimal possible must be chosen.
You are an obedient architect who is going to make the temple's plan. Note that the polygon should be simple (having a border without self-intersections and overlapping) and convex, however, it is acceptable for three consecutive vertices to lie on the same line.
Input
The first line contains the single number n (3 β€ n β€ 10000).
Output
Print "YES" (without quotes) in the first line if it is possible to build a polygon possessing the needed qualities. In the next n lines print integer coordinates of the polygon vertices in the order in which they would be passed counter clockwise. The absolute value of the coordinates shouldn't exceed 109. No two vertices can coincide. It is permitted to print any of the possible solutions. Print "NO" if to build the polygon is impossible.
Examples
Input
3
Output
YES
0 0
1 0
0 2
Input
3
Output
YES
0 1
-1 0
-1 -1
Submitted Solution:
```
def main():
n = int(input())
print("YES")
if n == 3:
return print("0 0\n1 0\n0 2")
f = (n - 2) * (n - 1) // 2
k = f // 2
for i in range(1, n - 1):
print(0, k)
k -= i
if f % 2 == 0:
k -= 1
print(0, k)
print(1, 0)
main()
``` | instruction | 0 | 65,973 | 23 | 131,946 |
No | output | 1 | 65,973 | 23 | 131,947 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It happened at the times of the Great Berland Empire. Once the Emperor dreamt that the Messenger from the gods ordered to build a temple whose base would be a convex polygon with n angles. Next morning the Emperor gave the command to build a temple whose base was a regular polygon with n angles. The temple was built but soon the Empire was shaken with disasters and crop failures. After an earthquake destroyed the temple, the Emperor understood that he somehow caused the wrath of gods to fall on his people. He ordered to bring the wise man. When the wise man appeared, the Emperor retold the dream to him and asked "Oh the wisest among the wisest, tell me how could I have infuriated the Gods?". "My Lord," the wise man answered. "As far as I can judge, the gods are angry because you were too haste to fulfill their order and didn't listen to the end of the message".
Indeed, on the following night the Messenger appeared again. He reproached the Emperor for having chosen an imperfect shape for the temple. "But what shape can be more perfect than a regular polygon!?" cried the Emperor in his dream. To that the Messenger gave a complete and thorough reply.
* All the vertices of the polygon should be positioned in the lattice points.
* All the lengths of its sides should be different.
* From the possible range of such polygons a polygon which maximum side is minimal possible must be chosen.
You are an obedient architect who is going to make the temple's plan. Note that the polygon should be simple (having a border without self-intersections and overlapping) and convex, however, it is acceptable for three consecutive vertices to lie on the same line.
Input
The first line contains the single number n (3 β€ n β€ 10000).
Output
Print "YES" (without quotes) in the first line if it is possible to build a polygon possessing the needed qualities. In the next n lines print integer coordinates of the polygon vertices in the order in which they would be passed counter clockwise. The absolute value of the coordinates shouldn't exceed 109. No two vertices can coincide. It is permitted to print any of the possible solutions. Print "NO" if to build the polygon is impossible.
Examples
Input
3
Output
YES
0 0
1 0
0 2
Input
3
Output
YES
0 1
-1 0
-1 -1
Submitted Solution:
```
n = int(input())
print("YES")
f = (n - 2) * (n - 1) // 2
k = -(f // 2)
for i in range(1, n - 1):
print(0, k)
k += i
if f % 2 == 0:
k += 1
print(0, k)
print(1, 0)
``` | instruction | 0 | 65,974 | 23 | 131,948 |
No | output | 1 | 65,974 | 23 | 131,949 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It happened at the times of the Great Berland Empire. Once the Emperor dreamt that the Messenger from the gods ordered to build a temple whose base would be a convex polygon with n angles. Next morning the Emperor gave the command to build a temple whose base was a regular polygon with n angles. The temple was built but soon the Empire was shaken with disasters and crop failures. After an earthquake destroyed the temple, the Emperor understood that he somehow caused the wrath of gods to fall on his people. He ordered to bring the wise man. When the wise man appeared, the Emperor retold the dream to him and asked "Oh the wisest among the wisest, tell me how could I have infuriated the Gods?". "My Lord," the wise man answered. "As far as I can judge, the gods are angry because you were too haste to fulfill their order and didn't listen to the end of the message".
Indeed, on the following night the Messenger appeared again. He reproached the Emperor for having chosen an imperfect shape for the temple. "But what shape can be more perfect than a regular polygon!?" cried the Emperor in his dream. To that the Messenger gave a complete and thorough reply.
* All the vertices of the polygon should be positioned in the lattice points.
* All the lengths of its sides should be different.
* From the possible range of such polygons a polygon which maximum side is minimal possible must be chosen.
You are an obedient architect who is going to make the temple's plan. Note that the polygon should be simple (having a border without self-intersections and overlapping) and convex, however, it is acceptable for three consecutive vertices to lie on the same line.
Input
The first line contains the single number n (3 β€ n β€ 10000).
Output
Print "YES" (without quotes) in the first line if it is possible to build a polygon possessing the needed qualities. In the next n lines print integer coordinates of the polygon vertices in the order in which they would be passed counter clockwise. The absolute value of the coordinates shouldn't exceed 109. No two vertices can coincide. It is permitted to print any of the possible solutions. Print "NO" if to build the polygon is impossible.
Examples
Input
3
Output
YES
0 0
1 0
0 2
Input
3
Output
YES
0 1
-1 0
-1 -1
Submitted Solution:
```
n = int(input())
print("YES")
f = (n - 2) * (n - 1) // 2
k = f // 2
for i in range(1, n - 1):
print(0, k)
k -= i
if f % 2 == 0:
k -= 1
print(0, k)
print(1, 0)
``` | instruction | 0 | 65,975 | 23 | 131,950 |
No | output | 1 | 65,975 | 23 | 131,951 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,008 | 23 | 132,016 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import math
n,k=map(int,input().split())
p=n/2
p=math.ceil(p)
max1=p-1
rem=n-p
if n%2==0:
max=2*(p*p)
else:
max=(p*p)+(max1*rem)
if k>max:
print("NO")
else:
a=[['S' for j in range(n)]for i in range(n)]
for i in range(n):
if k==0:
break
if i%2==0:
start=0
else:
start=1
for j in range(start,n,2):
a[i][j]='L'
k-=1
if k==0:
break
print("YES")
for i in range(n):
print(''.join(a[i]))
``` | output | 1 | 66,008 | 23 | 132,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,009 | 23 | 132,018 |
Tags: constructive algorithms, implementation
Correct Solution:
```
S=input().split();n=int(S[0]);k=int(S[1])
ans=[]
try:
cnt=0
for i in range(n):
ans.append("")
for j in range(n):
if (i+j)%2==0 and cnt<k:
ans[i]=ans[i]+'L';cnt=cnt+1
else :
ans[i]=ans[i]+'S'
if cnt<k:
cnt/0
print("YES")
for i in range(n):
print(ans[i])
except:
print("NO")
``` | output | 1 | 66,009 | 23 | 132,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,010 | 23 | 132,020 |
Tags: constructive algorithms, implementation
Correct Solution:
```
[n, k] = [int(i) for i in input().split()]
islands = 0
result = []
for i in range(n):
if i % 2 == 0 and islands < k:
result.append('L')
islands += 1
else:
result.append('S')
for j in range(n - 1):
if result[-1][-1] == 'S' and islands < k:
result[-1] += 'L'
islands += 1
else:
result[-1] += 'S'
if islands == k:
print('YES')
for i in range(n):
print(result[i])
else:
print('NO')
``` | output | 1 | 66,010 | 23 | 132,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,011 | 23 | 132,022 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import sys
import math
import collections
import bisect
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()
for t in range(1):
n,k=get_ints()
if k>math.ceil((n**2)/2):
print("NO")
continue
ans=[]
mul=0
count=0
for i in range(n):
row=["S"]*n
for j in range(n):
if j%2==0:
if mul%2==0 and count<k:
row[j]="L"
count+=1
elif j%2==1:
if mul%2==1 and count<k:
row[j]="L"
count+=1
mul+=1
ans.append(row)
print("YES")
for i in ans:
print(*i,sep="")
``` | output | 1 | 66,011 | 23 | 132,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,012 | 23 | 132,024 |
Tags: constructive algorithms, implementation
Correct Solution:
```
from math import *
from bisect import *
from collections import Counter,defaultdict
from sys import stdin, stdout
input = stdin.readline
I =lambda:int(input())
M =lambda:map(int,input().split())
LI=lambda:list(map(int,input().split()))
n,k=M()
if (n*n+1)//2<k:
print("NO")
else:
print("YES")
for i in range(n):
for j in range(n):
if (i+j)%2==0 and k:
print("L",end="")
k-=1
else:
print("S",end="")
print()
``` | output | 1 | 66,012 | 23 | 132,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,014 | 23 | 132,028 |
Tags: constructive algorithms, implementation
Correct Solution:
```
'''
/\
/ `.
,' `.
/`.________ ( :
\ `. _\_______ )
\ `.----._ `. "`-.
) \ \ ` ,"__\
\ \ ) ,-- (/o\\
( _ `. `---' ,--. \ _)).
`(-',-`----' ( (O \ `--,"`-.
`/ \ \__) ,' O )
/ `--' ( O ,'
( `--,'
\ `== _.-'
\ .____.-;-'
-hrr- ) `._ /
( |`-._\ | ,' /
`.__|__/ "\ |' /
`._|_,'
HAS ANYONE SEEN MY RIDER?
----------------------------------CODING SUCKS----------YOUR STALKING DOES NOT THOUGH------
'''
import math
n, k = map(int, input().split())
peak = (n*n +1) //2
if k>peak:
print("NO")
else:
print("YES")
l = []
for i in range(n):
x = []
for j in range(n):
x.append('S')
l.append(x)
for i in range(n):
for j in range(n):
if (i+j)%2==0 and k:
l[i][j] = 'L'
k = k -1
for i in range(n):
for j in range(n):
print(l[i][j], end = '')
print()
``` | output | 1 | 66,014 | 23 | 132,029 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO | instruction | 0 | 66,015 | 23 | 132,030 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, k = [int(x) for x in input().split()]
if (n * n + 1) // 2 < k:
print("NO")
else:
print("YES")
arr = ['L'] * k + ['S'] * ((n * n + 1) // 2 - k)
s = 'S'.join(arr)
if n % 2 == 0:
s += 'S'
turn = 1
while s:
print(s[:n][::turn])
s = s[n:]
if n % 2 == 0:
turn = - turn
``` | output | 1 | 66,015 | 23 | 132,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
import math
n,k=map(int,input().split(" "))
tt=1
ans=[['S' for x in range(n)]for y in range(n)]
for x in range(0,n):
chk=0
if tt==0:
tt=1
else:
tt=0
for y in range(tt,n,2):
if k>0:
ans[x][y]='L'
k=k-1
if k==0:
print("YES")
for x in ans:
print(*x,sep="")
else:
print("NO")
``` | instruction | 0 | 66,016 | 23 | 132,032 |
Yes | output | 1 | 66,016 | 23 | 132,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
n,k=map(int,input().split(' '))
r=0
for i in range(n):
for j in range(n):
if (i+j)%2==0:
r+=1
if r<k:
print("NO")
else:
print("YES")
z=0
for i in range(n):
s=""
for j in range(n):
if (i+j)%2==0:
if z<k:
s+="L"
z+=1
else:
s+="S"
else:
s+="S"
print(s)
``` | instruction | 0 | 66,017 | 23 | 132,034 |
Yes | output | 1 | 66,017 | 23 | 132,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
def islands():
n, k= (int(i) for i in input().split())
if n%2== 0:
maxisland= n*n/2
else:
maxisland= (n*n/2)+ 1
if k> maxisland:
print("NO")
return
print("YES")
ans= [["S" for i in range(n)] for j in range(n)]
if k== 0:
ans= ["".join(i) for i in ans]
ans= "\n".join(ans)
print(ans)
return
for i in range(n):
for j in range(n):
if i%2== 0:
if j%2== 0:
ans[i][j]= "L"
k-= 1
if k== 0:
ans= ["".join(i) for i in ans]
ans= "\n".join(ans)
print(ans)
return
elif i%2== 1:
if j%2== 1:
ans[i][j]= "L"
k-= 1
if k== 0:
ans= ["".join(i) for i in ans]
ans= "\n".join(ans)
print(ans)
return
islands()
``` | instruction | 0 | 66,018 | 23 | 132,036 |
Yes | output | 1 | 66,018 | 23 | 132,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
n,k=map(int,input().split())
if n%2==0:
M=(n/2)*n
else:
M=0
for i in range(n):
if i%2==0:
M+=n//2+1
else:
M+=n//2
if k>M:
print('NO')
else:
arr=[]
i=0
x=k
while i<n:
if i%2==0:
j=0
s=''
while j<n:
if j%2==0:
if x>0:
s+='L'
x+=-1
else:
s+='S'
else:
s+='S'
j+=1
arr.append(s)
i+=1
else:
j=0
s=''
while j<n:
if j%2==1:
if x>0:
s+='L'
x+=-1
else:
s+='S'
else:
s+='S'
j+=1
arr.append(s)
i+=1
print('YES')
for i in arr:
print(i)
``` | instruction | 0 | 66,019 | 23 | 132,038 |
Yes | output | 1 | 66,019 | 23 | 132,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
import math
n, k = input().split()
n = int(n)
k = int(k)
if k > math.ceil((n**2)/2):
print("NO")
exit()
print("YES")
a = []
for i in range(n):
a.append([])
for j in range(n):
a[i].append('S')
x = 0
y = 0
a[0][0] = 'L'
for i in range(k-1):
if x+2 < n:
x += 2
else:
if x % 2 == 0:
x = 1
else:
x = 0
y += 1
a[y][x] = 'L'
"""
y += 1
x = n-1
while (a[y-1][x] == 'S') and (x >= 0) and (y < n):
a[y][x] = 'L'
x -= 1
for x in range(n):
if (a[y-1][x] == 'L') and (y < n):
a[y][x] = 'L'
x = 0
while (a[y-1][x] == 'S') and (x < n):
a[y][x] = 'L'
x += 1
y -= 1
for x in range(n):
if (y < n-1) and (a[y-1][x] == 'S') and (a[y+1][x] == 'L'):
a[y][x] = 'L'
y += 2
while y < n:
for x in range(n):
if a[y-1][x] == 'L':
a[y][x] = 'L'"""
#y += 1
#a[i][j] = 'L'
for i in range(n):
s = ''
for j in range(n):
s += a[i][j]
print(s)
``` | instruction | 0 | 66,020 | 23 | 132,040 |
No | output | 1 | 66,020 | 23 | 132,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
inputa = list(input())
massval = []
stateval = ''
for i in inputa:
if i != ' ':
stateval+=i
else:
massval.append(int(stateval))
stateval = ''
massval.append(int(stateval))
matrix = []
for j in range(massval[0]):
matrix.append([])
for i in range(massval[0]):
matrix[j].append("S")
i=0
m=0
used = 0
flagus = 0
for j in matrix:
land = 0
while (land<len(j)):
if (land+i<len(j)):
j[land+i]="L"
used+=1
if i:
i-=1
else:
i+=1
land+=1
if (used>=massval[1]):
flagus = 1
break
if flagus==1:
break
if (massval[0]==82):
print("NO")
else:
if used<massval[1]:
print("NO")
else:
print("YES")
for i in matrix:
for j in i:
print(j, end="")
print("")
``` | instruction | 0 | 66,021 | 23 | 132,042 |
No | output | 1 | 66,021 | 23 | 132,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
n,k = map(int,input().split())
arr = []
for i in range(n):
arr.append(['S']*n)
v = check = count = 0
for i in range(n):
for j in range(v%2,n,2):
arr[i][j]='L'
count += 1
if count==k:
check = 1
break
if check:
break
v += 1
if count==k:
for i in arr:
print(''.join(i))
else:
print('NO')
``` | instruction | 0 | 66,022 | 23 | 132,044 |
No | output | 1 | 66,022 | 23 | 132,045 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).
Find a way to cover some cells with sand so that exactly k islands appear on the n Γ n map, or determine that no such way exists.
Input
The single line contains two positive integers n, k (1 β€ n β€ 100, 0 β€ k β€ n2) β the size of the map and the number of islands you should form.
Output
If the answer doesn't exist, print "NO" (without the quotes) in a single line.
Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.
If there are multiple answers, you may print any of them.
You should not maximize the sizes of islands.
Examples
Input
5 2
Output
YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS
Input
5 25
Output
NO
Submitted Solution:
```
def M(a,b,k):
c=1
if(b>k):
print(k)
else:
print("YES")
for i in range(a):
for x in range(a):
if(i%2==0):
if(x%2==0 and c<=b):
print("L", end='')
c+=1
else:
print("S", end='')
else:
if(x%2==1 and c<=b):
print("L", end='')
c+=1
else:
print("S", end='')
print()
if __name__=='__main__':
a,b=map(int,input().split())
if(a%2==0):
k=(a/3)*a
else:
n=(a//2)+1
m=(a//2)
k=(n*n)+(m*m)
M(a,b,k)
``` | instruction | 0 | 66,023 | 23 | 132,046 |
No | output | 1 | 66,023 | 23 | 132,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,588 | 23 | 133,176 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for i in range(t):
n,m = [int(i) for i in input().split()]
# print(n,m)
print((max(max(n,m),min(n,m)*2))**2)
``` | output | 1 | 66,588 | 23 | 133,177 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,589 | 23 | 133,178 |
Tags: greedy, math
Correct Solution:
```
t=int(input())
for i in range(t):
a,b=map(int,input().split())
a,b=max(a,b),min(a,b)
if 2*b>=a:
print((2*b)**2)
else:
print(a**2)
``` | output | 1 | 66,589 | 23 | 133,179 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,590 | 23 | 133,180 |
Tags: greedy, math
Correct Solution:
```
def find_area(x):
a,b = x.split()
a,b = int(a), int(b)
if(a>b):
min = b
max = a
else:
min = a
max = b
min2 = min*2
if(min2>max):
return min2**2
else:
return max**2
inputList = []
outputList = []
n = int(input())
for i in range(n):
inputList.append(input())
for x in inputList:
outputList.append(find_area(x))
for x in outputList:
print(str(x))
``` | output | 1 | 66,590 | 23 | 133,181 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,591 | 23 | 133,182 |
Tags: greedy, math
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]
#-------------------------code---------------------------#
#vsInput()
for _ in range(Int()):
a,b=sorted(value())
l=max(b,2*a)
print(l*l)
``` | output | 1 | 66,591 | 23 | 133,183 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,592 | 23 | 133,184 |
Tags: greedy, math
Correct Solution:
```
def minimal_square(a, b):
if a < b:
if a*2 >= b:
x = (a*2)**2
else:
x = b*b
else:
if b*2 >= a:
x = (b*2)**2
else:
x = a*a
return x
t = input()
a = []
b =[]
output = []
for i in range(0,int(t)):
p, q = input().split()
a.append(p)
b.append(q)
for i in range(0,int(t)):
print(minimal_square(int(a[i]), int(b[i])))
``` | output | 1 | 66,592 | 23 | 133,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,593 | 23 | 133,186 |
Tags: greedy, math
Correct Solution:
```
if __name__ == '__main__':
for _ in range(int(input())):
a, b = map(int, input().split())
print(max(min(a, b) * 2, max(a, b)) ** 2)
``` | output | 1 | 66,593 | 23 | 133,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,594 | 23 | 133,188 |
Tags: greedy, math
Correct Solution:
```
for _ in range(int(input())):
a,b = map(int,input().split())
lis = []
lis.append(a+b)
if a>= 2*b:
lis.append(a)
if b >= 2*a:
lis.append(b)
if 2*a >= b:
lis.append(2*a)
if 2*b >= a:
lis.append(2*b)
print(min(lis)**2)
``` | output | 1 | 66,594 | 23 | 133,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image> | instruction | 0 | 66,595 | 23 | 133,190 |
Tags: greedy, math
Correct Solution:
```
cases = int(input())
for case in range(cases):
(a, b) = map(int,input().split())
lado = max(max(a,b),2*min(a,b))
print(lado*lado)
``` | output | 1 | 66,595 | 23 | 133,191 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
import io
import os
import functools
import itertools
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
while t:
t -= 1
a, b = [int(x) for x in input().split()]
a, b = min(a, b), max(a, b)
print((2*a)**2 if 2*a >= b else b**2)
``` | instruction | 0 | 66,596 | 23 | 133,192 |
Yes | output | 1 | 66,596 | 23 | 133,193 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
t=int(input())
for i in range(t):
a,b=map(int,input().split())
one=max(max(a,b),2*min(a,b))
two=max(a+b,max(a,b))
three=max(max(a,b),2*min(a,b))
four=2*max(a,b)
print((min(one,two,three,four))**2)
``` | instruction | 0 | 66,597 | 23 | 133,194 |
Yes | output | 1 | 66,597 | 23 | 133,195 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
t = int(input())
c = []
for i in range (t):
a,b = input ().split()
k = [int(a),int(b)]
c.append(k)
def max(a,b):
if a>b :
return a
else : return b
def min(a,b):
if a<b :
return a
else : return b
for i in range (t):
k = max (c[i][0],c[i][1])
l = max(k, 2*min(c[i][0],c[i][1]))
print (l**2)
``` | instruction | 0 | 66,598 | 23 | 133,196 |
Yes | output | 1 | 66,598 | 23 | 133,197 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
t=int(input())
for a in range(t):
a,b=map(int,input().split())
x=max(4*a**2,b**2)
y=max(4*b**2,a**2)
z=min(x,y)
print(z)
``` | instruction | 0 | 66,599 | 23 | 133,198 |
Yes | output | 1 | 66,599 | 23 | 133,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
# https://codeforces.com/problemset/problem/1360/A
# 800
import math
t = int(input())
for _ in range(t):
a, b = map(int, input().split())
ab_area = a * b * 2
s = math.ceil(math.sqrt(ab_area))
while s < a * 2 or s < b * 2:
s += 1
print(s*s)
``` | instruction | 0 | 66,600 | 23 | 133,200 |
No | output | 1 | 66,600 | 23 | 133,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
for _ in range(int(input())):
a, b = map(int,input().split())
a, b = min(a,b), max(b,a)
if b%a == 0:
print(b**2)
else:
print(a**2*4)
``` | instruction | 0 | 66,601 | 23 | 133,202 |
No | output | 1 | 66,601 | 23 | 133,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
import math
def showarea(m,n):
s=2*m*n
a=[]
for i in range(201):
a.append(i*i)
if m==n:
return (m+n)**2;
elif s in a:
return s;
else:
j=int(math.sqrt(s))
return (j+1)**2;
t=int(input())
k=[]
for i in range(t):
a,b=map(int,input().split())
print(showarea(a,b))
``` | instruction | 0 | 66,602 | 23 | 133,204 |
No | output | 1 | 66,602 | 23 | 133,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Find the minimum area of a square land on which you can place two identical rectangular a Γ b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 β€ a, b β€ 100) β positive integers (you are given just the sizes, but not their positions).
* Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
<image> The picture shows a square that contains red and green rectangles.
Input
The first line contains an integer t (1 β€ t β€ 10 000) βthe number of test cases in the input. Then t test cases follow.
Each test case is a line containing two integers a, b (1 β€ a, b β€ 100) β side lengths of the rectangles.
Output
Print t answers to the test cases. Each answer must be a single integer β minimal area of square land, that contains two rectangles with dimensions a Γ b.
Example
Input
8
3 2
4 2
1 1
3 1
4 7
1 3
7 4
100 100
Output
16
16
4
9
64
9
64
40000
Note
Below are the answers for the first two test cases:
<image> <image>
Submitted Solution:
```
for _ in range(int(input())):
a, b = map(int, input().split())
if a > b:
if b * 2 > a:
x = b * 2
else:
x = a * 2
else:
if a * 2 > b:
x = a * 2
else:
x = b * 2
print(x**2)
``` | instruction | 0 | 66,603 | 23 | 133,206 |
No | output | 1 | 66,603 | 23 | 133,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given the centers of three equal sides of a strictly convex tetragon. Your task is to restore the initial tetragon.
Input
The first input line contains one number T β amount of tests (1 β€ T β€ 5Β·104). Each of the following T lines contains numbers x1, y1, x2, y2, x3, y3 β coordinates of different points that are the centers of three equal sides (non-negative integer numbers, not exceeding 10).
Output
For each test output two lines. If the required tetragon exists, output in the first line YES, in the second line β four pairs of numbers β coordinates of the polygon's vertices in clockwise or counter-clockwise order. Don't forget, please, that the tetragon should be strictly convex, i.e. no 3 of its points lie on one line. Output numbers with 9 characters after a decimal point.
If the required tetragon doen't exist, output NO in the first line, and leave the second line empty.
Examples
Input
3
1 1 2 2 3 3
0 1 1 0 2 2
9 3 7 9 9 8
Output
NO
YES
3.5 1.5 0.5 2.5 -0.5 -0.5 2.5 0.5
NO
Submitted Solution:
```
n = int(input())
for i in range(n):
x1,y1,x2,y2,x3,y3 = map(int,input().split())
print("NO")
print("")
print("YES")
print("3.5 1.5 0.5 2.5 -0.5 -0.5 2.5 0.5")
print("NO")
print("")
``` | instruction | 0 | 66,697 | 23 | 133,394 |
No | output | 1 | 66,697 | 23 | 133,395 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.