message stringlengths 2 28.7k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 21 109k | cluster float64 7 7 | __index_level_0__ int64 42 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,401 | 7 | 28,802 |
Tags: implementation
Correct Solution:
```
n , m = map(int , input().split())
l=[]
lhs = m
rhs=0
t=0
for i in range(n):
temp = str(input())
if t==1 or temp.count('.')!=len(temp):
t=1
l.append(temp)
if '*' in temp:
lhs = min(lhs , temp.index('*'))
rhs = max(rhs , temp.rfind('*'))
t=0
x = l[::-1]
i=0
while t==0:
if x[i] == m*'.':
x.remove(x[i])
i=i-1
else:
t=1
i = i+1
ans = x[::-1]
for i in ans:
print(i[lhs:rhs+1])
``` | output | 1 | 14,401 | 7 | 28,803 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,402 | 7 | 28,804 |
Tags: implementation
Correct Solution:
```
import sys
def main():
inp = sys.stdin.read().strip().split('\n')
m, n = map(int, inp[0].split())
s = inp[1:]
x, y = set(), set()
for i in range(m):
for j in range(n):
if s[i][j] == '*':
x.add(i); y.add(j)
out = []
for i in range(min(x), max(x)+1):
out.append(s[i][min(y):max(y)+1])
return out
print(*main(), sep='\n')
``` | output | 1 | 14,402 | 7 | 28,805 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,403 | 7 | 28,806 |
Tags: implementation
Correct Solution:
```
s=input().split()
a=int(s[0])
b=int(s[1])
lis=[]
ans=[]
col=[]
for i in range(a):
k=input()
lis.append(k)
if(lis[i].find("*")!=-1):
col.append(i)
ans.append(lis[i].find("*"))
if(lis[i].rfind("*")!=-1):
ans.append(lis[i].rfind("*"))
ans.sort()
for i in range(col[0],col[len(col)-1]+1):
print(lis[i][ans[0]:ans[len(ans)-1]+1])
``` | output | 1 | 14,403 | 7 | 28,807 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,404 | 7 | 28,808 |
Tags: implementation
Correct Solution:
```
n,m=[int(s) for s in input().split()]
a=[]
up=-1
down=n
left=m
right=-1
for i in range(n):
s=input()
a.append(s)
if s.find('*')!=-1:
if up==-1: up=i
down=i
p=s.find('*')
if p<left:
left=p
p=s.rfind('*')
if p>right:
right=p
for i in range(up,down+1):
print(a[i][left:right+1])
``` | output | 1 | 14,404 | 7 | 28,809 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,405 | 7 | 28,810 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
A = [input() for _ in range(n)]
min_x, max_x = n, 0
min_y, max_y = m, 0
for i in range(n):
for j in range(m):
if A[i][j] == '*':
min_x, max_x = min(min_x, i), max(max_x, i)
min_y, max_y = min(min_y, j), max(max_y, j)
for x in range(min_x, max_x+1):
print(A[x][min_y:max_y+1])
``` | output | 1 | 14,405 | 7 | 28,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,406 | 7 | 28,812 |
Tags: implementation
Correct Solution:
```
X = list(map(int, input().split()))
Picture, FirstRow, LastRow, First, Last = [], X[0], 0, X[1], 0
for i in range(X[0]):
Temp = input()
Picture.append(Temp)
if "*" in Temp:
FirstRow = min(FirstRow, i)
LastRow = i
First = min(First, Temp.index("*"))
Last = max(Last, X[1] - Temp[::-1].index("*"))
for i in range(FirstRow, LastRow + 1):
print(Picture[i][First:Last])
# UB_CodeForces
# Advice: Falling down is an accident, staying down is a choice
# Location: Here in Bojnurd
# Caption: So Close man!! Take it easy!!!!
# CodeNumber: 646
``` | output | 1 | 14,406 | 7 | 28,813 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,407 | 7 | 28,814 |
Tags: implementation
Correct Solution:
```
T_ON = 0
DEBUG_ON = 1
MOD = 998244353
def solve():
n, m = read_ints()
M = []
for r in range(n):
M.append(input())
r1 = n
r2 = 0
c1 = m
c2 = 0
for r in range(n):
for c in range(m):
if M[r][c] == '*':
r1 = min(r1, r)
r2 = max(r2, r)
c1 = min(c1, c)
c2 = max(c2, c)
for r in range(r1, r2 + 1):
print(M[r][c1:c2+1])
def main():
T = read_int() if T_ON else 1
for i in range(T):
solve()
def debug(*xargs):
if DEBUG_ON:
print(*xargs)
from collections import *
import math
#---------------------------------FAST_IO---------------------------------------
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#----------------------------------IO_WRAP--------------------------------------
def read_int():
return int(input())
def read_ints():
return list(map(int, input().split()))
def print_nums(nums):
print(" ".join(map(str, nums)))
def YES():
print("YES")
def Yes():
print("Yes")
def NO():
print("NO")
def No():
print("No")
def First():
print("First")
def Second():
print("Second")
#----------------------------------FIB--------------------------------------
def fib(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
def fib_ns(n):
assert n >= 1
f = [0 for _ in range(n + 1)]
f[0] = 0
f[1] = 1
for i in range(2, n + 1):
f[i] = f[i - 1] + f[i - 2]
return f
#----------------------------------MOD--------------------------------------
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def xgcd(a, b):
"""return (g, x, y) such that a*x + b*y = g = gcd(a, b)"""
x0, x1, y0, y1 = 0, 1, 1, 0
while a != 0:
(q, a), b = divmod(b, a), a
y0, y1 = y1, y0 - q * y1
x0, x1 = x1, x0 - q * x1
return b, x0, y0
def lcm(a, b):
d = gcd(a, b)
return a * b // d
def is_even(x):
return x % 2 == 0
def is_odd(x):
return x % 2 == 1
def modinv(a, m):
"""return x such that (a * x) % m == 1"""
g, x, _ = xgcd(a, m)
if g != 1:
raise Exception('gcd(a, m) != 1')
return x % m
def mod_add(x, y):
x += y
while x >= MOD:
x -= MOD
while x < 0:
x += MOD
return x
def mod_mul(x, y):
return (x * y) % MOD
def mod_pow(x, y):
if y == 0:
return 1
if y % 2:
return mod_mul(x, mod_pow(x, y - 1))
p = mod_pow(x, y // 2)
return mod_mul(p, p)
def mod_inv(y):
return mod_pow(y, MOD - 2)
def mod_div(x, y):
# y^(-1): Fermat little theorem, MOD is a prime
return mod_mul(x, mod_inv(y))
#---------------------------------PRIME---------------------------------------
def is_prime(n):
if n == 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i:
return False
return True
def gen_primes(n):
"""
generate primes of [1..n] using sieve's method
"""
P = [True for _ in range(n + 1)]
P[0] = P[1] = False
for i in range(int(n ** 0.5) + 1):
if P[i]:
for j in range(2 * i, n + 1, i):
P[j] = False
return P
#---------------------------------MAIN---------------------------------------
main()
``` | output | 1 | 14,407 | 7 | 28,815 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
*** | instruction | 0 | 14,408 | 7 | 28,816 |
Tags: implementation
Correct Solution:
```
n, m = map(int, input().split())
b = []
for i in range(n):
b.append(input())
x = []
for c in zip(*b):
for r in range(n):
if c[r] == '*':
x.append(r)
y = []
for r in b:
for c in range(m):
if r[c] == '*':
y.append(c)
for r in b[min(x) : max(x) + 1]:
print(''.join(r[min(y) : max(y) + 1]))
``` | output | 1 | 14,408 | 7 | 28,817 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it with his elder brother, who lives in Flatland. Now Bob has to send his picture by post, but because of the world economic crisis and high oil prices, he wants to send his creation, but to spend as little money as possible. For each sent square of paper (no matter whether it is shaded or not) Bob has to pay 3.14 burles. Please, help Bob cut out of his masterpiece a rectangle of the minimum cost, that will contain all the shaded squares. The rectangle's sides should be parallel to the sheet's sides.
Input
The first line of the input data contains numbers n and m (1 ≤ n, m ≤ 50), n — amount of lines, and m — amount of columns on Bob's sheet. The following n lines contain m characters each. Character «.» stands for a non-shaded square on the sheet, and «*» — for a shaded square. It is guaranteed that Bob has shaded at least one square.
Output
Output the required rectangle of the minimum cost. Study the output data in the sample tests to understand the output format better.
Examples
Input
6 7
.......
..***..
..*....
..***..
..*....
..***..
Output
***
*..
***
*..
***
Input
3 3
***
*.*
***
Output
***
*.*
***
Submitted Solution:
```
n, m = map(int, input().split())
arr = []
patt = []
for i in range(n):
k = input()
arr.append(k)
check = []
for i in arr:
a = [(x, y) for x, y in enumerate(i) if y == '*']
if len(a) > 0:
check.append(a)
z = 0
for i in range(n):
if arr[i].count('*')!=0:
z = i
break
for i in range(z,n):
patt.append(arr[i])
patt = patt[::-1]
for i in patt:
if i.count('*')!=0:
z = patt.index(i)
break
patt = patt[z:]
patt = patt[::-1]
mini = min(check)[0][0]
maxi = max(check)[-1][0]
arr = []
for i in patt:
arr.append(i[mini:maxi+1])
print('\n'.join(arr))
``` | instruction | 0 | 14,414 | 7 | 28,828 |
No | output | 1 | 14,414 | 7 | 28,829 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,486 | 7 | 28,972 |
Tags: combinatorics, number theory
Correct Solution:
```
from sys import stdin, stdout
def main():
n, p = 2000, 1000000007
factorial = [1] * (n + 1)
for i in range(2, n + 1):
factorial[i] = i * factorial[i - 1] % p
n, m = readline()
on = sorted(readline())
off = []
for i in range(1, m):
c = on[i] - on[i - 1] - 1
if c > 0:
off.append(c)
answer = pow(2, sum(off) - len(off), p) * factorial[n - m] % p
off = [on[0] - 1] + off + [n - on[m - 1]]
for x in off:
answer = answer * pow(factorial[x], p - 2, p) % p
return answer
def readline():
return map(int, stdin.readline().strip().split())
if __name__ == '__main__':
stdout.write(str(main()) + '\n')
``` | output | 1 | 14,486 | 7 | 28,973 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,487 | 7 | 28,974 |
Tags: combinatorics, number theory
Correct Solution:
```
import math
def myfunc(value):
if value == 0:
return 1
total = 1
for num in range(2, value+1):
total = total * num
return total
n, m = map(int, input().split())
mylist = sorted(list(map(int, input().split())))
value = myfunc(n-m)
temp = myfunc(mylist[0]-1)
total = value // temp
for i in range(1,m):
values = mylist[i]-mylist[i-1]
temp = myfunc(values-1)
total = total // temp
if mylist[i]- mylist[i-1] != 1:
values = mylist[i]-mylist[i-1]
temp = (values-2)
total = total * 2 ** temp
temp = myfunc(n-mylist[m-1])
total = total // temp
print(total % 1000000007 )
``` | output | 1 | 14,487 | 7 | 28,975 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,488 | 7 | 28,976 |
Tags: combinatorics, number theory
Correct Solution:
```
def f(p):
d = 1
for i in range(2, p + 1):
d *= i
return d
n, m = map(int, input().split())
l = list(map(int, input().split()))
if n == m:
print(1)
else:
l.sort()
for i in range(m):
l[i] -= 1
k = []
sm = n - m
if l[0] > 1:
k.append([l[0], 1])
for i in range(1, len(l)):
k.append([l[i] - l[i - 1] - 1, 2 ** (max(0, l[i] - l[i - 1] - 2))])
if l[-1] < n - 1:
k.append([n - 1 - l[-1], 1])
ans = f(sm)
for c in k:
ans //= f(c[0])
for c in k:
ans *= c[1]
print(ans % 1000000007)
``` | output | 1 | 14,488 | 7 | 28,977 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,489 | 7 | 28,978 |
Tags: combinatorics, number theory
Correct Solution:
```
#source: https://www.programmersought.com/article/2581544332/
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
twodList = [[0 for _ in range(1005)] for _ in range(1005)]
powTee = [0 for _ in range(1005)]
powTee[0] = 1
twodList[0][0] = 1
for i in range(1, 1005):
twodList[i][0] = 1
for j in range(1, i + 1):
twodList[i][j] = (twodList[i - 1][j] + twodList[i - 1][j - 1]) % 1000000007
twodList[i][i] = 1
powTee[i] = (powTee[i - 1] * 2) % 1000000007
n, m = get_ints()
inputListy = get_list()
inputListy.sort()
numby = n - m
roubles = twodList[numby][inputListy[0] - 1]
numby -= inputListy[0] - 1
for i in range(1, m):
x = inputListy[i] - inputListy[i - 1] - 1
if x > 0:
roubles = ((roubles * twodList[numby][x] % 1000000007) * powTee[x - 1])
else:
roubles = roubles * twodList[numby][x] % 1000000007
numby -= x
roubles = (roubles * twodList[numby][n - inputListy[m - 1]]) % 1000000007
print(roubles)
``` | output | 1 | 14,489 | 7 | 28,979 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,490 | 7 | 28,980 |
Tags: combinatorics, number theory
Correct Solution:
```
MOD = int(1e9+7)
n, m = map(int, input().split())
arr = sorted(list(map(int, input().split())))
fact = [1]
for i in range(1, 1000):
fact.append((fact[-1] * i) % MOD)
def fast_power(b, e):
res = 1
while e > 0:
if e % 2 == 1:
res = res * b % MOD
b = b * b % MOD
e //= 2
return res
def inv_mod(b):
return fast_power(b, MOD - 2)
res = fact[n - m]
for i in range(1, m):
mid = arr[i] - arr[i - 1] - 1
if mid > 0:
res = res * inv_mod(fact[mid]) % MOD
if mid > 1:
res = res * fast_power(2, mid-1) % MOD
if arr[0] > 1:
res = res * inv_mod(fact[arr[0] - 1]) % MOD
if arr[m - 1] < n:
res = res * inv_mod(fact[n - arr[m-1]]) % MOD
print(res)
``` | output | 1 | 14,490 | 7 | 28,981 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,491 | 7 | 28,982 |
Tags: combinatorics, number theory
Correct Solution:
```
def fac(n):
if n == 0:
return 1
mul = 1
for i in range(2,n+1):
mul *= i
return mul
n,m = (int(t) for t in input().split(' '))
gen = (int(t) for t in input().split(' '))
v = []
for i in gen:
v.append(i)
v.sort()
ans = fac(n-m)
#print(type(ans))
ans //= fac(v[0]-1)
for i in range(1,len(v)):
# print('#')
ans //= fac(v[i]-v[i-1]-1)
if v[i]-v[i-1]-1 != 0:
ans *= 2**(v[i]-v[i-1]-2)
ans //= fac(n-v[len(v)-1])
print('%d' % (ans%(int(1e9)+7)))
``` | output | 1 | 14,491 | 7 | 28,983 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,492 | 7 | 28,984 |
Tags: combinatorics, number theory
Correct Solution:
```
def bpow(a, b):
if b==0 or a==1:
return 1
if b%2 != 0:
return a * bpow(a, b-1) % mod
else:
c = bpow(a, b/2) % mod
return c * c % mod
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a + [n+1]
a = sorted(a)
fa = list()
fa.append(1)
mod = 1000000007
for i in range(1, 2010):
fa.append(fa[i-1] * i)
fa[i] %= mod
ans1 = 1
ans2 = 1
s = 0
for i in range(0, m+1):
ans1 *= fa[a[i+1] - a[i] - 1]
s+= a[i+1] - a[i] - 1
ans1 %= mod
if i > 0 and i < m and a[i+1] - a[i] > 1:
ans2*= pow(2, a[i+1] - a[i] - 2, mod)
ans2%= mod
print((fa[s] * pow(ans1, mod-2, mod) * ans2)%mod)
``` | output | 1 | 14,492 | 7 | 28,985 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720 | instruction | 0 | 14,493 | 7 | 28,986 |
Tags: combinatorics, number theory
Correct Solution:
```
from sys import stdin, stdout
def main():
p = 1000000007 # Constante brindada por el problema
n, m = readline()
on = sorted(readline()) # Se ordena de menor a mayor los elementos del conjunto de luces encendidas
off = [] # Conjunto de cardinalidades de los segmentos de luces apagadas
sum_ = 0
for i in range(1, m): # Se analizan todos los segmentos interiores
c = on[i] - on[i - 1] - 1
if c > 0:
off.append(c)
sum_ += c
factorial = [1] * (on[0] + sum_ + n - on[-1])
for i in range(2, len(factorial)): # Factoriales modulo p hasta la cantidad de luces apagadas
factorial[i] = i * factorial[i - 1] % p
answer = pow(2, sum_ - len(off), p) * factorial[n - m] % p # Se calcula el numerador de la expresion
off.append(on[0] - 1) # Se agregan los segmentos exteriores
off.append(n - on[-1])
for x in off: # Se agrega al calculo los elementos del denominador
answer = answer * pow(factorial[x], p - 2, p) % p # Se utiliza el inverso multiplicativo
return answer
def readline(): # Metodo para leer una linea completa, dividirla en elementos y convertirlos en numeros enteros
return map(int, stdin.readline().strip().split())
if __name__ == '__main__':
stdout.write(str(main()) + '\n')
``` | output | 1 | 14,493 | 7 | 28,987 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
l1=[]
l1.append(l[0]-1)
for i in range(m-1):
l1.append(l[i+1]-l[i]-1)
f1=[1]*1001
f2=[1]*1001
mod=10**9+7
a=1
b=1
for i in range(1,1001):
a*=i
a%=mod
f1[i]=a
b*=pow(i,mod-2,mod)
b%=mod
f2[i]=b
ans=1
n-=m
ans*=f1[n]*f2[l1[0]]*f2[n-l1[0]]
ans%=mod
n-=l1[0]
for i in range(1,len(l1)):
if l1[i]>0:
ans*=f1[n]*f2[l1[i]]*f2[n-l1[i]]*pow(2,l1[i]-1,mod)
ans%=mod
n-=l1[i]
print(ans)
``` | instruction | 0 | 14,494 | 7 | 28,988 |
Yes | output | 1 | 14,494 | 7 | 28,989 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
mod = 1000000007
fact = [1] * 2000
for i in range(1, 2000):
fact[i] = fact[i - 1] * i % mod
n, m = map(int, input().split())
a = sorted(map(int, input().split()))
b = []
for i in range (1, m):
x = a[i] - a[i - 1] - 1
if (x > 0):
b.append(x)
count = pow(2, sum(b) - len(b), mod) * fact[n - m] % mod
b = [a[0] - 1] + b + [n - a[-1]]
for i in b:
count = count * pow(fact[i], mod - 2, mod) % mod
print(count)
``` | instruction | 0 | 14,495 | 7 | 28,990 |
Yes | output | 1 | 14,495 | 7 | 28,991 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
mod=10**9+7
n,m=[int(x) for x in input().split()]
light=[False for x in range(n+1)]
marr=[int(x) for x in input().split()]
for i in range(m):
light[marr[i]]=True
counta=0;countb=0
for i in range(1,n+1):
if light[i]==False:
counta+=1
else:
break
for i in reversed(range(1,n+1)):
if light[i]==False:
countb+=1
else:
break
else:
countb=0
arr=[]
start=False;count=0
for i in range(1,n+1):
if start==False:
if light[i]==True:
start=True
else:
if light[i]==False:
count+=1
else:
if count>0:arr.append(count);count=0;#start=False
#else:start=False
fact=[None for x in range(n+1)];fact[0]=1
for i in range(1,n+1):
fact[i]=i*fact[i-1]
ans=fact[n-m]//(fact[counta]*fact[countb])
ans=int(ans)
for item in arr:
ans=ans//fact[item]
for item in arr:
ans=(ans*pow(2,item-1,mod))%mod
print(ans%mod)
``` | instruction | 0 | 14,496 | 7 | 28,992 |
Yes | output | 1 | 14,496 | 7 | 28,993 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
import itertools
import math
def countEndgames(grid):
ls = []
for elt, gp in itertools.groupby(grid):
if elt == '.':
ls.append(len(list(gp)))
tot = 1
for i,g in enumerate(ls):
if i==0 and grid[0] == '.' or i==(len(ls)-1) and grid[-1] == '.':
continue
tot *= 2**(g-1)
tot *= math.factorial(sum(ls))
for g in ls:
tot //= math.factorial(g)
return tot % (10**9+7)
n,x = map(int, input().split())
ls = list(map(int, input().split()))
grid = ['.' for i in range(n)]
for x in ls:
grid[x-1] = '#'
print(countEndgames(grid))
``` | instruction | 0 | 14,497 | 7 | 28,994 |
Yes | output | 1 | 14,497 | 7 | 28,995 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
def f(p):
d = 1
for i in range(2, p + 1):
d *= i
return d
n, m = map(int, input().split())
l = list(map(int, input().split()))
if n == m:
print(1)
else:
l.sort()
for i in range(m):
l[i] -= 1
k = []
sm = n - m
if l[0] > 1:
k.append([l[0], 1])
for i in range(1, len(l)):
k.append([l[i] - l[i - 1] - 1, 2 ** (l[i] - l[i - 1] - 2)])
if l[-1] < n - 1:
k.append([n - 1 - l[-1], 1])
ans = f(sm)
for c in k:
ans //= f(c[0])
for c in k:
ans *= c[1]
print(ans % 1000000007)
``` | instruction | 0 | 14,498 | 7 | 28,996 |
No | output | 1 | 14,498 | 7 | 28,997 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
def bpow(a, b):
if b==0 or a==1:
return 1
if b%2 != 0:
return a * bpow(a, b-1) % mod
else:
c = bpow(a, b/2) % mod
return c * c % mod
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a + [n+1]
fa = list()
fa.append(1)
mod = 1000000007
for i in range(1, 1001):
fa.append(fa[i-1] * i)
fa[i] %= mod
ans1 = 1
ans2 = 1
s = 0
for i in range(0, m+1):
ans1 *= fa[a[i+1] - a[i] - 1]
s+= a[i+1] - a[i] - 1
ans1 %= mod
if i > 0 and i < m and a[i+1] - a[i] > 1:
ans2*= pow(2, a[i+1] - a[i] - 2, mod)
ans2%= mod
print((fa[s] * pow(ans1, mod-2, mod) * ans2)%mod)
``` | instruction | 0 | 14,499 | 7 | 28,998 |
No | output | 1 | 14,499 | 7 | 28,999 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
import math
def solve( n, list1):
list1.sort()
inf = int(1e9 + 7)
t1 = [list1[0] - 1, n - list1[-1]]
t2 = []
for i in range(1, len(list1)):
t2.append((list1[i] - list1[i - 1] - 1))
num1 = 1
for i in range(n - len(list1)):
num1 = num1 * (i + 1)
num1 = num1 % inf
num2 = 1
num2 = math.factorial(t1[0]) % inf
num2 = num2 % inf
num2 = num2 * math.factorial(t1[1]) % inf
num2 = num2 % inf
for i in range(len(t2)):
num2 = num2 * math.factorial(t2[i])
num2 = num2 % inf
num2 = pow(num2, inf - 2, inf)
num3 = 1
for i in range(len(t2)):
num3 = (num3 * pow(2, t2[i] - 1, inf)) % inf
num1 = num1 * num2
num1 = num1 % inf
num1 = num1 * num3
num1 = num1 % inf
return int(num1)
n,m = map(int,input().split())
list1 = list(map(int,input().split()))
print(solve(n,list1))
``` | instruction | 0 | 14,500 | 7 | 29,000 |
No | output | 1 | 14,500 | 7 | 29,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
Input
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
Output
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
Examples
Input
3 1
1
Output
1
Input
4 2
1 4
Output
2
Input
11 2
4 8
Output
6720
Submitted Solution:
```
pri=pow(10,9)+7
p=pri
fac=[1 for i in range((10**6)+1)]
for i in range(2,len(fac)):
fac[i]=(fac[i-1]*(i%pri))%pri
def modi(x):
return (pow(x,p-2,p))%p;
def ncr(n,r):
x=(fac[n]*((modi(fac[r])%p)*(modi(fac[n-r])%p))%p)%p
return x;
n,m=map(int,input().split())
z=list(map(int,input().split()))
ans=[]
for i in range(len(z)):
if(i==0):
ans.append(z[0]-1)
else:
ans.append(z[i]-z[i-1]-1)
ans.append(n-z[-1])
temp=[]
for i in range(len(ans)):
if(i==0 or i==len(ans)-1):
temp.append(1)
else:
temp.append(pow(2,max(0,ans[i]-1),pri))
seats=n-m
count=1
for i in range(len(ans)):
count=count*ncr(seats,ans[i])
seats-=ans[i]
count%=pri
for i in range(len(temp)):
count=count*temp[i]
count%=pri
print(count)
``` | instruction | 0 | 14,501 | 7 | 29,002 |
No | output | 1 | 14,501 | 7 | 29,003 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,544 | 7 | 29,088 |
Tags: greedy, implementation
Correct Solution:
```
n=int(input())
board=[""]*n
c=0
for i in range(n):
board[i]=list(input())
for i in range(1,n-1):
for j in range(1,n-1):
if(board[i][j]=='#' and board[i-1][j]=='#' and board[i+1][j]=='#' and board[i][j-1]=='#' and board[i][j+1]=='#'):
board[i][j]='.'
board[i-1][j]='.'
board[i+1][j]='.'
board[i][j-1]='.'
board[i][j+1]='.'
c= sum(board[i].count('#') for i in range(n))
print ('YES') if c==0 else print('NO')
``` | output | 1 | 14,544 | 7 | 29,089 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,545 | 7 | 29,090 |
Tags: greedy, implementation
Correct Solution:
```
def cross(i, j, v, n):
v[i*n+j] = '.'
if v[(i+1)*n+j] == '#':
v[(i+1)*n+j] = '.'
if v[(i+2)*n+j] == '#':
v[(i+2)*n+j] = '.'
if v[(i+1)*n+j+1] == '#':
v[(i+1)*n+j+1] = '.'
if v[(i+1)*n+j-1] == '#':
v[(i+1)*n+j-1] = '.'
return True
else:
return False
else:
return False
else:
return False
else:
return False
n = int(input())
v = ['.'] * n * n
ans = True
for i in range(n):
s = input()
for j in range(n):
v[i*n+j] = s[j]
for i in range(n):
if ans:
for j in range(n):
if v[i*n+j] == '#':
if j == 0 or j == (n - 1) or i > (n - 3):
ans = False
break
else:
ans = cross(i, j, v, n)
else:
break
if ans:
print('YES')
else:
print('NO')
``` | output | 1 | 14,545 | 7 | 29,091 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,546 | 7 | 29,092 |
Tags: greedy, implementation
Correct Solution:
```
def fits(x, y):
global n
return x >= 0 and x < n and y >= 0 and y < n
def paint(x, y):
global a
a[x][y] = '.'
a[x - 1][y] = '.'
a[x + 1][y] = '.'
a[x][y - 1] = '.'
a[x][y + 1] = '.'
def check(x, y):
global a
dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]
cnt = 0
for i in range(4):
if (fits(x + dx[i], y + dy[i]) and a[x + dx[i]][y + dy[i]] == '#'):
cnt += 1
if (a[x][y] == '#'):
cnt += 1
if (cnt == 5):
paint(x, y)
n = int(input())
a = []
for i in range(n):
a.append(list(input()))
for i in range(n):
for j in range(n):
check(i, j)
cnt = 0
for el in a:
for el2 in el:
if el2 == '#':
cnt += 1
if (cnt == 0):
print('YES')
else:
print('NO')
``` | output | 1 | 14,546 | 7 | 29,093 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,547 | 7 | 29,094 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
a = []
for i in range(n):
a.append(list(1 if c == '#' else 0 for c in input()))
for i in range(n):
for j in range(n):
if a[i][j]:
if i + 2 >= n or j + 1 >= n or j == 0:
print('NO')
exit()
if a[i + 1][j] + a[i + 2][j] + a[i + 1][j - 1] + a[i + 1][j + 1] != 4:
print('NO')
exit()
a[i][j] = a[i + 1][j] = a[i + 2][j] = a[i + 1][j - 1] = a[i + 1][j + 1] = 0
print('YES')
``` | output | 1 | 14,547 | 7 | 29,095 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,548 | 7 | 29,096 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
ar = [list(input()) for _ in range(n)]
for i in range(1, n-1):
for j in range(1, n-1):
if ar[i][j] == "#" and ar[i-1][j] == "#" and ar[i+1][j] == "#" and ar[i][j+1] == "#" and ar[i][j-1] == "#":
ar[i][j] = ar[i+1][j] = ar[i-1][j] = ar[i][j+1] = ar[i][j-1] = "."
flag = True
for i in range(n):
if ar[i].count("#") > 0:
flag = False
break
print("YES" if flag else "NO")
``` | output | 1 | 14,548 | 7 | 29,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,549 | 7 | 29,098 |
Tags: greedy, implementation
Correct Solution:
```
n=int(input())
a=[[] for i in range(n)]
for i in range(n):
s=input().strip()
for j in s:
a[i]+=[j]
kr=0
for i in range(n):
for j in range(n):
#print(i,j)
if a[i][j]=='#':
kr+=1
if 0<i<n-1 and 0<j<n-1 and a[i][j]=='#':
if a[i][j-1]==a[i][j+1]==a[i-1][j]==a[i+1][j]=='#':
kr-=3
a[i][j-1],a[i][j+1],a[i-1][j],a[i+1][j],a[i][j]='.','.','.','.','.'
if kr:
print('NO')
else:
print('YES')
``` | output | 1 | 14,549 | 7 | 29,099 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,550 | 7 | 29,100 |
Tags: greedy, implementation
Correct Solution:
```
h = int(input())
l = [c == '#' for _ in range(h) for c in input()]
w = len(l) // h
cross = (0, w - 1, w, w + 1, 2 * w)
for i in range(1, (h - 2) * w - 1):
if all(l[_ + i] for _ in cross):
for _ in cross:
l[_ + i] = False
print(('YES', 'NO')[any(l)])
# Made By Mostafa_Khaled
``` | output | 1 | 14,550 | 7 | 29,101 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all. | instruction | 0 | 14,551 | 7 | 29,102 |
Tags: greedy, implementation
Correct Solution:
```
n = int(input())
matriz = []
yes = True
for i in range(n):
matriz.append(list(input()))
for i in range(1,n-1):
for j in range(1, n-1):
if(matriz[i][j] == '#' and matriz[i-1][j] == '#' and matriz[i+1][j] == '#' and matriz[i][j-1] == '#' and matriz[i][j+1] == '#'):
matriz[i][j] = '.'
matriz[i-1][j] = '.'
matriz[i+1][j] = '.'
matriz[i][j-1] = '.'
matriz[i][j+1] = '.'
for i in range(n):
for j in range(n):
if(matriz[i][j] != '.'):
print('NO')
yes = False
break
if(yes == False):
break
if(yes):
print('YES')
``` | output | 1 | 14,551 | 7 | 29,103 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
n=int(input())
l=[]
for i in range(n):
l.append(list(input()))
f=0
for j in range(n-2):
for k in range(n):
if(l[j][k]=='#'):
if(l[j+1][k]=='#'):
if(-1<(k-1)<n):
if(l[j+1][k-1]=='#'):
if(-1<(k+1)<n):
if(l[j+1][k+1]=='#'):
if(l[j+2][k]=='#'):
l[j][k]='.'
l[j+1][k]='.'
l[j+1][k-1]='.'
l[j+1][k+1]='.'
l[j+2][k]='.'
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
if(f!=1):
for j in range(n-2,n):
for k in range(n):
if(l[j][k]=='#'):
f=1
if(f==1):
break
if(f==0):
print('YES')
else:
print('NO')
``` | instruction | 0 | 14,552 | 7 | 29,104 |
Yes | output | 1 | 14,552 | 7 | 29,105 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
def cross(n, lst):
for i in range(n):
for j in range(n):
if lst[i][j] == '#':
if i < n - 2 and 1 <= j <= n - 2 and lst[i + 1][j - 1] == '#' and lst[i + 1][j] == '#' and lst[i + 1][
j + 1] == '#' and lst[i + 2][j] == '#':
lst[i][j] = '.'
lst[i + 1][j - 1] = '.'
lst[i + 1][j] = '.'
lst[i + 1][j + 1] = '.'
lst[i + 2][j] = '.'
else:
return "NO"
return "YES"
N = int(input())
a = [list(input()) for i in range(N)]
print(cross(N, a))
``` | instruction | 0 | 14,553 | 7 | 29,106 |
Yes | output | 1 | 14,553 | 7 | 29,107 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
def check():
for i in range(n):
for j in range(n):
if board[i][j] == '#':
return False
return True
n = int(input())
board = []
for i in range(n):
board.append([char for char in input()])
for i in range(1,n-1):
for j in range(1,n-1):
if board[i][j] == '#' and board[i][j-1] == board[i][j+1] == board[i-1][j] == board[i+1][j] == '#':
board[i][j] = board[i][j-1] = board[i][j+1] = board[i-1][j] = board[i+1][j] = '@'
print("YES" if check() else "NO")
``` | instruction | 0 | 14,554 | 7 | 29,108 |
Yes | output | 1 | 14,554 | 7 | 29,109 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
n=int(input())
l=[]
for i in range(n):
l.append(list(input()))
c=0
for i in range(1,n-1):
for j in range(1,n-1):
if(l[i][j]==l[i][j+1]==l[i][j-1]==l[i-1][j]==l[i+1][j]=='#'):
l[i][j]=l[i][j+1]=l[i][j-1]=l[i-1][j]=l[i+1][j]='.'
for i in range(n):
if(l[i].count('#')>0):
c=1
break
if(c==0):
print("YES")
else:
print("NO")
``` | instruction | 0 | 14,555 | 7 | 29,110 |
Yes | output | 1 | 14,555 | 7 | 29,111 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
def check(i, j):
global matrix, n
if j==0 or j==n-1 or i>n-3:
return False
matrix[i][j] = '.'
matrix[i+1][j] = '.'
matrix[i+2][j] = '.'
matrix[i+1][j-1] = '.'
matrix[i+1][j+1] = '.'
return True
n = int(input())
matrix = []
for i in range(n):
l = list(input())
matrix.append(l)
ans = True
for i in range(n):
for j in range(n):
if matrix[i][j] == '#':
ans = check(i, j)
if not ans:
break
if ans:
print("YES")
else:
print("NO")
``` | instruction | 0 | 14,556 | 7 | 29,112 |
No | output | 1 | 14,556 | 7 | 29,113 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
n=int(input())
l=[]
for i in range(n):
l.append(list(input()))
f=0
for j in range(n-2):
for k in range(n):
if(l[j][k]=='#'):
if(l[j+1][k]=='#'):
if(-1<(k-1)<n):
if(l[j+1][k-1]=='#'):
if(-1<(k+1)<n):
if(l[j+1][k+1]=='#'):
if(l[j+2][k]=='#'):
l[j][k]='.'
l[j+1][k]='.'
l[j+1][k-1]='.'
l[j+1][k+1]='.'
l[j+2][k]='.'
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
else:
f=1
break
if(f==0):
print('YES')
else:
print('NO')
``` | instruction | 0 | 14,557 | 7 | 29,114 |
No | output | 1 | 14,557 | 7 | 29,115 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
if __name__ == '__main__':
n = int(input())
x = [list(input()) for i in range(n)]
y = [['.' for j in range(n)] for i in range(n)]
error = False
for i in range(n):
for j in range(n):
if x[i][j] == '.' and y[i][j] == '.':
continue
elif x[i][j] == '.' and y[i][j] == '#':
error = True
break
elif x[i][j] == '#' and y[i][j] == '.':
if j == 0 or j == n - 1 or i > n - 3:
error = True
break
else:
y[i][j] = '#'
y[i + 1][j - 1] = '#'
y[i + 1][j] = '#'
y[i + 1][j + 1] = '#'
y[i + 2][j] = '#'
if not error:
print('YES')
else:
print('NO')
``` | instruction | 0 | 14,558 | 7 | 29,116 |
No | output | 1 | 14,558 | 7 | 29,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
<image>
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Examples
Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
YES
Note
In example 1, you can draw two crosses. The picture below shows what they look like.
<image>
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Submitted Solution:
```
n = int(input())
s = [list(input()) for i in range(n)]
for i in range(1,n-1):
for j in range(1,n-1):
tmp = s[i][i] =='#' and s[i-1][j] == '#' and s[i+1][j] == '#' and s[i][j-1] == '#' and s[i][j+1] == '#'
if tmp :
s[i][i] =s[i-1][j] = s[i+1][j] = s[i][j-1] = s[i][j+1] = '.'
print(['YES' , 'NO'][s.count('#')==0])
``` | instruction | 0 | 14,559 | 7 | 29,118 |
No | output | 1 | 14,559 | 7 | 29,119 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,657 | 7 | 29,314 |
Tags: implementation, math
Correct Solution:
```
lst = input().split()
n = int(lst[0])
k = int(lst[1])
t = int(lst[2])
full = n*k
points = int(n*k*t/100)
result = []
while full > 0:
if points >= k:
result.append(str(k))
elif points > 0:
result.append(str(int(points)))
else:
result.append('0')
full -= k
points -= k
print(' '.join(result))
``` | output | 1 | 14,657 | 7 | 29,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,658 | 7 | 29,316 |
Tags: implementation, math
Correct Solution:
```
from math import floor
(n, k, t) = list(map(int, input().split()))
t = floor(t * n * k / 100)
sat = t // k
part = t % k
s = (str(k) + " ") * sat
if (part > 0):
s += (str(part) + " ")
sat += 1
s += (str(0) + " ") * (n - sat)
print(s)
``` | output | 1 | 14,658 | 7 | 29,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,659 | 7 | 29,318 |
Tags: implementation, math
Correct Solution:
```
n, k, t = map(int, input().split())
p = int((t/100)*(n*k))
f = p//k
for x in range(f):
print(k, end=' ')
p -= f*k
if p > 0:
print(p, end=' ')
f+=1
for x in range(n-f):
print("0", end=' ')
``` | output | 1 | 14,659 | 7 | 29,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,660 | 7 | 29,320 |
Tags: implementation, math
Correct Solution:
```
import math
#n=int(input())
#lst = list(map(int, input().strip().split(' ')))
n,k,t = map(int, input().strip().split(' '))
x1=math.floor((t*n*k)/100)
c=0
f=0
for j in range(n):
c+=k
if f==1:
print(0,end=" ")
else:
if c<=x1:
print(k,end=" ")
elif c>x1:
c-=k
print(x1-c,end=" ")
f=1
``` | output | 1 | 14,660 | 7 | 29,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,661 | 7 | 29,322 |
Tags: implementation, math
Correct Solution:
```
#codeforces_71B
gi = lambda : list(map(int,input().split()))
n,k,t = gi()
t = (n*k*t)//100
while t > k:
print(k,end=" ")
t -= k
n -= 1
print(t,end=" ")
n -= 1
while n:
print(0,end=" ")
n -= 1
``` | output | 1 | 14,661 | 7 | 29,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,662 | 7 | 29,324 |
Tags: implementation, math
Correct Solution:
```
a = input().split(" ")
n = int(a[0])
k = int(a[1])
t = int(a[2]) / 100
loop = 1
output = ""
sumTotal = int(t * n * k)
while(loop <= n):
if(loop / n <= t):
output += str(k)
elif(((loop - 1) / n < t) and (loop / n > t)):
between = sumTotal - ((loop - 1) * k)
output += str(between)
else:
output += "0"
output += " "
loop += 1
print(output)
``` | output | 1 | 14,662 | 7 | 29,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,663 | 7 | 29,326 |
Tags: implementation, math
Correct Solution:
```
x = input()
a,b,c=[int(i) for i in x.split(" ")]
proz = c/100
anz = a*b
volle = int(proz*anz/b)
rest = int(proz*anz/b%1*b)
res = ""
for i in range(volle):
res = res + str(b) + " "
if(a-volle != 0):
res = res + str(rest) + " "
for i in range(a-volle-1):
res = res + "0 "
print(res)
``` | output | 1 | 14,663 | 7 | 29,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0 | instruction | 0 | 14,664 | 7 | 29,328 |
Tags: implementation, math
Correct Solution:
```
def readln(): return tuple(map(int, input().split()))
n, k, t = readln()
for i in range(n):
for p in range(0, k + 1):
if 100 * (i * k + p) <= n * k * t < 100 * (i * k + p + 1):
print(*([k] * i + [p] + [0]*(n - i - 1)))
import sys
sys.exit(0)
``` | output | 1 | 14,664 | 7 | 29,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.
A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.
So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.
The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:
<image>
An example of such a bar can be seen on the picture.
<image>
For the given n, k, t determine the measures of saturation for all the squares ai of the progress bar.
Input
We are given 3 space-separated integers n, k, t (1 ≤ n, k ≤ 100, 0 ≤ t ≤ 100).
Output
Print n numbers. The i-th of them should be equal to ai.
Examples
Input
10 10 54
Output
10 10 10 10 10 4 0 0 0 0
Input
11 13 37
Output
13 13 13 13 0 0 0 0 0 0 0
Submitted Solution:
```
n,k,t=map(int,input().split())
ok=(n*k*t)//100
ans=[]*n
while k<=ok:
ans.append(k)
ok-=k
if ok==0:
final=ans+[0]*(n-len(ans))
else:
final=ans+[ok]+[0]*(n-len(ans)-1)
print(*final)
``` | instruction | 0 | 14,665 | 7 | 29,330 |
Yes | output | 1 | 14,665 | 7 | 29,331 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.