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.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
def possible(arr):
# 4 possible cases
a,b,c,d,e,f = arr
if(a == c == e and b + d + f == a):
one = "A" * b + "B" * d + "C" * f
print(a)
for i in range(a):
print(one)
return True
if(b == d == f and a + c + e == d):
print(b)
for i in range(a):
print("A" * b)
for i in range(c):
print("B" * b)
for i in range(e):
print("C" * b)
return True
ns = [(a,b,"A"),(c,d,"B"),(e,f,"C")]
fs = [(b, a,"A"),(d, c,"B"),(f, e,"C")]
ns.sort(reverse = True)
x,y,z = ns
a,b,t1 = x
c,d,t2 = y
e,f,t3 = z
if(c + e == a and d == f and d + b == a):
print(a)
mat = [["." for i in range(a)] for j in range(a)]
for i in range(a):
for j in range(b):
mat[i][j] = t1
for i in range(c):
for j in range(b, a):
mat[i][j] = t2
for i in range(c, a):
for j in range(b, a):
mat[i][j] = t3
for i in range(a):
print("".join(mat[i]))
return True
fs.sort(reverse = True)
x,y,z = fs
b,a,t1 = x
d,c,t2 = y
f,e,t3 = z
if(d + f == b and c == e and c + a == b):
print(b)
mat = [["." for i in range(b)] for j in range(b)]
for i in range(a):
for j in range(b):
mat[i][j] =t1
for i in range(a, b):
for j in range(d):
mat[i][j] = t2
for i in range(a, b):
for j in range(d, b):
mat[i][j] = t3
for i in range(b):
print("".join(mat[i]))
return True
return False
arr = [int(x) for x in input().split()]
cnt = 0
ok = False
for i in range(8):
send = [x for x in arr]
if(i&1):
send[0], send[1] = send[1], send[0]
if(i&2):
send[2], send[3] = send[3], send[2]
if(i&4):
send[4], send[5] = send[5], send[4]
if(possible(send)):
ok = True
break
if(not ok):
print(-1)
``` | instruction | 0 | 87,075 | 23 | 174,150 |
Yes | output | 1 | 87,075 | 23 | 174,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
x1, y1, x2, y2, x3, y3 = map(int, input().split())
rect1 = [x1, y1]
rect2 = [x2, y2]
rect3 = [x3, y3]
def func():
rect11 = [x1, y1]
rect22 = [x2, y2]
rect33 = [x3, y3]
rect1 = [x1, y1]
rect2 = [x2, y2]
rect3 = [x3, y3]
recta = [x1, y1]
rectb = [x2, y2]
rectc = [x3, y3]
for i in rect11:
for ii in rect22:
for iii in rect33:
if i==ii:
rect1.remove(i)
rect2.remove(ii)
if rect1[0]+rect2[0]==iii:
rect3.remove(iii)
if i+rect3[0]==iii:
print(iii)
for j in range(iii):
if j<rect1[0]:
print("C"*rect3[0]+"A"*i)
else:
print("C"*rect3[0]+"B"*ii)
exit()
rect1=recta.copy()
rect2=rectb.copy()
rect3=rectc.copy()
if i==iii:
rect1.remove(i)
rect3.remove(iii)
if rect1[0]+rect3[0]==ii:
rect2.remove(ii)
if i+rect2[0]==ii:
print(ii)
for j in range(ii):
if j<rect1[0]:
print("B"*rect2[0]+"A"*i)
else:
print("B"*rect2[0]+"C"*iii)
exit()
rect1 = recta.copy()
rect2 = rectb.copy()
rect3 = rectc.copy()
if ii==iii:
rect2.remove(ii)
rect3.remove(iii)
if rect2[0]+rect3[0]==i:
rect1.remove(i)
if i==rect1[0]+ii:
print(i)
for j in range(i):
if j<rect2[0]:
print("A"*rect1[0]+"B"*ii)
else:print("A"*rect1[0]+"C"*iii)
exit()
rect1=recta.copy()
rect2=rectb.copy()
rect3=rectc.copy()
return print(-1)
for i in rect1:
for ii in rect2:
for iii in rect3:
recta = [x1, y1]
rectb = [x2, y2]
rectc = [x3, y3]
if i==ii==iii:
rect1.remove(i)
rect2.remove(i)
rect3.remove(i)
if rect1[0]+rect2[0]+rect3[0]==i:
print(i)
for j in range(i):
print("A"*rect1[0]+"B"*rect2[0]+"C"*rect3[0])
exit()
rect1=recta
rect2=rectb
rect3=rectc
func()
``` | instruction | 0 | 87,076 | 23 | 174,152 |
Yes | output | 1 | 87,076 | 23 | 174,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
def getprint(c1, c2, c3, maxi, ost, delta):
ans = str(maxi) + "\n" + (c1 * maxi + "\n") * ost
return ans + (c2 * delta + c3 * (maxi - delta) + "\n") * (maxi - ost)
def solve():
a = list(map(int, input().split()))
if max(a) ** 2 != a[0] * a[1] + a[2] * a[3] + a[4] * a[5]:
return -1
maxi = max(a)
if maxi in a[:2] and maxi in a[2:4] and maxi in a[4:]:
return str(maxi) + "\n" + ("A" * maxi + "\n") * min(a[:2]) + ("B" * maxi + "\n") * min(a[2:4]) + ("C" * maxi + "\n") * min(a[4:])
ind = a.index(maxi)
ost = a[ind ^ 1]
if ind // 2 == 0 and maxi - ost in a[2:4] and maxi - ost in a[4:]:
return getprint("A", "B", "C", maxi, ost, a[2] * a[3] // (maxi - ost))
elif ind // 2 == 1 and maxi - ost in a[:2] and maxi - ost in a[4:]:
return getprint("B", "A", "C", maxi, ost, a[0] * a[1] // (maxi - ost))
elif ind // 2 == 2 and maxi - ost in a[:2] and maxi - ost in a[2:4]:
return getprint("C", "A", "B", maxi, ost, a[0] * a[1] // (maxi - ost))
return -1
print(solve())
``` | instruction | 0 | 87,077 | 23 | 174,154 |
Yes | output | 1 | 87,077 | 23 | 174,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
import sys
#this solves only a specific orientation
#is fine because we consider all orientations
import itertools
def can(h1, w1, h2, w2, h3, w3, c1, c2, c3, tot):
#height = h1
if tot % h1 == 0 and tot // h1 == h1:
# side by side or on top of each other are the two options
# side by side
if h1 == h2 == h3:
print(h1)
for r in range(h1):
temp = ""
for c in range(w1 + w2 + w3):
if c < w1: temp += c1
elif c < w1 + w2: temp += c2
else: temp += c3
print(temp)
return True
if h2 + h3 == h1 and w2 == w3:
print(h1)
for r in range(h1):
temp = ""
for c in range(w1 + w2):
if c < w1: temp += c1
else:
if r < h2: temp += c2
else: temp += c3
print(temp)
return True
return False
def solve(perm):
x1, y1 = perm[0][0][0], perm[0][0][1]
x2, y2 = perm[1][0][0], perm[1][0][1]
x3, y3 = perm[2][0][0], perm[2][0][1]
c1 = perm[0][1]
c2 = perm[1][1]
c3 = perm[2][1]
tot = x1 * y1 + x2 * y2 + x3 * y3
for sw1 in range(2):
for sw2 in range(2):
for sw3 in range(2):
h1, w1, h2, w2, h3, w3 = x1, y1, x2, y2, x3, y3
if sw1 == 1: h1, w1 = w1, h1
if sw2 == 1: h2, w2 = w2, h2
if sw3 == 1: h3, w3 = w3, h3
if can(h1, w1, h2, w2, h3, w3, c1, c2, c3, tot):
return True
def supersolve():
x1, y1, x2, y2, x3, y3, = rv()
a = [([x1, y1], 'A'), ([x2, y2], 'B'), ([x3, y3], 'C')]
for perm in itertools.permutations(a):
if solve(perm): return
print(-1)
def prt(l): return print(' '.join(map(str, l)))
def rs(): return map(str, input().split())
def rv(): return map(int, input().split())
def rl(n): return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
supersolve()
``` | instruction | 0 | 87,078 | 23 | 174,156 |
Yes | output | 1 | 87,078 | 23 | 174,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
def stripe(a, b, c, x):
y1 = a[0] if a[1] == x else a[1]
y2 = b[0] if b[1] == x else b[1]
y3 = c[0] if c[1] == x else c[1]
ans = []
ans.append('\n'.join('A'*x for _ in range(y1)))
ans.append('\n'.join('B'*x for _ in range(y2)))
ans.append('\n'.join('C'*x for _ in range(y3)))
return '\n'.join(ans)
def tt(aa):
return (aa[1], aa[0], aa[2])
def one_two(a, b, c):
ans = []
ans.append('\n'.join(a[2]*a[0] for _ in range(a[1])))
for _ in range(b[1]):
ans.append(b[2]*b[0] + c[2]*c[0])
return '\n'.join(ans)
def solve():
x1, y1, x2, y2, x3, y3 = map(int, input().split())
a = (x1, y1, 'A')
b = (x2, y2, 'B')
c = (x3, y3, 'C')
# case 1, stripe
for x in a:
if x in b and x in c:
return stripe(a, b, c, x)
# case 2
from itertools import permutations
for a, b, c in permutations((a, b, c)):
for a, b, c in ((a, b, c), (tt(a), b, c), (a, tt(b), c), (a, b, tt(c)),
(tt(a), tt(b), c), (tt(a), b, tt(c)), (a, tt(b), tt(c)),
(tt(a), tt(b), tt(c))):
if a[0] == b[0] + c[0] and b[1] == c[1]:
return one_two(a, b, c)
return -1
print(solve())
``` | instruction | 0 | 87,079 | 23 | 174,158 |
No | output | 1 | 87,079 | 23 | 174,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
"""
Author - Satwik Tiwari .
21th NOV , 2020 - Saturday
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
# from itertools import *
from heapq import *
from math import gcd, factorial,floor,ceil,sqrt
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
#==============================================================================================
#fast I/O region
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")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
# inp = lambda: sys.stdin.readline().rstrip("\r\n")
#===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
def wrapped_func(*args, **kwargs):
if stack: return f(*args, **kwargs)
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
continue
stack.pop()
if not stack: break
to = stack[-1].send(to)
return to
return wrapped_func
#### END ITERATE RECURSION ####
#===============================================================================================
#some shortcuts
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var)) #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
# def graph(vertex): return [[] for i in range(0,vertex+1)]
def testcase(t):
for pp in range(t):
solve(pp)
def google(p):
print('Case #'+str(p)+': ',end='')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(x, y, p) :
y%=(p-1) #not so sure about this. used when y>p-1. if p is prime.
res = 1 # Initialize result
x = x % p # Update x if it is more , than or equal to p
if (x == 0) :
return 0
while (y > 0) :
if ((y & 1) == 1) : # If y is odd, multiply, x with result
res = (res * x) % p
y = y >> 1 # y = y/2
x = (x * x) % p
return res
def ncr(n,r): return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))
def isPrime(n) :
if (n <= 1) : return False
if (n <= 3) : return True
if (n % 2 == 0 or n % 3 == 0) : return False
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6
return True
inf = pow(10,20)
mod = 10**9+7
#===============================================================================================
# code here ;))
def solve(case):
x1,y1,x2,y2,x3,y3 = sep()
arr = x1*y1 + x2*y2 + x3*y3
for jj in range(8):
# print(x1,x2,x3,y1,y2,y3,x1 == x2,x2 == x3,y1+y2+y2, x1)
if(x1 == x2 and x2 == x3 and y1+y2+y3 == x1):
print(x1)
g = [[0 for _ in range(x1)] for __ in range(x1)]
for i in range(x1):
for j in range(y1):
g[i][j] = 'A'
for i in range(x1):
for j in range(y1,y1+y2):
g[i][j] = 'B'
for i in range(x1):
for j in range(y1+y2,y1+y2+y3):
g[i][j] = 'C'
for i in range(x1):
print(''.join(g[i]))
return
else:
pass
x1,y1 = y1,x1
if(jj%2==1):
x2,y2 = y2,x2
if(jj%4==3):
x3,y3 = y3,x3
# print('==')
# x1,y1 = y1,x1
# x2,y2 = y2,x2
# x3,y3 = y3,x3
for jj in range(8):
# print(x1,y1,x2,y2,x3,y3)
n = [x1+x2,x1+x3,x2+x3]
for i in range(len(n)):
# print(arr,n[i]*n[i])
if(arr != (n[i]*n[i])):
continue
g = [[0 for _ in range(n[i])] for __ in range(n[i])]
if(i == 0 or i == 5):
for j in range(x1):
for k in range(y1):
g[j][k] = 'A'
for j in range(x1,x1+x2):
for k in range(y2):
g[j][k] = 'B'
for j in range(n[i]):
for k in range(n[i]):
if(g[j][k] == 0):
g[j][k] = 'C'
print(n[i])
for ii in range(n[i]):
print(''.join(g[ii]))
return
if(i == 1 or i == 4):
# print(x1,x2,x3,y1,y2,y3,n[i],i)
for j in range(x1):
for k in range(y1):
g[j][k] = 'A'
for j in range(x1,x1+x3):
for k in range(y3):
g[j][k] = 'C'
for j in range(n[i]):
for k in range(n[i]):
if(g[j][k] == 0):
g[j][k] = 'B'
print(n[i])
for ii in range(n[i]):
print(''.join(g[ii]))
return
if(i == 2 or i==3):
# print(x1,x2,x3,y1,y2,y3,n[i])
for j in range(x2):
for k in range(y2):
g[j][k] = 'B'
for j in range(x2,x3+x2):
for k in range(y3):
g[j][k] = 'C'
for j in range(n[i]):
for k in range(n[i]):
if(g[j][k] == 0):
g[j][k] = 'A'
print(n[i])
for ii in range(n[i]):
print(''.join(g[ii]))
return
x1,y1 = y1,x1
if(jj%2==1):
x2,y2 = y2,x2
if(jj%4==3):
x3,y3 = y3,x3
print(-1)
testcase(1)
# testcase(int(inp()))
``` | instruction | 0 | 87,080 | 23 | 174,160 |
No | output | 1 | 87,080 | 23 | 174,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
x1, y1, x2, y2, x3, y3 = map(int, input().split())
x1, y1 = max(x1, y1), min(x1, y1)
x2, y2 = max(x2, y2), min(x2, y2)
x3, y3 = max(x3, y3), min(x3, y3)
x1c, y1c, x2c, y2c, x3c, y3c = x1, y1, x2, y2, x3, y3
if x2 == max(x1, x2, x3) :
x1, y1, x2, y2 = x2, y2, x1, y1
elif x3 == max(x1, x2, x3) :
x1, y1, x3, y3 = x3, y3, x1, y1
if x1 == x1c and y1 == y1c and x2 == x2c and y2 == y2c :
s1 = 'A'
s2 = 'B'
s3 = 'C'
elif x1 == x1c and y1 == y1c and x2 == x3c and y2 == y3c :
s1 = 'A'
s2 = 'C'
s3 = 'B'
elif x1 == x2c and y1 == y2c and x2 == x1c and y2 == y1c :
s1 = 'B'
s2 = 'A'
s3 = 'C'
elif x1 == x2c and y1 == y2c and x2 == x3c and y2 == y3c :
s1 = 'B'
s2 = 'C'
s3 = 'A'
elif x1 == x3c and y1 == y3c and x2 == x1c and y2 == y1c :
s1 = 'C'
s2 = 'A'
s3 = 'B'
elif x1 == x3c and y1 == y3c and x2 == x2c and y2 == y2c :
s1 = 'C'
s2 = 'B'
s3 = 'A'
if x1 == x2 == x3 and y1 + y2 + y3 == x1 :
print(x1)
for i in range(x1) :
for j in range(x1) :
if i < y1 :
print(s1, end = '')
elif y1 <= i < y1 + y2 :
print(s2, end = '')
else :
print(s3, end = '')
print()
elif x1 == y2 + x3 and x2 + y1 == y3 + y1 == x1 :
print(x1)
for i in range(x1) :
for j in range(x1) :
if i < y1 :
print(s1, end = '')
else :
if j < y2 :
print(s2, end = '')
else :
print(s3, end = '')
print()
elif x1 == x2 + y3 and y2 + y1 == x3 + y1 == x1 :
print(x1)
for i in range(x1) :
for j in range(x1) :
if i < y1 :
print(s1, end = '')
else :
if j < x2 :
print(s2, end = '')
else :
print(s3, end = '')
print()
else :
print(-1)
``` | instruction | 0 | 87,081 | 23 | 174,162 |
No | output | 1 | 87,081 | 23 | 174,163 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.
Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.
Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.
Input
The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.
Output
If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).
If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:
* the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
* the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
* the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,
Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.
See the samples to better understand the statement.
Examples
Input
5 1 2 5 5 2
Output
5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC
Input
4 4 2 6 4 2
Output
6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC
Submitted Solution:
```
from collections import namedtuple
from itertools import permutations
Rect = namedtuple("Rect", "h w")
def rotations(r):
yield r
yield Rect(r[1], r[0])
def main():
a, b, c, d, e, f = map(int, input().split())
a = Rect(a, b)
b = Rect(c, d)
c = Rect(e, f)
del d, e, f
for a0 in rotations(a):
for b0 in rotations(b):
for c0 in rotations(c):
for x, y, z in permutations((a0, b0, c0), 3):
if x.w == y.w == z.w == x.h + y.h + z.h:
# AAA
# BBB
# CCC
print(x.w)
for i in range(x.h):
print('A' * x.w)
for i in range(y.h):
print('B' * y.w)
for i in range(z.h):
print('C' * z.w)
return
elif x.w == y.w + z.w == x.h + y.h and y.h == z.h:
# AAA
# BBC
# BBC
print(x.w)
for i in range(x.h):
print('A' * x.w)
for i in range(y.h):
print('B' * y.w, end="")
print('C' * z.w)
return
print(-1)
main()
``` | instruction | 0 | 87,082 | 23 | 174,164 |
No | output | 1 | 87,082 | 23 | 174,165 |
Provide a correct Python 3 solution for this coding contest problem.
We understand that reading English is a great pain to many of you. So we’ll keep this problem statememt simple. Write a program that reports the point equally distant from a set of lines given as the input. In case of no solutions or multiple solutions, your program should report as such.
Input
The input consists of multiple datasets. Each dataset is given in the following format:
n
x1,1 y1,1 x1,2 y1,2
x2,1 y2,1 x2,2 y2,2
...
xn,1 yn,1 xn,2 yn,2
n is the number of lines (1 ≤ n ≤ 100); (xi,1, yi,1) and (xi,2, yi,2) denote the different points the i-th line passes through. The lines do not coincide each other. The coordinates are all integers between -10000 and 10000.
The last dataset is followed by a line containing one zero. This line is not a part of any dataset and should not be processed.
Output
For each dataset, print a line as follows. If there is exactly one point equally distant from all the given lines, print the x- and y-coordinates in this order with a single space between them. If there is more than one such point, just print "Many" (without quotes). If there is none, just print "None" (without quotes).
The coordinates may be printed with any number of digits after the decimal point, but should be accurate to 10-4.
Example
Input
2
-35 -35 100 100
-49 49 2000 -2000
4
0 0 0 3
0 0 3 0
0 3 3 3
3 0 3 3
4
0 3 -4 6
3 0 6 -4
2 3 6 6
-1 2 -4 6
0
Output
Many
1.5000 1.5000
1.000 1.000 | instruction | 0 | 87,469 | 23 | 174,938 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
EPS = 1e-9
def line_cross_point(P1, P2, Q1, Q2):
x0, y0 = P1; x1, y1 = P2
x2, y2 = Q1; x3, y3 = Q2
dx0 = x1 - x0; dy0 = y1 - y0
dx1 = x3 - x2; dy1 = y3 - y2
s = (y0-y2)*dx1 - (x0-x2)*dy1
sm = dx0*dy1 - dy0*dx1
if -EPS < sm < EPS:
return None
return x0 + s*dx0/sm, y0 + s*dy0/sm
def bisector(P1, P2, Q1, Q2):
x0, y0 = P1; x1, y1 = P2
x2, y2 = Q1; x3, y3 = Q2
dx0 = x1 - x0; dy0 = y1 - y0
dx1 = x3 - x2; dy1 = y3 - y2
cp = line_cross_point(P1, P2, Q1, Q2)
if cp is None:
return None
cx, cy = cp
d0 = (dx0**2 + dy0**2)**.5
d1 = (dx1**2 + dy1**2)**.5
return [
((cx, cy), (cx + (dx0*d1 + dx1*d0), cy + (dy0*d1 + dy1*d0))),
((cx, cy), (cx + (dx0*d1 - dx1*d0), cy + (dy0*d1 - dy1*d0))),
]
def line_point_dist2(p1, p2, q):
x, y = q
x1, y1 = p1; x2, y2 = p2
dx = x2 - x1; dy = y2 - y1
dd = dx**2 + dy**2
sv = (x - x1) * dy - (y - y1) * dx
return abs(sv / dd**.5)
def check(LS, q):
ds = [line_point_dist2(p1, p2, q) for p1, p2 in LS]
return all(abs(ds[0] - e) < EPS for e in ds)
def solve():
N = int(readline())
if N == 0:
return False
P = []
for i in range(N):
x1, y1, x2, y2 = map(int, readline().split())
P.append(((x1, y1), (x2, y2)))
if N <= 2:
write("Many\n")
return True
s = []
for i in range(N):
p1, p2 = P[i]
for j in range(i):
q1, q2 = P[j]
bs = bisector(p1, p2, q1, q2)
if bs is None:
continue
s.append(bs)
if len(s) > 1:
break
else:
continue
break
if len(s) < 2:
write("None\n")
return True
ans = []
b1, b2 = s
for p1, p2 in b1:
for q1, q2 in b2:
cp = line_cross_point(p1, p2, q1, q2)
if cp is None:
continue
if check(P, cp):
cx, cy = cp
for ax, ay in ans:
if abs(cx - ax) < EPS and abs(cy - ay) < EPS:
break
else:
ans.append(cp)
if len(ans) == 0:
write("None\n")
elif len(ans) > 1:
write("Many\n")
else:
write("%.16f %.16f\n" % ans[0])
return True
while solve():
...
``` | output | 1 | 87,469 | 23 | 174,939 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
import sys
input=sys.stdin.readline
lastodd=[]
n=int(input())
a=[int(i) for i in input().split()]
ans=0
for i in range(n):
if not a[i]&1:
ans+=a[i]//2
else:
if lastodd:
if (i-lastodd[-1])&1:
ans+=1
lastodd.pop()
else:
lastodd.append(i)
else:
lastodd.append(i)
ans+=a[i]//2
print(ans)
``` | instruction | 0 | 87,693 | 23 | 175,386 |
Yes | output | 1 | 87,693 | 23 | 175,387 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
w=0
b=0
for i in range(n):
if i%2==0:
if a[i]%2==1:
b+=1
b+=a[i]//2
w+=a[i]//2
else:
if a[i]%2==1:
w+=1
b+=a[i]//2
w+=a[i]//2
print(min(w,b))
``` | instruction | 0 | 87,694 | 23 | 175,388 |
Yes | output | 1 | 87,694 | 23 | 175,389 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
import math
N = int(input())
arr = [int(x) for x in input().split()]
tot = 0
hor = 0
for i in range(N):
if arr[i] >= hor or (hor%2 == arr[i]%2):
tot += int(math.ceil(min(hor, arr[i])/2))
else:
tot += int(math.ceil((min(hor, arr[i])-1)/2))
if arr[i] >= hor:
tot += (arr[i]-hor)//2
if (arr[i] - hor) % 2 == 0:
hor = max(hor-1, 0)
else:
hor += 1
else:
hor -= 1
hor2 = arr[i]
if hor2%2 != hor%2: hor2 -= 1
hor = max(hor2, 0)
#print(tot, hor)
print(tot)
``` | instruction | 0 | 87,695 | 23 | 175,390 |
Yes | output | 1 | 87,695 | 23 | 175,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
def main():
n=int(input())
a=readIntArr()
whites=0
blacks=0
for i,x in enumerate(a):
y=x//2
z=x-y
if i%2==0:
whites+=y
blacks+=z
else:
whites+=z
blacks+=y
print(min(whites,blacks))
return
import sys
# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
def oneLineArrayPrint(arr):
print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
def readIntArr():
return [int(x) for x in input().split()]
# def readFloatArr():
# return [float(x) for x in input().split()]
def makeArr(defaultVal,dimensionArr): # eg. makeArr(0,[n,m])
dv=defaultVal;da=dimensionArr
if len(da)==1:return [dv for _ in range(da[0])]
else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
def queryInteractive(x,y):
print('? {} {}'.format(x,y))
sys.stdout.flush()
return int(input())
def queryInteractive2(arr):
print('? '+' '.join([str(x) for x in arr]))
sys.stdout.flush()
return [int(x) for x in input().split()]
def answerInteractive(ans):
print('! {}'.format(ans))
sys.stdout.flush()
inf=float('inf')
MOD=10**9+7
for _abc in range(1):
main()
``` | instruction | 0 | 87,696 | 23 | 175,392 |
Yes | output | 1 | 87,696 | 23 | 175,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
def dominos(n, list1):
count=0
prev=False
for x in list1:
count+= x//2
if(x%2==1):
if(prev):
count+=1
else: prev=True
else: prev=False
return count
n= input()
list1= input().split()
list1 = [ int(x) for x in list1]
print(dominos(n,list1))
``` | instruction | 0 | 87,697 | 23 | 175,394 |
No | output | 1 | 87,697 | 23 | 175,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
n=int(input())
ar=list(map(int,input().split()))
res=[i//2 for i in ar]
print(sum(res))
``` | instruction | 0 | 87,698 | 23 | 175,396 |
No | output | 1 | 87,698 | 23 | 175,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
a=int(input())
y=list(map(int,input().split()))
y.sort()
t=0
while len(y)!=0:
u=y[0]
t+=len(y)//2*y[0]
for i in range(y.count(y[0])):
y.remove(y[0])
for k in range(len(y)):
y[k]-=u
print(t)
``` | instruction | 0 | 87,699 | 23 | 175,398 |
No | output | 1 | 87,699 | 23 | 175,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, …, a_n (a_1 ≥ a_2 ≥ … ≥ a_n ≥ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1 × 2 or 2 × 1 rectangle.
Input
The first line of input contain one integer n (1 ≤ n ≤ 300 000): the number of columns in the given histogram.
The next line of input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300 000, a_i ≥ a_{i+1}): the lengths of columns.
Output
Output one integer: the largest number of non-overlapping dominos that you can draw inside of the given Young diagram.
Example
Input
5
3 2 2 2 1
Output
4
Note
Some of the possible solutions for the example:
<image> <image>
Submitted Solution:
```
from sys import stdin,stdout
n = int(stdin.readline().strip())
alist = list(map(int,stdin.readline().split()))
k = max(alist)
total,odd,even = 0,0,0
for i,a in enumerate(alist):
total += a//2
if i%2:
odd+=1
else:
even+=1
total+=min(odd,even)
print(total)
``` | instruction | 0 | 87,700 | 23 | 175,400 |
No | output | 1 | 87,700 | 23 | 175,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,833 | 23 | 175,666 |
Tags: implementation
Correct Solution:
```
for _ in range(int(input())) :
n=int(input());a=[]
l=[[0 for i in range(n)] for j in range(n)]
for i in range(n) :
s=input()
for j in range(n) :
if(s[j]=="*") :
a.append([i,j])
l[i][j]=s[j]
x1=a[0][0];y1=a[0][1]
x2=a[1][0];y2=a[1][1]
if(x1!=x2 and y1!=y2) :
l[x1][y2]="*"
l[x2][y1]="*"
elif(x1==x2) :
if(x1==0 and x2==0) :
l[x1+1][y1]="*"
l[x2+1][y2]="*"
else :
l[x1-1][y1]="*"
l[x2-1][y2]="*"
elif(y1==y2) :
if(y1==0 and y2==0) :
l[x1][y1+1]="*"
l[x2][y2+1]="*"
else :
l[x1][y1-1]="*"
l[x2][y2-1]="*"
for i in range(n) :
for j in range(n) :
print(l[i][j],end="")
print()
``` | output | 1 | 87,833 | 23 | 175,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,834 | 23 | 175,668 |
Tags: implementation
Correct Solution:
```
test =int(input())
while test>0:
n = int(input())
arr =[]
for i in range(n):
arr.append(list(input()))
x=y=0
x1=y1=0
count=1
for i in range(n):
for j in range(n):
if count==1 and arr[i][j]=="*":
x=j
y=i
count+=1
elif count==2 and arr[i][j]=="*":
x1=j
y1=i
break
if y==y1:
arr[(y+1)%n][x1]="*"
arr[(y+1)%n][x]="*"
elif x1==x:
arr[y1][(x1+1)%n]="*"
arr[y][(x+1)%n]="*"
else:
arr[y][x1]="*"
arr[y1][x]="*"
for s1 in arr:
s=""
for a in s1:
s+=str(a)
print(s)
test-=1
``` | output | 1 | 87,834 | 23 | 175,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,835 | 23 | 175,670 |
Tags: implementation
Correct Solution:
```
# cook your dish here
for _ in range(int(input())):
n = int(input())
arr = []
for i in range(n):
temp = list(input())
arr.append(temp)
pos1 = -1
pos2 = -1
for i in range(n):
for j in range(n):
if arr[i][j] == "*":
if pos1 == -1:
pos1 = [i, j]
else:
pos2 = [i, j]
break
if pos1[0] == pos2[0]:
if ((pos1[0] + 1) < n):
arr[pos1[0]+1][pos1[1]] = "*"
arr[pos2[0]+1][pos2[1]] = "*"
else:
arr[pos1[0]-1][pos1[1]] = "*"
arr[pos2[0]-1][pos2[1]] = "*"
elif pos1[1] == pos2[1]:
if ((pos1[1] + 1) < n):
arr[pos1[0]][pos1[1]+1] = "*"
arr[pos2[0]][pos2[1]+1] = "*"
else:
arr[pos1[0]][pos1[1]-1] = "*"
arr[pos2[0]][pos2[1]-1] = "*"
else:
arr[pos1[0]][pos2[1]] = "*"
arr[pos2[0]][pos1[1]] = "*"
for i in range(n):
s = ""
print(s.join(arr[i]))
``` | output | 1 | 87,835 | 23 | 175,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,836 | 23 | 175,672 |
Tags: implementation
Correct Solution:
```
import sys
import math
input = sys.stdin.readline
mod=(10**9)+7
############ ---- Input Functions ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
for _ in range(inp()):
n=inp()
l=[]
r=-1
c=-1
r1=-1
c1=-1
for i in range(n):
a=insr()
l.append(a)
for j in range(n):
if a[j]=="*":
if r==-1:
r=i
c=j
continue
if r1==-1:
r1=i
c1=j
if r1==r:
if r!=n-1:
l[r+1][c]="*"
l[r1+1][c1]="*"
else:
l[r-1][c]="*"
l[r1-1][c1]="*"
elif c1==c:
if c!=n-1:
l[r][c+1]="*"
l[r1][c+1]="*"
else:
l[r][c-1]="*"
l[r1][c-1]="*"
else:
l[r][c1]="*"
l[r1][c]="*"
for i in range(n):
print("".join(j for j in l[i]))
``` | output | 1 | 87,836 | 23 | 175,673 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,837 | 23 | 175,674 |
Tags: implementation
Correct Solution:
```
n = int(input())
for z in range(n):
t = int(input())
x = []
y = []
l = [list(str(input())) for _ in range(t)]
d = {}
for i in range(t):
for j in range(t):
if l[i][j] == '*':
x.append(i)
y.append(j)
k = list(zip(x,y))
################################################
if k[0][0] != k[1][0]:
if k[0][0] > k[1][0] and k[0][1] != k[1][1]:
first_x = k[0][0]
first_y = k[1][1]
second_x = k[1][0]
second_y = k[0][1]
elif k[0][0] < k[1][0] and k[0][1] != k[1][1]:
first_x = k[1][0]
first_y = k[0][1]
second_x = k[0][0]
second_y = k[1][1]
if k[0][1] == k[1][1]:
if l[k[0][0]][-1] == '*':
first_x = k[0][0]
first_y = k[0][1] -1
second_x = k[1][0]
second_y = k[1][1] -1
else:
first_x = k[0][0]
first_y = k[0][1] +1
second_x = k[1][0]
second_y = k[1][1] +1
if k[0][0] == k[1][0]:
if l[0][k[0][1]] == '*':
first_x = k[0][0]+1
first_y = k[0][1]
second_x = k[1][0]+1
second_y = k[1][1]
else:
first_x = k[0][0]-1
first_y = k[0][1]
second_x = k[1][0]-1
second_y = k[1][1]
##############################################
l[first_x][first_y] = '*'
l[second_x][second_y] = '*'
for i in range(t):
print(''.join(l[i]))
``` | output | 1 | 87,837 | 23 | 175,675 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,838 | 23 | 175,676 |
Tags: implementation
Correct Solution:
```
import sys
sys.setrecursionlimit(10**6)
def main(t):
n = int(input())
matrix = []
row = 0
track = []
for i in range(n):
col = 0
k = input()
for i in k:
if i=='*':
track.append(row)
track.append(col)
col+=1
row+=1
matrix.append(k)
r1,c1,r2,c2 = track
if r1==r2:
if r1+1<n:
matrix[r1+1] = matrix[r1]
else:
matrix[r1-1] = matrix[r1]
elif c1==c2:
if c1+1<n:
k = matrix[r1][:c1+1]+'*'+matrix[r1][c1+2:]
else:
k = matrix[r1][:c1-1]+'*'+matrix[r1][c1:]
matrix[r1] = matrix[r2] = k
else:
matrix[r1] = matrix[r1][:c2]+'*'+matrix[r1][c2+1:]
matrix[r2] = matrix[r1][:c1]+'*'+matrix[r1][c1+1:]
print(*matrix,sep='\n')
if t>1:
main(t-1)
main(int(input()))
``` | output | 1 | 87,838 | 23 | 175,677 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,839 | 23 | 175,678 |
Tags: implementation
Correct Solution:
```
t = int(input())
for x in range(t):
n = int(input())
a = [list(input()) for i in range(n)]
c = [(i,j) for i in range(n) for j in range(n) if a[i][j]=='*']
# c00 = x0 c01 = y0 c10 = x1 c11 = y1
if c[0][0] == c[1][0]:
if c[0][0] < n-1:
c.append((c[0][0]+1, c[0][1]))
c.append((c[0][0]+1, c[1][1]))
else:
c.append((c[0][0]-1, c[0][1]))
c.append((c[0][0]-1, c[1][1]))
elif c[0][1] == c[1][1]:
if c[0][1] < n-1:
c.append((c[0][0], c[0][1]+1))
c.append((c[1][0], c[1][1]+1))
else:
c.append((c[0][0], c[0][1]-1))
c.append((c[1][0], c[1][1]-1))
else:
c.append((c[0][0], c[1][1]))
c.append((c[1][0], c[0][1]))
for i in range(n):
for j in range(n):
if (i,j) in c:
print('*', end='')
else:
print('.', end='')
print('\n', end='')
``` | output | 1 | 87,839 | 23 | 175,679 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**.. | instruction | 0 | 87,840 | 23 | 175,680 |
Tags: implementation
Correct Solution:
```
def solve():
n = int(input())
#n,m,k = input().split()
#n = int(n)
#m = int(m)
#k = int(k)
idx1=-1
idy1=-1
idx2=-1
idy2=-1
mark = True
for i in range(n):
a = input()
for j in range(n):
if (a[j]=='*'):
if mark :
idx1= j
idy1= i
mark = False
else :
idx2= j
idy2= i
if (idx1==idx2):
if (idx1==0) :
for i in range(n):
for j in range(n):
if j==idx1 and i==idy1 : print('*',end="")
elif j==idx1+1 and i==idy1 : print('*',end="")
elif j==idx2 and i==idy2 : print('*',end="")
elif j==idx2+1 and i==idy2 : print('*',end="")
else : print('.',end="")
print('')
else :
for i in range(n):
for j in range(n):
if j==idx1 and i==idy1 : print('*',end="")
elif j==idx1-1 and i==idy1 : print('*',end="")
elif j==idx2 and i==idy2 : print('*',end="")
elif j==idx2-1 and i==idy2 : print('*',end="")
else : print('.',end="")
print('')
return 0;
if (idy1==idy2):
if (idy1==0) :
for i in range(n):
for j in range(n):
if j==idx1 and i==idy1 : print('*',end="")
elif j==idx1 and i==idy1+1 : print('*',end="")
elif j==idx2 and i==idy2 : print('*',end="")
elif j==idx2 and i==idy2+1 : print('*',end="")
else : print('.',end="")
print('')
else :
for i in range(n):
for j in range(n):
if j==idx1 and i==idy1 : print('*',end="")
elif j==idx1 and i==idy1-1 : print('*',end="")
elif j==idx2 and i==idy2 : print('*',end="")
elif j==idx2 and i==idy2-1 : print('*',end="")
else : print('.',end="")
print('')
return 0
for i in range(n):
for j in range(n):
if j==idx1 and i==idy1 : print('*',end="")
elif j==idx2 and i==idy1 : print('*',end="")
elif j==idx2 and i==idy2 : print('*',end="")
elif j==idx1 and i==idy2 : print('*',end="")
else : print('.',end="")
print('')
return 0
if __name__=="__main__":
T = int(input())
for i in range(T):
(solve())
``` | output | 1 | 87,840 | 23 | 175,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
import sys
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
#########################
# imgur.com/Pkt7iIf.png #
#########################
def sieve(n):
if n < 2: return list()
prime = [True for _ in range(n + 1)]
p = 3
while p * p <= n:
if prime[p]:
for i in range(p * 2, n + 1, p):
prime[i] = False
p += 2
r = [2]
for p in range(3, n + 1, 2):
if prime[p]:
r.append(p)
return r
def divs(n, start=1):
divisors = []
for i in range(start, int(math.sqrt(n) + 1)):
if n % i == 0:
if n / i == i:
divisors.append(i)
else:
divisors.extend([i, n // i])
return divisors
def divn(n, primes):
divs_number = 1
for i in primes:
if n == 1:
return divs_number
t = 1
while n % i == 0:
t += 1
n //= i
divs_number *= t
def flin(d, x, default=-1):
left = right = -1
for i in range(len(d)):
if d[i] == x:
if left == -1: left = i
right = i
if left == -1:
return (default, default)
else:
return (left, right)
def ceil(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a * b) // math.gcd(a, b)
def prr(a, sep=' '): print(sep.join(map(str, a)))
def dd(): return collections.defaultdict(int)
def ddl(): return collections.defaultdict(list)
def minmax(a, b): return (a, b) if a < b else (b, a)
# input = sys.stdin.readline
for _ in range(ii()):
n = ii()
m = []
d = []
for i in range(n):
tmp = []
for j, p in enumerate(input()):
tmp.append(p)
if p == '*':
d.append((i, j))
m.append(tmp)
a, b = d[0], d[1]
if a[0] == b[0]:
m[(a[0] + 1) % n][a[1]] = '*'
m[(b[0] + 1) % n][b[1]] = '*'
elif a[1] == b[1]:
m[a[0]][(a[1] + 1) % n] = '*'
m[b[0]][(b[1] + 1) % n] = '*'
else:
m[b[0]][a[1]] = '*'
m[a[0]][b[1]] = '*'
for i in range(n):
print(*m[i], sep='')
``` | instruction | 0 | 87,841 | 23 | 175,682 |
Yes | output | 1 | 87,841 | 23 | 175,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
tot = int(input())
for x in range(tot):
a = int(input())
# arr = [[] for y in range(a) ]
idar = []
for y in range(a):
b = input()
# arr[y] = list(b)
# print(b)
if len(idar) < 4:
for pp in range(a):
if b[pp]=="*":
idar.append(y)
idar.append(pp)
nid = []
if idar[0]==idar[2]:
if idar[0]==a-1:
nid.append(idar[0]-1)
nid.append(idar[1])
nid.append(idar[2]-1)
nid.append(idar[3])
else:
nid.append(idar[0]+1)
nid.append(idar[1])
nid.append(idar[2]+1)
nid.append(idar[3])
elif idar[1]==idar[3]:
if idar[1]==a-1:
nid.append(idar[0])
nid.append(idar[1]-1)
nid.append(idar[2])
nid.append(idar[3]-1)
else:
nid.append(idar[0])
nid.append(idar[1]+1)
nid.append(idar[2])
nid.append(idar[3]+1)
else:
nid.append(idar[0])
nid.append(idar[3])
nid.append(idar[2])
nid.append(idar[1])
pp = idar[0]
qq = idar[1]
rr = idar[2]
ss = idar[3]
tt = nid[0]
uu = nid[1]
vv = nid[2]
ww = nid[3]
for ff in range(a):
for hh in range(a):
if (pp==ff and qq==hh) or (rr==ff and ss==hh) or (tt==ff and uu==hh) or (vv==ff and ww==hh):
print("*",end="")
else:
print(".",end="")
print()
# print(idar)
``` | instruction | 0 | 87,842 | 23 | 175,684 |
Yes | output | 1 | 87,842 | 23 | 175,685 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
def main():
t = int(input())
for _ in range(t):
n = int(input())
l=[]
for i in range(n):
arr = list(input())
l.append(arr)
ans=[]
for i in range(n):
for j in range(n):
if l[i][j]=="*":
ans.append([i,j])
#print(ans)
if ans[0][0]==ans[1][0]:
if ans[0][0]==0:
#print(6)
l[1][ans[0][1]]="*"
l[1][ans[1][1]]="*"
else:
l[0][ans[0][1]] = "*"
l[0][ans[1][1]] = "*"
elif ans[0][1]==ans[1][1]:
if ans[0][1]==0:
l[ans[0][0]][1]="*"
l[ans[1][0]][1]="*"
else:
l[ans[0][0]][0] = "*"
l[ans[1][0]][0] = "*"
else:
l[ans[0][0]][ans[1][1]]="*"
l[ans[1][0]][ans[0][1]]="*"
#print(l)
for i in range(n):
for j in range(n):
print(l[i][j],end="")
print()
if __name__ == '__main__':
main()
``` | instruction | 0 | 87,843 | 23 | 175,686 |
Yes | output | 1 | 87,843 | 23 | 175,687 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush,heappop,heapify
from itertools import permutations,combinations
from itertools import accumulate as ac
mod = int(1e9)+7
mod = 998244353
ip = lambda : int(stdin.readline())
inp = lambda: map(int,stdin.readline().split())
ips = lambda: stdin.readline().rstrip()
out = lambda x : stdout.write(str(x)+"\n")
t = ip()
for _ in range(t):
n = ip()
arr = []
for i in range(n):
s = ips()
arr.append(list(s))
ct = [[0]*n for i in range(n)]
ind = []
for i in range(n):
for j in range(n):
if arr[i][j] == '*':
ind.append([i,j])
val1 = ind[0]
val2 = ind[1]
if val1[0] == val2[0]:
if val1[0] == 0:
arr[1][val1[1]] = '*'
arr[1][val2[1]] = '*'
else:
arr[0][val1[1]] = '*'
arr[0][val2[1]] = '*'
elif val1[1] == val2[1]:
if val1[1] == 0:
arr[val1[0]][1] = '*'
arr[val2[0]][1] = '*'
else:
arr[val1[0]][0] = '*'
arr[val2[0]][0] = '*'
else:
for i in ind:
x = i[0]
y = i[1]
for i in range(n):
if y != i:
ct[x][i] += 1
if x != i:
ct[i][y] += 1
ct[x][y] += 1
ans = []
for i in range(n):
for j in range(n):
if ct[i][j] == 2:
ans.append([i,j])
for i in ans:
arr[i[0]][i[1]] = '*'
for i in arr:
print(''.join(i))
``` | instruction | 0 | 87,844 | 23 | 175,688 |
Yes | output | 1 | 87,844 | 23 | 175,689 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
import sys
input=sys.stdin.readline
def I():return input().strip()
def II():return int(input().strip())
def LI():return [*map(int,input().strip().split())]
import string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from bisect import bisect_left,bisect_right
from collections import deque,defaultdict,Counter,OrderedDict
from itertools import permutations,combinations,groupby
for _ in range(II()):
n=II()
s=list()
for i in range(n):
inp=I()
for j in range(n):
if inp[j]=='*':
s.append((i,j))
if s[0][0]==s[1][0]:
s.append(((s[0][0]+1)%n,s[0][1]))
s.append(((s[1][0]+1)%n,s[1][1]))
elif s[0][1]==s[1][1]:
s.append((s[0][0],(s[0][1]+1)%n))
s.append((s[1][0],(s[1][1]+1)%n))
else:
s.append((s[0][0],s[1][1]))
s.append((s[1][0],s[0][1]))
for i in range(n):
for j in range(n):
if (i,j) in s:
print('*',end='')
else:
print('.',end='')
print(' ')
``` | instruction | 0 | 87,845 | 23 | 175,690 |
No | output | 1 | 87,845 | 23 | 175,691 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
pl=[]
f=0
for i in range(n):
s=input()
for j in range(n):
if f==2:
break
elif s[j]=='*':
pl.append((i,j))
f+=1
if pl[0][0]!=pl[1][0] and pl[0][1]!=pl[1][1]:
pl.extend([(pl[0][0],pl[1][1]),(pl[1][0],pl[0][1])])
elif pl[0][0]==pl[1][0] and pl[0][0]==0:
pl.extend([(pl[0][0]+1,pl[0][1]),(pl[1][0]+1,pl[1][1])])
elif pl[0][0]==pl[1][0] and pl[0][0]!=0:
pl.extend([(pl[0][0]-1,pl[0][1]),(pl[1][0]-1,pl[1][1])])
elif pl[0][1]==pl[1][1] and pl[0][1]==0:
pl.extend([(pl[0][0],pl[0][1]+1),(pl[1][0],pl[1][1]+1)])
else:
pl.extend([(pl[0][0],pl[0][1]-1),(pl[1][0],pl[1][1]-1)])
for i in range(n):
for j in range(n):
if (i==pl[0][0] and j==pl[0][1]) or (i==pl[1][0] and j==pl[1][1]) or (i==pl[2][0] and j==pl[2][1]) or (i==pl[3][0] and j==pl[3][1]):
print('*',end=' ')
else:
print('.',end=' ')
print()
``` | instruction | 0 | 87,846 | 23 | 175,692 |
No | output | 1 | 87,846 | 23 | 175,693 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
"""
Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
"""
if __name__ == "__main__":
# Write your solution here
pass
``` | instruction | 0 | 87,847 | 23 | 175,694 |
No | output | 1 | 87,847 | 23 | 175,695 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column.
You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.
For example, if n=4 and a rectangular field looks like this (there are asterisks in the marked cells):
$$$ \begin{matrix} . & . & * & . \\\ . & . & . & . \\\ * & . & . & . \\\ . & . & . & . \\\ \end{matrix} $$$
Then you can mark two more cells as follows
$$$ \begin{matrix} * & . & * & . \\\ . & . & . & . \\\ * & . & * & . \\\ . & . & . & . \\\ \end{matrix} $$$
If there are several possible solutions, then print any of them.
Input
The first line contains a single integer t (1 ≤ t ≤ 400). Then t test cases follow.
The first row of each test case contains a single integer n (2 ≤ n ≤ 400) — the number of rows and columns in the table.
The following n lines each contain n characters '.' or '*' denoting empty and marked cells, respectively.
It is guaranteed that the sums of n for all test cases do not exceed 400.
It is guaranteed that there are exactly two asterisks on the field. They can be in the same row/column.
It is guaranteed that the solution exists.
Output
For each test case, output n rows of n characters — a field with four asterisks marked corresponding to the statements. If there multiple correct answers, print any of them.
Example
Input
6
4
..*.
....
*...
....
2
*.
.*
2
.*
.*
3
*.*
...
...
5
.....
..*..
.....
.*...
.....
4
....
....
*...
*...
Output
*.*.
....
*.*.
....
**
**
**
**
*.*
*.*
...
.....
.**..
.....
.**..
.....
....
....
**..
**..
Submitted Solution:
```
for _ in range(int(input())):
n=int(input())
l=[]
for i in range(n):
l.append(list(input()))
x=[]
for j in range(n):
for k in range(n):
if l[j][k]=='*':
x.append([j,k])
if x[0][0]==x[1][0]:
if x[0][0]==0:
l[1][x[0][1]]='*'
l[1][x[1][1]]='*'
elif x[0][0]==n-1:
l[n-2][x[0][1]]='*'
l[n-2][x[1][1]]='*'
else:
l[x[0][0]+1][x[0][1]]='*'
l[x[0][0]][x[1][1]]='*'
elif x[0][1]==x[1][1]:
if x[0][1]==0:
l[x[0][0]][1]='*'
l[x[1][0]][1]='*'
elif x[0][1]==n-1:
l[x[0][0]][n-2]='*'
l[x[1][0]][n-2]='*'
else:
l[x[0][0]][x[0][1]+1]='*'
l[x[1][0]][x[0][1]+1]='*'
else:
# if x[0][1]==0:
# l[x[0][0]][1]='*'
# l[x[0][0]][1]='*'
# elif x[0][1]==n-1:
# l[x[0][0][n-2]='*'
# l[x[0][0]][n-2]='*'
# else:
l[x[0][0]][x[1][1]]='*'
l[x[1][0]][x[0][1]]='*'
for ss in range(n):
for sss in range(n):
print(l[ss][sss],end='')
print()
``` | instruction | 0 | 87,848 | 23 | 175,696 |
No | output | 1 | 87,848 | 23 | 175,697 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,193 | 23 | 176,386 |
"Correct Solution:
```
A = list(map(int, input().split()))
print((A[0]*A[1])//2)
``` | output | 1 | 88,193 | 23 | 176,387 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,194 | 23 | 176,388 |
"Correct Solution:
```
h, w, n = map(int, input().split())
print(int(h*w/2))
``` | output | 1 | 88,194 | 23 | 176,389 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,195 | 23 | 176,390 |
"Correct Solution:
```
n, h, m = map(int, input().split(' '))
print(int(n*h/2))
``` | output | 1 | 88,195 | 23 | 176,391 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,196 | 23 | 176,392 |
"Correct Solution:
```
a=sorted(map(int,input().split()))
print(a[0]*a[1]//2)
``` | output | 1 | 88,196 | 23 | 176,393 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,197 | 23 | 176,394 |
"Correct Solution:
```
l =[int(i) for i in input().split()]
print(l[0]*l[1]//2)
``` | output | 1 | 88,197 | 23 | 176,395 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,198 | 23 | 176,396 |
"Correct Solution:
```
a,b,_=map(int,input().split());print(a*b//2)
``` | output | 1 | 88,198 | 23 | 176,397 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,199 | 23 | 176,398 |
"Correct Solution:
```
a, b, c = map(int, input().split())
s = a*b//2
print(s)
``` | output | 1 | 88,199 | 23 | 176,399 |
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630 | instruction | 0 | 88,200 | 23 | 176,400 |
"Correct Solution:
```
#116a
a,b,c=map(int,input().split())
print(a*b//2)
``` | output | 1 | 88,200 | 23 | 176,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
x,y,z = map(int,input().split())
print(int(x*y/2))
``` | instruction | 0 | 88,201 | 23 | 176,402 |
Yes | output | 1 | 88,201 | 23 | 176,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a, b, c = map(int, input().split())
print((int)(a*b/2))
``` | instruction | 0 | 88,202 | 23 | 176,404 |
Yes | output | 1 | 88,202 | 23 | 176,405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
c,a,b = map(int,input().split())
print(int(1/2 * c * a))
``` | instruction | 0 | 88,203 | 23 | 176,406 |
Yes | output | 1 | 88,203 | 23 | 176,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
A,B,C=map(int,input().split())
print(int(A*B/2))
``` | instruction | 0 | 88,204 | 23 | 176,408 |
Yes | output | 1 | 88,204 | 23 | 176,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a,b,c=map(int,input().split())
print(str(int(0.5*(a+c))))
``` | instruction | 0 | 88,205 | 23 | 176,410 |
No | output | 1 | 88,205 | 23 | 176,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
A = int(input())
p = A
C = []
while A not in C:
C.append(A)
if A % 2 == 0:
A = A//2
else:
A = A*3+1
print(len(C)+1)
``` | instruction | 0 | 88,206 | 23 | 176,412 |
No | output | 1 | 88,206 | 23 | 176,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a,b,c=list(input().split())
AB=int(a)
BC=int(b)
ptint(int(AB*BC/2))
``` | instruction | 0 | 88,207 | 23 | 176,414 |
No | output | 1 | 88,207 | 23 | 176,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a, b, c = map(int, input().split(' '))
print(a*b/2)
``` | instruction | 0 | 88,208 | 23 | 176,416 |
No | output | 1 | 88,208 | 23 | 176,417 |
Provide a correct Python 3 solution for this coding contest problem.
Problem
Find the area of a regular N / K polygon inscribed in a circle with a radius of 1.
However, a regular N / K polygon is defined as "the outermost figure that takes N points on the circumference at equal intervals and connects each point every K-1".
For example, a 5/2 polygon can be drawn as follows. First, take five points at equal intervals on the circumference of radius 1.
Sample Input 2 diagram
Next, connect each point every other 2-1 = 1.
Sample Input 2 diagram
The outermost figure is a regular 5/2 square.
Sample Input 2 diagram
Constraints
The input satisfies the following constraints.
* 5 ≤ N ≤ 106
* 1 <K <N / 2
* N and K are integers that are relatively prime
Input
The input is given in the following format.
N K
Two integers N and K are given on one line.
Output
Output the area of a regular N / K polygon inscribed in a circle with a radius of 1 on one line. An error of 10-5 or less is acceptable.
Examples
Input
5 2
Output
1.12256994
Input
20 3
Output
2.93114293
Input
7 3
Output
1.08395920
Input
100000 3
Output
3.14159265 | instruction | 0 | 88,307 | 23 | 176,614 |
"Correct Solution:
```
# AOJ 1593: Star
# Python3 2018.7.13 bal4u
import math
PI = 3.1415926535897932384626433832795
# area = n*r^2*sin(180/n)*cos(180k/n)*sec(180(k-1)/n), for n/k star
N, K = map(int, input().split())
print(N*math.sin(PI/N)*math.cos(K*PI/N)/math.cos((K-1)*PI/N))
``` | output | 1 | 88,307 | 23 | 176,615 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.