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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
n, m = map(int, input().split())
a = [[' ' for i in range(m)]for j in range(n)]
for i in range(n):
a[i] = list(input())
check = [['.' for i in range(m)]for j in range(n)]
MAX_STAR_SIZE = min(n, m)//2
ans = []
def valid_star(i, j):
sz = 0
for s in range(1, MAX_STAR_SIZE + 1):
sz = s
if (i - s < 0) or (i + s >= n) or (j - s < 0) or (j + s >= m):
return s - 1
if (a[i + s][j] == '.') or (a[i - s][j] == '.') or (a[i][j + s] == '.') or (a[i][j - s] == '.'):
return s - 1
return sz
def place_star(x, y, sz):
global check
check[x][y] = '*'
for i in range(1, sz + 1):
check[x + i][y] = '*'
check[x - i][y] = '*'
check[x][y + i] = '*'
check[x][y - i] = '*'
def star_complete():
global check
for i in range(n):
for j in range(m):
if a[i][j] != check[i][j]:
return False
return True
for i in range(n):
for j in range(m):
if a[i][j] != '*':
continue
sz = valid_star(i, j)
if sz != 0:
place_star(i, j, sz)
ans.append([i + 1, j + 1, sz])
if not star_complete():
print(-1)
else:
print(len(ans))
print('\n'.join([f'{str(a)} {str(b)} {str(c)}' for a, b, c in ans]))
``` | instruction | 0 | 47,028 | 23 | 94,056 |
Yes | output | 1 | 47,028 | 23 | 94,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
#sys.setrecursionlimit(300000)
#threading.stack_size(10**8)
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")
#-------------------------------------------------------------------------
#mod = 9223372036854775807
class SegmentTree:
def __init__(self, data, default=0, func=lambda a, b: a+b):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(range(_size)):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
if start == stop:
return self.__getitem__(start)
stop += 1
start += self._size
stop += self._size
res = self._default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "SegmentTree({0})".format(self.data)
class SegmentTree1:
def __init__(self, data, default=10**6, func=lambda a, b: min(a,b)):
"""initialize the segment tree with data"""
self._default = default
self._func = func
self._len = len(data)
self._size = _size = 1 << (self._len - 1).bit_length()
self.data = [default] * (2 * _size)
self.data[_size:_size + self._len] = data
for i in reversed(range(_size)):
self.data[i] = func(self.data[i + i], self.data[i + i + 1])
def __delitem__(self, idx):
self[idx] = self._default
def __getitem__(self, idx):
return self.data[idx + self._size]
def __setitem__(self, idx, value):
idx += self._size
self.data[idx] = value
idx >>= 1
while idx:
self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
idx >>= 1
def __len__(self):
return self._len
def query(self, start, stop):
if start == stop:
return self.__getitem__(start)
stop += 1
start += self._size
stop += self._size
res = self._default
while start < stop:
if start & 1:
res = self._func(res, self.data[start])
start += 1
if stop & 1:
stop -= 1
res = self._func(res, self.data[stop])
start >>= 1
stop >>= 1
return res
def __repr__(self):
return "SegmentTree({0})".format(self.data)
MOD=10**9+7
class Factorial:
def __init__(self, MOD):
self.MOD = MOD
self.factorials = [1, 1]
self.invModulos = [0, 1]
self.invFactorial_ = [1, 1]
def calc(self, n):
if n <= -1:
print("Invalid argument to calculate n!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.factorials):
return self.factorials[n]
nextArr = [0] * (n + 1 - len(self.factorials))
initialI = len(self.factorials)
prev = self.factorials[-1]
m = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = prev * i % m
self.factorials += nextArr
return self.factorials[n]
def inv(self, n):
if n <= -1:
print("Invalid argument to calculate n^(-1)")
print("n must be non-negative value. But the argument was " + str(n))
exit()
p = self.MOD
pi = n % p
if pi < len(self.invModulos):
return self.invModulos[pi]
nextArr = [0] * (n + 1 - len(self.invModulos))
initialI = len(self.invModulos)
for i in range(initialI, min(p, n + 1)):
next = -self.invModulos[p % i] * (p // i) % p
self.invModulos.append(next)
return self.invModulos[pi]
def invFactorial(self, n):
if n <= -1:
print("Invalid argument to calculate (n^(-1))!")
print("n must be non-negative value. But the argument was " + str(n))
exit()
if n < len(self.invFactorial_):
return self.invFactorial_[n]
self.inv(n) # To make sure already calculated n^-1
nextArr = [0] * (n + 1 - len(self.invFactorial_))
initialI = len(self.invFactorial_)
prev = self.invFactorial_[-1]
p = self.MOD
for i in range(initialI, n + 1):
prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
self.invFactorial_ += nextArr
return self.invFactorial_[n]
class Combination:
def __init__(self, MOD):
self.MOD = MOD
self.factorial = Factorial(MOD)
def ncr(self, n, k):
if k < 0 or n < k:
return 0
k = min(k, n - k)
f = self.factorial
return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod=10**9+7
omod=998244353
#-------------------------------------------------------------------------
prime = [True for i in range(10)]
pp=[0]*10
def SieveOfEratosthenes(n=10):
p = 2
c=0
while (p * p <= n):
if (prime[p] == True):
c+=1
for i in range(p, n+1, p):
pp[i]+=1
prime[i] = False
p += 1
#---------------------------------Binary Search------------------------------------------
def binarySearch(arr, n, key):
left = 0
right = n-1
mid = 0
res=arr[n-1]
while (left <= right):
mid = (right + left)//2
if (arr[mid] >= key):
res=arr[mid]
right = mid-1
else:
left = mid + 1
return res
def binarySearch1(arr, n, key):
left = 0
right = n-1
mid = 0
res=arr[0]
while (left <= right):
mid = (right + left)//2
if (arr[mid] > key):
right = mid-1
else:
res=arr[mid]
left = mid + 1
return res
#---------------------------------running code------------------------------------------
n,m=map(int,input().split())
l=[]
tot=[]
done=[[0 for i in range(m)]for j in range(n)]
for i in range(n):
l.append(input())
colsum=[[0 for i in range(m)]for j in range(n)]
rowsum=[[0 for i in range(m)]for j in range(n)]
col=[[0 for i in range(m)]for j in range(n)]
row=[[0 for i in range(m)]for j in range(n)]
for i in range(n):
for j in range(m):
if l[i][j]=='*':
rowsum[i][j]=1
colsum[i][j]=1
row[i][j]=1
col[i][j]=1
for i in range(n):
for j in range(1,m):
if l[i][j]=='.':
continue
rowsum[i][j]+=rowsum[i][j-1]
for i in range(n):
for j in range(m-2,-1,-1):
if l[i][j]=='.':
continue
row[i][j]+=row[i][j+1]
for i in range(m):
for j in range(n-2,-1,-1):
if l[j][i]=='.':
continue
col[j][i]+=col[j+1][i]
for i in range(m):
for j in range(1,n):
if l[j][i]=='.':
continue
colsum[j][i]+=colsum[j-1][i]
def check(x,y):
i=x
j=y
ans=min(row[i][j],rowsum[i][j],colsum[i][j],col[i][j])-1
if ans==0:
return []
return [ans]
h=[[0 for i in range(m+1)]for j in range(n)]
v=[[0 for i in range(m)]for j in range(n+1)]
for i in range(n):
for j in range(m):
if l[i][j]=='*':
ans=check(i,j)
for j1 in ans:
tot.append([i+1,j+1,j1])
h[i][j-j1]+=1
h[i][j+j1+1]-=1
v[i-j1][j]+=1
v[i+j1+1][j]-=1
for i in range(n):
for j in range(1,m):
h[i][j]+=h[i][j-1]
for i in range(m):
for j in range(1,n):
v[j][i]+=v[j-1][i]
#print(h)
#print(v)
for i in range(n):
for j in range(m):
if l[i][j]=='*' and h[i][j]==0 and v[i][j]==0:
print(-1)
sys.exit(0)
print(len(tot))
for i in tot:
print(*i)
``` | instruction | 0 | 47,029 | 23 | 94,058 |
Yes | output | 1 | 47,029 | 23 | 94,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
n,m=map(int,input().split())
g=[[*input()] for _ in range(n)]
c=[[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
v=0
for j in range(m):
v=(v+1)*(g[i][j]=='*')
c[i][j]=v
v=0
for j in range(m-1,-1,-1):
v=(v+1)*(g[i][j]=='*')
c[i][j]=min(c[i][j],v)
for j in range(m):
v=0
for i in range(n):
v=(v+1)*(g[i][j]=='*')
c[i][j]=min(c[i][j],v)
v=0
for i in range(n-1,-1,-1):
v=(v+1)*(g[i][j]=='*')
c[i][j]=min(c[i][j],v)
for i in range(n):
for j in range(m):
if c[i][j]==1: c[i][j]=0
for i in range(n):
v=0
for j in range(m):
v=max(v-1,c[i][j])
if v:g[i][j]='.'
v=0
for j in range(m-1,-1,-1):
v=max(v-1,c[i][j])
if v:g[i][j]='.'
for j in range(m):
v=0
for i in range(n):
v=max(v-1,c[i][j])
if v:g[i][j]='.'
for i in range(n-1,-1,-1):
v=max(v-1,c[i][j])
if v:g[i][j]='.'
if all(g[i][j]=='.' for i in range(n) for j in range(m)):
r=[(i+1,j+1,c[i][j]-1) for i in range(n) for j in range(m) if c[i][j]]
print(len(r))
for t in r: print(*t)
else:
print(-1)
``` | instruction | 0 | 47,030 | 23 | 94,060 |
Yes | output | 1 | 47,030 | 23 | 94,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
def check(x, y, fd, stars, n, m):
ln = 1
while (y-ln > -1 and x - ln > -1 and y + ln < m and x + ln < n):
flag = True
#up
if (fd[x-ln][y] == '.' ): flag = False
#down
if (fd[x+ln][y] == '.' ): flag = False
#left
if (fd[x][y-ln] == '.' ): flag = False
#right
if (fd[x][y+ln] == '.' ): flag = False
if (flag):
fd[x-ln] = fd[x-ln][:y]+'+'+fd[x-ln][y+1:]
fd[x+ln] = fd[x+ln][:y]+'+'+fd[x+ln][y+1:]
fd[x] = fd[x][:y-ln]+'+'*(ln+ln+1)+fd[x][y+ln+1:]
ln += 1
else:
if (ln>1):
stars.append(str(x+1)+" "+str(y+1)+" "+str(ln-1))
return
else:
return
if (ln-1 > 0):
stars.append(str(x+1)+" "+str(y+1)+" "+str(ln-1))
n, m = map(int, input().split())
stars = []
fd = []
for i in range(n):
fd.append(input())
#solve
final = False
for i in range(1, n):
for j in range(1, m):
if (fd[i][j] != '.' ):
isIsland = False
#is point a Island ?
if (fd[i-1][j] == '.' and fd[i+1][j] == '.' and fd[i][j-1] == '.' and fd[i][j+1] == '.'):
isIsland = True
if (isIsland):
final = True
break
else:
check(i, j, fd, stars, n, m)
if final:
print(-1)
break
# output
if (not final):
for i in range(n):
for j in range(m):
if fd[i][j] == '*':
final = True
break
if (final):
print(-1)
break
if not final:
print(len(stars))
for i in stars:
print(i)
``` | instruction | 0 | 47,031 | 23 | 94,062 |
Yes | output | 1 | 47,031 | 23 | 94,063 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
io = input().split()
n = int(io[0])
m = int(io[1])
arr = []
def analitic(y, x):
global n,m,arr
maxValue = min(y, m-x-1, n-y-1, x)
tMax = 0
for i in range(maxValue):
if (arr[y-i-1][x] == '.'):
tMax = i
break
else:
tMax = i + 1
rMax = 0
for i in range(tMax):
if (arr[y][x+i+1] == '.'):
rMax = i
break
else:
rMax = i + 1
bMax = 0
for i in range(rMax):
if (arr[y+i+1][x] == '.'):
bMax = i
break
else:
bMax = i + 1
lMax = 0
for i in range(bMax):
if (arr[y][x-i-1] == '.'):
lMax = i
break
else:
lMax = i + 1
return lMax
def drawChar(currentCahr):
if (currentCahr == 0):
return '*'
return currentCahr
def draw(y, x, size):
global arr
for i in range(size):
arr[y - i - 1][x] = drawChar(arr[y - i - 1][x])
for i in range(size):
arr[y][x + i + 1] = drawChar(arr[y][x + i + 1])
for i in range(size):
arr[y + i + 1][x] = drawChar(arr[y + i + 1][x])
for i in range(size):
arr[y][x - i - 1] = drawChar(arr[y][x - i - 1])
for i in range(n):
arr.append(list(input()))
for i in range(n):
for j in range(m):
if (arr[i][j] == '.'):
continue
arr[i][j] = analitic(i,j)
print("".join(map(str, arr[i])))
res = []
for i in range(n):
for j in range(m):
if (arr[i][j] != '.' and arr[i][j] != '*' and arr[i][j] != 0):
res.append(str(i+1) + ' ' + str(j+1) + ' ' + str(arr[i][j]))
draw(i,j,arr[i][j])
for i in range(n):
for j in range(m):
if (arr[i][j] == 0):
print(-1)
exit()
count = len(res)
if count == 0:
print(-1)
exit()
print(count)
for i in res:
print(i)
``` | instruction | 0 | 47,032 | 23 | 94,064 |
No | output | 1 | 47,032 | 23 | 94,065 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
import sys
n,m=map(int,input().split())
s=[list(input()) for i in range(n)]
dp=[[-1 for i in range(m)] for j in range(n)]
ans=[]
for i in range(1,n-1):
for j in range(1,m-1):
if s[i][j]=="*" and s[i+1][j]=='*' and s[i-1][j]=='*' and s[i][j-1]=='*' and s[i][j+1]=='*' and (dp[i][j]==-1 or dp[i+1][j]==-1 or dp[i-1][j]==-1 or dp[i][j-1]==-1 or dp[i][j+1]==-1):
x=0
while i-x>-1 and x+i<n and j-x>-1 and x+j<m and s[i+x][j]=='*' and s[i-x][j]=='*' and s[i][j-x]=='*' and s[i][j+x]=='*':
dp[i+x][j]=1
dp[i-x][j]=1
dp[i][j-x]=1
dp[i][j+x]=1
x+=1
if x!=1:
ans.append([i+1,j+1,x-1])
else:
dp[i][j]=-1
for i in range(n):
for j in range(m):
if s[i][j]=='*' and dp[i][j]==-1:
print(-1)
sys.exit()
print(len(ans))
for i in ans:
print(*i)
``` | instruction | 0 | 47,033 | 23 | 94,066 |
No | output | 1 | 47,033 | 23 | 94,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
n, m = map(int, input().split())
u = []
sh = []
ans = []
for i in range(n):
u.append(list(input()))
sh.append(['.'] * m)
def star(d, i, j):
global sh
x = d + 1
if i + x < n and i - x >= 0 and j + x < m and j - x >= 0:
if u[i + x][j] == '*' and u[i - x][j] == '*' and u[i][j + x] == '*' and u[i][j - x] == '*':
d += 1
sh[i + x][j] = '*'
sh[i - x][j] = '*'
sh[i][j + x] = '*'
sh[i][j - x] = '*'
sh[i][j] = '*'
return star(d, i, j)
return (i + 1, j + 1, d)
for i in range(n):
for j in range(m):
t = star(0, i, j)
if t[2] > 0:
ans.append(t)
ok = 1
for i in range(n):
for j in range(m):
if u[i][j] != sh[i][j]:
ok = 0
break
if not ok:
print(-1)
else:
print(len(ans))
for i in ans:
for j in i:
print(j, end = ' ')
print()
``` | instruction | 0 | 47,034 | 23 | 94,068 |
No | output | 1 | 47,034 | 23 | 94,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
<image> The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n × m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n ⋅ m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n ⋅ m stars.
Input
The first line of the input contains two integers n and m (3 ≤ n, m ≤ 100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
Output
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0 ≤ k ≤ n ⋅ m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — x_j, y_j and s_j, where x_j is the row index of the central star character, y_j is the column index of the central star character and s_j is the size of the star. Each star should be completely inside the grid.
Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
Note
In the first example the output
2
3 4 1
3 5 2
is also correct.
Submitted Solution:
```
import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
# sys.stdin.readline()
def determine_star(grid, row, col, n, m):
size = 1
while(True):
score = 0
score += int(col+size < m and grid[row][col+size] == '*')
score += int(col-size < m and grid[row][col-size] == '*')
score += int(row+size < m and grid[row+size][col] == '*')
score += int(row-size < m and grid[row-size][col] == '*')
if(score == 0):
return (True, size-1)
elif(score < 4):
if(size != 1):
return (True, size-1)
else:
return (False, 0)
size += 1
def cover_star(grid, row, col, size):
ind = 0
while(ind <= size):
grid[row+ind][col] = 'x'
grid[row-ind][col] = 'x'
grid[row][col+ind] = 'x'
grid[row][col-ind] = 'x'
ind += 1
if __name__ == "__main__":
# single variables
n, m = [int(val) for val in input().split()]
grid = [[val for val in input()] for row in range(n)]
stars = []
for row in range(n):
for col in range(m):
if(grid[row][col] == '*'):
thing = determine_star(grid, row, col, n, m)
if(thing[0]):
stars.append((row, col, thing[1]))
for star in stars:
cover_star(grid, star[0], star[1], star[2])
summ = 0
for row in range(n):
summ += sum([1 for val in grid[row] if val == '*'])
if(summ == 0):
for star in stars:
print(star[0], star[1], star[2])
else:
print(-1)
``` | instruction | 0 | 47,035 | 23 | 94,070 |
No | output | 1 | 47,035 | 23 | 94,071 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n points on the plane, the i-th of which is at (x_i, y_i). Tokitsukaze wants to draw a strange rectangular area and pick all the points in the area.
The strange area is enclosed by three lines, x = l, y = a and x = r, as its left side, its bottom side and its right side respectively, where l, r and a can be any real numbers satisfying that l < r. The upper side of the area is boundless, which you can regard as a line parallel to the x-axis at infinity. The following figure shows a strange rectangular area.
<image>
A point (x_i, y_i) is in the strange rectangular area if and only if l < x_i < r and y_i > a. For example, in the above figure, p_1 is in the area while p_2 is not.
Tokitsukaze wants to know how many different non-empty sets she can obtain by picking all the points in a strange rectangular area, where we think two sets are different if there exists at least one point in one set of them but not in the other.
Input
The first line contains a single integer n (1 ≤ n ≤ 2 × 10^5) — the number of points on the plane.
The i-th of the next n lines contains two integers x_i, y_i (1 ≤ x_i, y_i ≤ 10^9) — the coordinates of the i-th point.
All points are distinct.
Output
Print a single integer — the number of different non-empty sets of points she can obtain.
Examples
Input
3
1 1
1 2
1 3
Output
3
Input
3
1 1
2 1
3 1
Output
6
Input
4
2 1
2 2
3 1
3 2
Output
6
Note
For the first example, there is exactly one set having k points for k = 1, 2, 3, so the total number is 3.
For the second example, the numbers of sets having k points for k = 1, 2, 3 are 3, 2, 1 respectively, and their sum is 6.
For the third example, as the following figure shows, there are
* 2 sets having one point;
* 3 sets having two points;
* 1 set having four points.
Therefore, the number of different non-empty sets in this example is 2 + 3 + 0 + 1 = 6.
<image> | instruction | 0 | 47,099 | 23 | 94,198 |
Tags: data structures, divide and conquer, sortings, two pointers
Correct Solution:
```
import sys
import copy
input = sys.stdin.readline
n=int(input())
P=[list(map(int,input().split())) for i in range(n)]
SET_X=set()
SET_Y=set()
for x,y in P:
SET_X.add(x)
SET_Y.add(y)
CX=sorted(SET_X)
CY=sorted(SET_Y)
LEN=len(CX)
MAX=len(CX)-1
DICT_X={x:i for i,x in enumerate(CX)}
DICT_Y={x:i for i,x in enumerate(CY)}
for i in range(n):
P[i]=[DICT_X[P[i][0]],DICT_Y[P[i][1]]]
check=[0]*len(CX)
# BIT(BIT-indexed tree)
BIT=[0]*(LEN+1)# 1-indexedなtree
def update(v,w):# vにwを加える
while v<=LEN:
BIT[v]+=w
v+=(v&(-v))# 自分を含む大きなノードへ. たとえばv=3→v=4
def getvalue(v):# [1,v]の区間の和を求める
ANS=0
while v!=0:
ANS+=BIT[v]
v-=(v&(-v))# 自分より小さい2ベキのノードへ. たとえばv=3→v=2へ
return ANS
LIST_Y=[[] for i in range(len(CY))]
for x,y in P:
LIST_Y[y].append(x)
for i in range(len(CY)):
LIST_Y[i].sort()
ANS=0
for y in range(len(CY)-1,-1,-1):
for x in LIST_Y[y]:
#print(x,check)
if check[x]==0:
check[x]=1
update(x+1,1)
ANS+=getvalue(LIST_Y[y][0]+1)*(getvalue(MAX+1)-getvalue(LIST_Y[y][0]+1)+1)
for i in range(1,len(LIST_Y[y])):
#print((getvalue(LIST_Y[y][i]+1)-getvalue(LIST_Y[y][i-1]+1)),getvalue(MAX+1))
ANS+=(getvalue(LIST_Y[y][i]+1)-getvalue(LIST_Y[y][i-1]+1))*(getvalue(MAX+1)-getvalue(LIST_Y[y][i]+1)+1)
#print(ANS)
print(ANS)
``` | output | 1 | 47,099 | 23 | 94,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,285 | 23 | 94,570 |
Tags: binary search, number theory
Correct Solution:
```
def gcd(a, b):
if(a % b == 0):
return b
return gcd(b,a%b)
a , b, x, y = map(int,input().split())
t = gcd(x,y)
x ,y= x // t , y // t
k = min(a//x,b//y)
print(k * x,k*y)
``` | output | 1 | 47,285 | 23 | 94,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,286 | 23 | 94,572 |
Tags: binary search, number theory
Correct Solution:
```
# Python 3
from math import gcd
a, b, x, y = list(map(int, input().split()))
g = gcd(x, y)
x //= g
y //= g
k = min(a // x, b // y)
print(k * x, k * y)
``` | output | 1 | 47,286 | 23 | 94,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,287 | 23 | 94,574 |
Tags: binary search, number theory
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', '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")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def Ceil(a,b): return a//b+int(a%b>0)
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()
a,b,x,y=value()
gc=gcd(x,y)
x//=gc
y//=gc
l=a//x
l=min(l,b//y)
print(l*x,l*y)
``` | output | 1 | 47,287 | 23 | 94,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,288 | 23 | 94,576 |
Tags: binary search, number theory
Correct Solution:
```
import sys
from collections import defaultdict as dd
from collections import deque
def eprint(*args):
print(*args, file=sys.stderr)
pl=1
from math import *
import copy
#sys.setrecursionlimit(10**6)
if pl:
input=sys.stdin.readline
def li():
return [int(xxx) for xxx in input().split()]
def fi():
return int(input())
def si():
return list(input().rstrip())
def mi():
return map(int,input().split())
d=[]
from bisect import *
from itertools import permutations
from bisect import *
f=[0 for i in range(100)]
for i in range(1,100):
if i==1:
f[i]=1
else:
f[i]=2*f[i-1]+1
#print(f[:15])
def rec(n,k):
s=[]
while n!=0:
n,r=n//k,n%k
#print(n,r)
if r<0:
r-=k
n+=1
#print(s,n,r)
s.append(r)
return s
a,b,x,y=mi()
g=gcd(x,y)
x//=g
y//=g
l=1
r=10**10
ans=0
aa=[0,0]
while l<=r:
mid=(l+r)//2
#print(x*mid,y*mid)
if x*mid<=a and y*mid<=b:
ans=max(ans,x*y*mid**2)
aa=[x*mid,y*mid]
l=mid+1
else:
r=mid-1
print(*aa)
``` | output | 1 | 47,288 | 23 | 94,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,289 | 23 | 94,578 |
Tags: binary search, number theory
Correct Solution:
```
import sys
import math
import bisect
def solve(a, b, x, y):
t1 = a // x
t2 = b // y
t = min(t1, t2)
return (t * x, t * y)
def main():
a, b, x, y = map(int, input().split())
g = math.gcd(x, y)
x //= g
y //= g
ans = solve(a, b, x, y)
print('%d %d' % (ans[0], ans[1]))
if __name__ == "__main__":
main()
``` | output | 1 | 47,289 | 23 | 94,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,290 | 23 | 94,580 |
Tags: binary search, number theory
Correct Solution:
```
from math import gcd
a, b, x, y = map(int, input().split())
x, y = x // gcd(x, y), y // gcd(x, y)
q = min(a // x, b // y)
print(x * q, y * q)
``` | output | 1 | 47,290 | 23 | 94,581 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,291 | 23 | 94,582 |
Tags: binary search, number theory
Correct Solution:
```
from fractions import gcd
a, b, x, y = map(int, input().split())
g = gcd(x, y)
x, y, = x // g, y // g
v = min(a // x, b // y)
print(v * x, v * y)
# Made By Mostafa_Khaled
``` | output | 1 | 47,291 | 23 | 94,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0 | instruction | 0 | 47,292 | 23 | 94,584 |
Tags: binary search, number theory
Correct Solution:
```
from fractions import gcd
a,b,x,y = map(int, input().split(" "))
g = gcd(x,y)
x,y = x//g, y//g
xmax = a//x
ymax = b//y
res = min(xmax,ymax)
print("%d %d" % (res*x, res*y))
``` | output | 1 | 47,292 | 23 | 94,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
import sys
from array import array # noqa: F401
from math import gcd
def input():
return sys.stdin.buffer.readline().decode('utf-8')
a, b, x, y = map(int, input().split())
x, y = x // gcd(x, y), y // gcd(x, y)
ok, ng = 0, a + 1
while abs(ok - ng) > 1:
mid = (ok + ng) >> 1
if mid * x <= a and mid * y <= b:
ok = mid
else:
ng = mid
print(ok * x, ok * y)
``` | instruction | 0 | 47,293 | 23 | 94,586 |
Yes | output | 1 | 47,293 | 23 | 94,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
import math
a,b,x,y=map(int,input().split())
e=math.gcd(x,y)
x//=e
y//=e
l,r,ans=0,10**10,-1
while(l<=r):
m=(l+r)//2
if(x*m<=a and y*m<=b):
ans=m
l=m+1
else:
r=m-1
print(ans*x,ans*y)
``` | instruction | 0 | 47,294 | 23 | 94,588 |
Yes | output | 1 | 47,294 | 23 | 94,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
a,b,x,y=map(int,input().split())
import math
n=math.gcd(x,y)
x=x//n
y=y//n
t=min(a//x,b//y)
print(x*t,end=" ")
print(y*t)
``` | instruction | 0 | 47,295 | 23 | 94,590 |
Yes | output | 1 | 47,295 | 23 | 94,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
from fractions import gcd
a,b,x,y = map(int,input().split())
m = gcd(x,y)
x,y = x//m,y//m
m = min(a//x,b//y)
print(x*m,y*m)
``` | instruction | 0 | 47,296 | 23 | 94,592 |
Yes | output | 1 | 47,296 | 23 | 94,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
__author__ = 'Darren'
def solve():
a, b, x, y = map(int, input().split())
ans, the_a, the_b = 0, 0, 0
na, nb = a // x * x, a // x * y
if nb > b:
nb = 0
if na * nb > ans:
ans, the_a, the_b = na * nb, na, nb
nb, na = b // y * y, b // y * x
if na > a:
na = 0
if na * nb > ans:
the_a, the_b = na, nb
if ans == 0:
print(0, 0)
else:
print(the_a, the_b)
if __name__ == '__main__':
solve()
``` | instruction | 0 | 47,297 | 23 | 94,594 |
No | output | 1 | 47,297 | 23 | 94,595 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
from math import floor
a, b, x, y = map(int, input().split())
omj1 = a / x
omj2 = b / y
k = floor(min(omj1, omj2))
print(x * k, y * k)
``` | instruction | 0 | 47,298 | 23 | 94,596 |
No | output | 1 | 47,298 | 23 | 94,597 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
a, b, x, y = map(int, input().split(' '))
if a < x or b < y:
i = 2
while i * i <= y:
if x % i == 0 and y % i == 0:
if x // i <= a and y // i <= b:
print(x // i, y // i, sep=' ')
exit()
i += 1
print('0 0')
exit()
l = 0
r = 1e18
while r - l > 1:
mid = (r + l) // 2
if x * mid <= a and y * mid <= b:
l = mid
else:
r = mid
print(int(l * x), int(l * y), sep=' ')
``` | instruction | 0 | 47,299 | 23 | 94,598 |
No | output | 1 | 47,299 | 23 | 94,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Reca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio x: y became popular with users. That's why the company wants to reduce monitor AB999 size so that its screen sides ratio becomes x: y, at the same time they want its total area to be maximal of all possible variants. Your task is to find the screen parameters of the reduced size model, or find out that such a reduction can't be performed.
Input
The first line of the input contains 4 integers — a, b, x and y (1 ≤ a, b, x, y ≤ 2·109).
Output
If the answer exists, output 2 positive integers — screen parameters of the reduced size model. Output 0 0 otherwise.
Examples
Input
800 600 4 3
Output
800 600
Input
1920 1200 16 9
Output
1920 1080
Input
1 1 1 2
Output
0 0
Submitted Solution:
```
def main():
a, b, x, y = map(int, input().split())
na = a - a % x
nb = b - b % y
fa, fb = na // x, nb // y
kb, ka = fa * y, fb * x
kb = 0 if kb > b else kb
ka = 0 if ka > a else ka
na = na if kb is not 0 else 0
nb = nb if ka is not 0 else 0
if na * kb > nb * ka:
print("%d %d\n"%(na, kb))
else:
print("%d %d\n"%(ka, nb))
if __name__ == "__main__":
main()
``` | instruction | 0 | 47,300 | 23 | 94,600 |
No | output | 1 | 47,300 | 23 | 94,601 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,358 | 23 | 94,716 |
Tags: sortings
Correct Solution:
```
from collections import defaultdict
maps = defaultdict(int)
maps1 = defaultdict(int)
arr = []
distinct_count = distinct_count1 = 0
for i in range(8):
temp = list(map(int, input().split()))
if temp[0] not in maps:
distinct_count += 1
if temp[1] not in maps1:
distinct_count1 += 1
maps[temp[0]] = maps1[temp[1]] = 1
arr.append(temp)
if distinct_count != 3 or distinct_count1 != 3:
print('ugly')
exit()
k = sorted(maps.keys())
k1 = sorted(maps1.keys())
for i in range(8):
if arr[i] == [k[1], k1[1]]:
print('ugly')
exit()
for i in range(7):
for j in range(i+1,8):
if arr[j] == arr[i]:
print('ugly')
exit()
print('respectable')
``` | output | 1 | 47,358 | 23 | 94,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,359 | 23 | 94,718 |
Tags: sortings
Correct Solution:
```
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
arr_point = []
for i in range(8):
tmp_x, tmp_y = map(int, input().split())
arr_point.append(Point(tmp_x, tmp_y))
for i in range(8):
for j in range(i+1, 8):
if (arr_point[i].x == arr_point[j].x and arr_point[i].y == arr_point[j].y):
print("ugly")
exit()
distinctX = []
distinctX.append(arr_point[0].x)
distinctY = []
distinctY.append(arr_point[0].y)
for i in range(1, 8):
check_x = check_y = False
for j in range(len(distinctX)):
if (arr_point[i].x == distinctX[j]):
check_x = True
break
for j in range(len(distinctY)):
if (arr_point[i].y == distinctY[j]):
check_y = True
break
if (check_x == False):
distinctX.append(arr_point[i].x)
if (check_y == False):
distinctY.append(arr_point[i].y)
if (len(distinctX) != 3 or len(distinctY) != 3):
print("ugly")
exit()
distinctX.sort()
distinctY.sort()
# print(distinctX)
# print(distinctY)
cnt_point = 0
for k in range(8):
for i in range(len(distinctX)):
for j in range(len(distinctY)):
if (arr_point[k].x == distinctX[i] and arr_point[k].y == distinctY[j]):
if (i != 1 or j != 1):
cnt_point += 1
break
if (cnt_point == 8):
print("respectable")
else:
print("ugly")
``` | output | 1 | 47,359 | 23 | 94,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,360 | 23 | 94,720 |
Tags: sortings
Correct Solution:
```
x, y = [], []
xx, yy = {}, {}
for i in range(8):
a, b = map(int, input().split())
x.append(a)
y.append(b)
if a not in xx:
xx[a] = [b]
else:
xx[a].append(b)
if b not in yy:
yy[b] = [a]
else:
yy[b].append(a)
if len(set(x)) != 3 or len(set(y)) != 3:
print('ugly')
exit()
xxx, yyy = sorted(set(x)), sorted(set(y))
if set(xx[xxx[1]]) != {yyy[0], yyy[2]}:
print('ugly')
exit()
if set(yy[yyy[1]]) != {xxx[0], xxx[2]}:
print('ugly')
exit()
if len(set(xx[xxx[0]])) != 3 or 3 != len(set(xx[xxx[2]])) or len(set(yy[yyy[0]])) != 3 or 3 != len(set(yy[yyy[2]])):
print('ugly')
exit()
print('respectable')
``` | output | 1 | 47,360 | 23 | 94,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,361 | 23 | 94,722 |
Tags: sortings
Correct Solution:
```
def Slove():
A=sorted(tuple(map(int, input().split())) for _ in range(8))
if(A[0][0] == A[1][0]==A[2][0]
< A[3][0]==A[4][0]
< A[5][0]==A[6][0]==A[7][0]
and A[0][1]==A[3][1]==A[5][1]
< A[1][1]==A[6][1]
< A[2][1]==A[4][1]==A[7][1]):
print('respectable')
else:
print('ugly')
Slove()
``` | output | 1 | 47,361 | 23 | 94,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,362 | 23 | 94,724 |
Tags: sortings
Correct Solution:
```
lines = []
for i in range(0, 8):
lines.append(list(map(int, input().split())))
lines = sorted(lines)
countA = [lines[0][0]]
countB = [lines[0][1]]
for i in range(1, len(lines)):
if lines[i][0] != lines[i-1][0]:
countA.append(lines[i][0])
if lines[i][1] not in countB:
countB.append(lines[i][1])
if len(countA) != 3 or len(countB) != 3:
print("ugly")
else:
index = 0
check = True
for i in countA:
for j in countB:
if i == countA[1] and j == countB[1]:
continue
if i != lines[index][0] or j != lines[index][1]:
check = False
break
index+=1
if check:
print("respectable")
else:
print("ugly")
``` | output | 1 | 47,362 | 23 | 94,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,363 | 23 | 94,726 |
Tags: sortings
Correct Solution:
```
if __name__ == "__main__":
point_set = []
for i in range(8):
x, y = map(int, input().split())
point_set.append((x, y))
point_set.sort()
if point_set[0][0] == point_set[1][0] == point_set[2][0]\
and point_set[3][0] == point_set[4][0]\
and point_set[5][0] == point_set[6][0] == point_set[7][0]\
and point_set[2][0] != point_set[3][0]\
and point_set[4][0] != point_set[5][0]\
and point_set[0][1] == point_set[3][1] == point_set[5][1]\
and point_set[1][1] == point_set[6][1]\
and point_set[2][1] == point_set[4][1] == point_set[7][1]\
and point_set[0][1] != point_set[1][1]\
and point_set[1][1] != point_set[2][1]:
print("respectable")
else:
print("ugly")
``` | output | 1 | 47,363 | 23 | 94,727 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,364 | 23 | 94,728 |
Tags: sortings
Correct Solution:
```
import sys
fin = sys.stdin
points = []
for i in range(8):
x, y = map(int, fin.readline().split())
points += [(x, y)]
def CheckPoints(p):
if not p[0][0] == p[1][0] == p[2][0]:
return False
x1 = p[0][0]
if not p[3][0] == p[4][0]:
return False
x2 = p[3][0]
if not p[5][0] == p[6][0] == p[7][0]:
return False
x3 = p[5][0]
if not p[0][1] == p[3][1] == p[5][1]:
return False
y1 = p[0][1]
if not p[1][1] == p[6][1]:
return False
y2 = p[1][1]
if not p[2][1] == p[4][1] == p[7][1]:
return False
y3 = p[2][1]
return x1 < x2 < x3 and y1 < y2 < y3
from itertools import *
for p in permutations(points):
if CheckPoints(p):
print("respectable")
break
else:
print("ugly")
``` | output | 1 | 47,364 | 23 | 94,729 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly | instruction | 0 | 47,365 | 23 | 94,730 |
Tags: sortings
Correct Solution:
```
d = [{}, {}]
t = []
for i in range(8):
x, y = [int(x) for x in input().split()]
if [x, y] in t:
print("ugly")
exit()
t.append([x, y])
if x not in d[0]:
d[0][x] = 1
else:
d[0][x] += 1
if y not in d[1]:
d[1][y] = 1
else:
d[1][y] += 1
if (len(d[0]) == 3) and (len(d[1]) == 3):
a, b = [], []
for k in sorted(d[0]):
a.append(d[0][k])
for k in sorted(d[1]):
b.append(d[1][k])
if (a == [3, 2, 3]) and (b == [3, 2, 3]):
print("respectable")
else:
print("ugly")
else:
print("ugly")
``` | output | 1 | 47,365 | 23 | 94,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
X = dict()
Y = dict()
A = set()
for i in range(8):
x, y = map(int, input().split())
if (x, y) in A:
print('ugly')
exit()
else:
A.add((x, y))
if x in X:
X[x] += 1
else:
X[x] = 1
if y in Y:
Y[y] += 1
else:
Y[y] = 1
X = [(i, X[i]) for i in X]
Y = [(i, Y[i]) for i in Y]
X.sort()
Y.sort()
if len(X) == 3 and len(Y) == 3 and X[0][1] == 3 and X[1][1] == 2 and X[2][1] == 3 and Y[0][1] == 3 and Y[1][1] == 2 and Y[2][1] == 3:
print('respectable')
else:
print('ugly')
``` | instruction | 0 | 47,366 | 23 | 94,732 |
Yes | output | 1 | 47,366 | 23 | 94,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
x = []
y = []
for i in range(8):
xi, yi = map(int, input().split())
x.append(xi)
y.append(yi)
xtmp = sorted(x)
ytmp = sorted(y)
xdist_list = [xtmp[0]]
ydist_list = [ytmp[0]]
for i in range(1, 8):
if xtmp[i] != xtmp[i-1]:
xdist_list.append(xtmp[i])
if ytmp[i] != ytmp[i-1]:
ydist_list.append(ytmp[i])
if len(xdist_list) != 3 or len(ydist_list) != 3:
print('ugly')
exit()
full_eight_points_set = []
for i in range(3):
for j in range(3):
if i != 1 or j != 1:
found = False
for k in range(8):
if x[k] == xdist_list[i] and y[k] == ydist_list[j]:
found = True
break
if not found:
print('ugly')
exit()
print('respectable')
``` | instruction | 0 | 47,367 | 23 | 94,734 |
Yes | output | 1 | 47,367 | 23 | 94,735 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
from collections import *
points = sorted([int(x) for x in input().split()] for i in range(8))
x,y = Counter(), Counter()
for r,c in points:
x[r] += 1
y[c] += 1
xk = sorted(x.keys())
yk = sorted(y.keys())
test = []
for r in xk:
for c in yk:
test.append([r,c])
del test[len(test)//2]
if test == points:
print('respectable')
else:
print('ugly')
``` | instruction | 0 | 47,368 | 23 | 94,736 |
Yes | output | 1 | 47,368 | 23 | 94,737 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
X=[]
Y=[]
Points=[]
k=False
for i in range(8):
x,y=map(int,input().split())
X.append(x)
Y.append(y)
if([x,y] in Points):
k=True
Points.append([x,y])
X.sort()
Y.sort()
if(len(set(X))!=3 or len(set(Y))!=3 or k):
print("ugly")
elif(X.count(X[0])!=3 or X.count(X[3])!=2 or X.count(X[5])!=3):
print("ugly")
elif(Y.count(Y[0])!=3 or Y.count(Y[3])!=2 or Y.count(Y[5])!=3):
print("ugly")
elif([X[3],Y[3]] in Points):
print("ugly")
else:
print("respectable")
``` | instruction | 0 | 47,369 | 23 | 94,738 |
Yes | output | 1 | 47,369 | 23 | 94,739 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
import sys
import math
d = dict()
for i in range(8):
x, y = [int(x) for x in (sys.stdin.readline()).split()]
if x in d:
d[x].append(y)
else:
d[x] = [y]
k = list(d.keys() )
k.sort()
if(len(k) == 3):
if(len(d[k[0]]) == 3 and len(d[k[2]]) == 3):
d[k[0]].sort()
d[k[1]].sort()
d[k[2]].sort()
if(d[k[1]][0] != k[0] or d[k[1]][1] != k[2]):
print("ugly")
exit()
for i in range(3):
if(d[k[0]][i] != d[k[2]][i]):
print("ugly")
exit()
print("respectable")
else:
print("ugly")
else:
print("ugly")
``` | instruction | 0 | 47,370 | 23 | 94,740 |
No | output | 1 | 47,370 | 23 | 94,741 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
ar = [tuple(map(int, input().split(' '))) for i in range(8)]
ar.sort()
print(ar)
print('respectable' if ar[0][0]==ar[1][0]==ar[2][0] and ar[3][0]==ar[4][0] and ar[5][0]==ar[6][0]==ar[7][0] and ar[0][1]==ar[3][1]==ar[5][1] and ar[1][1]==ar[6][1] and ar[2][1]==ar[4][1]==ar[7][1] else 'ugly')
``` | instruction | 0 | 47,371 | 23 | 94,742 |
No | output | 1 | 47,371 | 23 | 94,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
a=[]
b=[]
for i in range(8):
x,y=[int(k) for k in input().split()]
a.append(x)
b.append(y)
seta=set(a)
setb=set(b)
if len(seta)==3 and len(setb)==3:
x1,x2,x3=sorted(seta)
y1,y2,y3=sorted(setb)
if a.count(x2)==2:
print("respectable")
else:
print("ugly")
else:
print("ugly")
``` | instruction | 0 | 47,372 | 23 | 94,744 |
No | output | 1 | 47,372 | 23 | 94,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).
You have a set of eight points. Find out if Gerald can use this set?
Input
The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.
Output
In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.
Examples
Input
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
Output
respectable
Input
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
Output
ugly
Input
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
Output
ugly
Submitted Solution:
```
#------------------------template--------------------------#
import os
import sys
# from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', '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")
ALPHA='abcdefghijklmnopqrstuvwxyz/'
M=998244353
EPS=1e-6
def Ceil(a,b): return a//b+int(a%b>0)
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()
x=set()
y=set()
have=[]
for _ in range(8):
i,j=value()
have.append((i,j))
x.add(i)
y.add(j)
ans="respectable"
# print(x)
# print(y)
if(len(x)!=3 or len(y)!=3): ans="ugly"
else:
no=[]
x=sorted(x)
y=sorted(y)
for i in x:
for j in x:
if((i,j) not in have):no.append((i,j))
# print(no)
if(len(no)!=1 or no[0]!=(x[1],y[1])): ans="ugly"
print(ans)
``` | instruction | 0 | 47,373 | 23 | 94,746 |
No | output | 1 | 47,373 | 23 | 94,747 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,904 | 23 | 95,808 |
"Correct Solution:
```
import math
def koch(d,x1,y1,x2,y2):
if d == 0:
return
xs = (2*x1+x2)/3
ys = (2*y1+y2)/3
xt = (x1+2*x2)/3
yt = (y1+2*y2)/3
xu = (xt-xs)*math.cos(math.pi/3) - (yt-ys)*math.sin(math.pi/3) + xs
yu = (xt-xs)*math.sin(math.pi/3) + (yt-ys)*math.cos(math.pi/3) + ys
koch(d-1,x1,y1,xs,ys)
print(xs,ys)
koch(d-1,xs,ys,xu,yu)
print(xu,yu)
koch(d-1,xu,yu,xt,yt)
print(xt,yt)
koch(d-1,xt,yt,x2,y2)
n = int(input())
print(0.00000000,0.00000000)
koch(n,0.0,0.0,100.0,0.0)
print(100.00000000,0.00000000)
``` | output | 1 | 47,904 | 23 | 95,809 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,905 | 23 | 95,810 |
"Correct Solution:
```
import math
class Point:
def __init__(self,x,y):
self.x=x
self.y=y
def __str__(self):
return str(self.x)+' '+str(self.y)
def koch(n,a,b):
if n==0: return
s=Point(0,0)
t=Point(0,0)
u=Point(0,0)
th=math.pi*60/180
s.x=(2*a.x+1*b.x)/3
s.y=(2*a.y+1*b.y)/3
t.x=(1*a.x+2*b.x)/3
t.y=(1*a.y+2*b.y)/3
u.x=(t.x-s.x)*math.cos(th)-(t.y-s.y)*math.sin(th)+s.x
u.y=(t.x-s.x)*math.sin(th)+(t.y-s.y)*math.cos(th)+s.y
koch(n-1,a,s)
print(s)
koch(n-1,s,u)
print(u)
koch(n-1,u,t)
print(t)
koch(n-1,t,b)
n=int(input())
a=Point(0,0)
b=Point(100,0)
print(a)
koch(n,a,b)
print(b)
``` | output | 1 | 47,905 | 23 | 95,811 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,906 | 23 | 95,812 |
"Correct Solution:
```
import math
def show_vertex(x,y):
print("%.8f %.8f" % (x,y))
def koch(x0,y0,x1,y1,n):
if n == 0:
show_vertex(x0,y0)
else:
c1 = [(2*x0+x1)/3,(2*y0+y1)/3]
c3 = [(x0+2*x1)/3,(y0+2*y1)/3]
c2 = [(3*(x1+x0) -(y1-y0)*math.sqrt(3))/6,((x1-x0)*math.sqrt(3)+3*(y1+y0))/6]
koch(x0,y0,c1[0],c1[1],n-1)
koch(c1[0],c1[1],c2[0],c2[1],n-1)
koch(c2[0],c2[1],c3[0],c3[1],n-1)
koch(c3[0],c3[1],x1,y1,n-1)
N = int(input())
koch(0,0,100,0,N)
show_vertex(100,0)
``` | output | 1 | 47,906 | 23 | 95,813 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,907 | 23 | 95,814 |
"Correct Solution:
```
import math
def koch(start, end, n, r):
if n > 0:
#途中の頂点をa, b, cとする
a = [(start[0]*2 + end[0]*1) / 3, (start[1]*2 + end[1]*1) / 3]
c = [(start[0]*1 + end[0]*2) / 3, (start[1]*1 + end[1]*2) / 3]
x = c[0] - a[0]
y = c[1] - a[1]
b = [x * math.cos(math.pi/3) - y * math.sin(math.pi/3) + a[0], x * math.sin(math.pi/3) + y * math.cos(math.pi/3) + a[1]]
koch(start, a, n-1, r)
koch(a, b, n-1, r)
koch(b, c, n-1, r)
koch(c, end, n-1, r)
else:
r.append(start)
n = int(input())
r = []
koch([0, 0], [100, 0], n, r)
r.append([100, 0])
for rr in r:
print(str(rr[0]) + ' ' + str(rr[1]))
``` | output | 1 | 47,907 | 23 | 95,815 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,908 | 23 | 95,816 |
"Correct Solution:
```
import math
def kochCurve(d, p1, p2):
if d <= 0:
return
s = [(2.0*p1[0]+1.0*p2[0])/3.0, (2.0*p1[1]+1.0*p2[1])/3.0]
t = [(1.0*p1[0]+2.0*p2[0])/3.0, (1.0*p1[1]+2.0*p2[1])/3.0]
u = [(t[0]-s[0])*math.cos(math.radians(60))-(t[1]-s[1])*math.sin(math.radians(60))+s[0], (t[0]-s[0])*math.sin(math.radians(60))+(t[1]-s[1])*math.cos(math.radians(60))+s[1]]
kochCurve(d-1, p1, s)
print(s[0], s[1])
kochCurve(d-1, s, u)
print(u[0], u[1])
kochCurve(d-1, u, t)
print(t[0], t[1])
kochCurve(d-1, t, p2)
n = int(input())
s = [0.00000000, 0.00000000]
e = [100.00000000, 0.00000000]
print(s[0],s[1])
if n != 0:
kochCurve(n,s,e)
print(e[0],e[1])
``` | output | 1 | 47,908 | 23 | 95,817 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,909 | 23 | 95,818 |
"Correct Solution:
```
d = int(input().rstrip())
import math
sin60 = math.sin(math.radians(60))
cos60 = math.cos(math.radians(60))
def make_koch(d, p1, p2):
s = ((p1[0]*2 + p2[0]) / 3, (p1[1]*2 + p2[1]) / 3)
t = ((p1[0] + p2[0]*2) / 3, (p1[1] + p2[1]*2) / 3)
u = ((t[0] - s[0]) * cos60 - (t[1] - s[1])*sin60 + s[0], (t[0] - s[0]) * sin60 + (t[1] - s[1]) * cos60 + s[1])
if d == 0:
return [p1]
elif d == 1:
return [p1, s, u, t]
else:
return make_koch(d-1, p1, s) + make_koch(d-1, s, u) + make_koch(d-1, u, t) + make_koch(d-1, t, p2)
result_list = make_koch(d, (0, 0), (100, 0))
for result in result_list:
print(result[0], result[1])
print("100 0")
``` | output | 1 | 47,909 | 23 | 95,819 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,910 | 23 | 95,820 |
"Correct Solution:
```
from math import*
a=(0,0)
b=(100,0)
def koch(n,ax,ay,bx,by):
if n==0:
return 0
th=pi/3
sx=(2*ax+bx)/3
sy=(2*ay+by)/3
tx=(ax+2*bx)/3
ty=(ay+2*by)/3
ux=(tx-sx)*cos(th)-(ty-sy)*sin(th)+sx
uy=(tx-sx)*sin(th)+(ty-sy)*cos(th)+sy
koch(n-1,ax,ay,sx,sy)
print(sx,sy)
koch(n-1,sx,sy,ux,uy)
print(ux,uy)
koch(n-1,ux,uy,tx,ty)
print(tx,ty)
koch(n-1,tx,ty,bx,by)
n=int(input())
print(*a)
koch(n,*a,*b)
print(*b)
``` | output | 1 | 47,910 | 23 | 95,821 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000 | instruction | 0 | 47,911 | 23 | 95,822 |
"Correct Solution:
```
import math
def kochCurve(p1, p2, n):
if n == 0:
print(p2[0], p2[1])
return
v = [(p2[0]-p1[0])/3, (p2[1]-p1[1])/3]
s = [p1[0]+v[0], p1[1]+v[1]]
t = [s[0]+v[0], s[1]+v[1]]
theta = math.atan2(v[1], v[0]) + math.pi/2
a = math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2)
h = 3**(1/2)*a/2
u = [s[0]+(t[0]-s[0])/2+h*math.cos(theta), s[1]+(t[1]-s[1])/2+h*math.sin(theta)]
n -= 1
kochCurve(p1, s, n)
kochCurve(s, u, n)
kochCurve(u, t, n)
kochCurve(t, p2, n)
if __name__ == "__main__":
n = int(input())
print(0, 0)
kochCurve([0, 0], [100, 0], n)
``` | output | 1 | 47,911 | 23 | 95,823 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.
The Koch curve is well known as a kind of fractals.
You can draw a Koch curve in the following algorithm:
* Divide a given segment (p1, p2) into three equal segments.
* Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
* Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).
<image>
You should start (0, 0), (100, 0) as the first segment.
Notes
Constraints
* 0 ≤ n ≤ 6
Input
An integer n is given.
Output
Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.
Examples
Input
1
Output
0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000
Input
2
Output
0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000
Submitted Solution:
```
import math
def plot(x,y):
print(f'{x:.8f} {y:.8f}')
def Koch(n,x1,y1,x2,y2): #3点を求めるプログラム
if n==0:
plot(x1,y1)
return
sx=(2*x1+x2)/3
sy=(2*y1+y2)/3
tx=(x1+2*x2)/3
ty=(y1+2*y2)/3
ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
Koch(n-1,x1,y1,sx,sy) #分割された座標から求める、n-1で無限ループにならないようにする
Koch(n-1,sx,sy,ux,uy)
Koch(n-1,ux,uy,tx,ty)
Koch(n-1,tx,ty,x2,y2)
n=int(input())
Koch(n,0,0,100,0)
plot(100,0)
``` | instruction | 0 | 47,912 | 23 | 95,824 |
Yes | output | 1 | 47,912 | 23 | 95,825 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.