message stringlengths 2 43.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 853 107k | cluster float64 24 24 | __index_level_0__ int64 1.71k 214k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES | instruction | 0 | 64,106 | 24 | 128,212 |
Tags: math
Correct Solution:
```
t = int(input())
while(t):
a, b, c, n = map(int, input().strip().split())
final_coins = (a + b + c + n) / 3
if (a + b + c + n) % 3 == 0:
if a > final_coins or b > final_coins or c > final_coins:
print("NO")
else:
print("YES")
else:
print("NO")
t -= 1
``` | output | 1 | 64,106 | 24 | 128,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES | instruction | 0 | 64,107 | 24 | 128,214 |
Tags: math
Correct Solution:
```
def main():
for _ in range(int(input())):
a = list(map(int,input().split()))
s = list(reversed(sorted(a[:3])))
n = a[3]
need = 0
need += s[0] - s[1]
need += s[0] - s[2]
if need > n:
print('NO')
else:
if (n - need) % 3 == 0:
print('YES')
else:
print('NO')
main()
``` | output | 1 | 64,107 | 24 | 128,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
I=input
n=int(I())
for _ in range(n):
a,b,c,m=map(int,I().split())
k=max(a,b,c)
if (a+b+c+m)%3==0 and (a+b+c+m)/3>=k:
print("YES")
else:
print("NO")
'''n,s,k=map(int,input().split())
a=list(map(int,input().split()))
i = 0
while max(s - i, 1) in a and min(s + i, n) in a:
i += 1
print(i)
'''
``` | instruction | 0 | 64,108 | 24 | 128,216 |
Yes | output | 1 | 64,108 | 24 | 128,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
t = int(input())
for each in range(t):
arr=[int(i) for i in input().split()]
n = arr[3]
tsum = sum(arr)
arr.pop(3)
if(tsum%3==0):
p = tsum/3
if(p<max(arr)):
print("NO")
else:
print("YES")
else:
print("NO")
``` | instruction | 0 | 64,109 | 24 | 128,218 |
Yes | output | 1 | 64,109 | 24 | 128,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
t = int(input())
for number in range(t):
numbers = [int(x) for x in input().split()]
n = int(numbers[3])
l = numbers[:3]
l.sort()
n -= (2 * int(l[2])) - int(l[1]) - int(l[0])
if n % 3 == 0 and n >= 0:
print("YES")
else:
print("NO")
``` | instruction | 0 | 64,110 | 24 | 128,220 |
Yes | output | 1 | 64,110 | 24 | 128,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
def arr_inp(n):
if n == 1:
return [int(x) for x in stdin.readline().split()]
elif n == 2:
return [float(x) for x in stdin.readline().split()]
else:
return [str(x) for x in stdin.readline().split()]
from sys import stdin
for i in range(int(input())):
a, b, c, n = arr_inp(1)
ar = sorted([a, b, c])
extra1, extra2 = ar[-1] - ar[0], ar[-1] - ar[1]
all = n - (extra2 + extra1)
print('NO' if (all % 3 or all < 0) else 'YES')
``` | instruction | 0 | 64,111 | 24 | 128,222 |
Yes | output | 1 | 64,111 | 24 | 128,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
t = int(input())
for i in range(t):
a,b,c,n = map(int, input().split())
coin = [a,b,c]
coin.sort()
rem = abs(coin[0]-coin[2]) + abs(coin[1]-coin[2])
if (n-rem)>=0 & (n-rem)%3==0:
print("YES\n")
else:
print("NO\n")
``` | instruction | 0 | 64,112 | 24 | 128,224 |
No | output | 1 | 64,112 | 24 | 128,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
z = int(input())
for i in range(0, z):
a = list(map(int, input().split()))
b = max(a) * 3 - sum(a) + a[-1]
if(a[0] == a[1] == a[2]):
print("YES")
elif((a[-1] - b) %3 == 0):
print("YES")
else:
print("NO")
``` | instruction | 0 | 64,113 | 24 | 128,226 |
No | output | 1 | 64,113 | 24 | 128,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
t = int(input())
for i in range(t):
a,b,c,n = map(int,input().split(' '))
if(((a + b + c + n) % 3) == 0):
x = (a+b+c+n)/3
if((x-a)+(x-b)+(x-c) == n):
print("YES")
else:
print("NO")
``` | instruction | 0 | 64,114 | 24 | 128,228 |
No | output | 1 | 64,114 | 24 | 128,229 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has a coins, Barbara has b coins and Cerene has c coins. Recently Polycarp has returned from the trip around the world and brought n coins.
He wants to distribute all these n coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives A coins to Alice, B coins to Barbara and C coins to Cerene (A+B+C=n), then a + A = b + B = c + C.
Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.
Your task is to find out if it is possible to distribute all n coins between sisters in a way described above.
You have to answer t independent test cases.
Input
The first line of the input contains one integer t (1 β€ t β€ 10^4) β the number of test cases.
The next t lines describe test cases. Each test case is given on a new line and consists of four space-separated integers a, b, c and n (1 β€ a, b, c, n β€ 10^8) β the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.
Output
For each test case, print "YES" if Polycarp can distribute all n coins between his sisters and "NO" otherwise.
Example
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3
Output
YES
YES
NO
NO
YES
Submitted Solution:
```
def mysplit(a,b):
output_list = []
z = ""
for i in a:
if not i == b:
z += i
else:
output_list.append(int(z))
z = ""
output_list.append(int(z))
return output_list
def myjoin(a, b):
output_str = ""
for loc, i in enumerate(a):
if not loc == len(a) - 1:
output_str += i + b
output_str += a[-1]
return output_str
def maximum(a):
in_var = a[0]
for i in a:
if i > in_var:
in_var = i
return in_var
def polycarp():
lis = []
d = input()
for i in range(int(d)):
a,b,c,p = mysplit(input(), " ")
max_coins = maximum([a, b, c])
coins_needed = 3 * max_coins - a - b - c
what_isleft = p - coins_needed
if not what_isleft % 3:
lis.append("YES")
else:
lis.append("NO")
return myjoin(lis, "\n")
print(polycarp())
``` | instruction | 0 | 64,115 | 24 | 128,230 |
No | output | 1 | 64,115 | 24 | 128,231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,116 | 24 | 128,232 |
Tags: implementation
Correct Solution:
```
t = int(input())
while t>0:
t = t-1
# a,b,c = list(map(int,input().split()))
# n = int(input())
a,b,x,y = map(int,input().split())
one = (y)*(a)
two = (x)*(b)
three = ((a-1)-(x+1) +1)*(b)
four = ((b-1)-(y+1) +1)*(a)
# print(one)
# print(two)
# print(three)
# print(four)
print(max(one,two,three,four))
``` | output | 1 | 64,116 | 24 | 128,233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,117 | 24 | 128,234 |
Tags: implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
n,m,a,b = map(int,input().split())
print(max(max(a,n-a-1)*m,max(b,m-b-1)*n))
``` | output | 1 | 64,117 | 24 | 128,235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,118 | 24 | 128,236 |
Tags: implementation
Correct Solution:
```
t = int(input())
for i in range(t):
# a = int(input())
# b = int(input())
# x = int(input())
# y = int(input())
a, b, x, y = map(int, input().split())
x += 1
y += 1
row = max(a - x, x - 1)
col = max(b - y, y - 1)
result = max(row*b, a*col)
print(result)
``` | output | 1 | 64,118 | 24 | 128,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,119 | 24 | 128,238 |
Tags: implementation
Correct Solution:
```
import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
go = lambda : 1/0
def write(*args, sep="\n"):
for i in args:
sys.stdout.write("{}{}".format(i, sep))
INF = float('inf')
MOD = int(1e9 + 7)
YES = "YES"
NO = "NO"
for _ in range(int(input())):
try:
a, b, x, y = read()
up = y * a
down = (b - y - 1) * a
left = x * b
right = (a - x - 1) * b
print(max([up, down, left, right]))
except ZeroDivisionError:
continue
except Exception as e:
print(e)
continue
``` | output | 1 | 64,119 | 24 | 128,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,120 | 24 | 128,240 |
Tags: implementation
Correct Solution:
```
import math
t=int(input())
for g in range(0,t):
abxy=list(map(int,input().split()))
a=abxy[0]
b=abxy[1]
x=abxy[2]
y=abxy[3]
arr=[]
arr.append(a*y)
arr.append(a*(b-y-1))
arr.append(b*x)
arr.append(b*(a-x-1))
print(max(arr))
``` | output | 1 | 64,120 | 24 | 128,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,121 | 24 | 128,242 |
Tags: implementation
Correct Solution:
```
for _ in range(int(input())):
a,b,x,y=map(int,input().split())
print(max(b*max(x,a-x-1),a*max(y,b-y-1)))
``` | output | 1 | 64,121 | 24 | 128,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,122 | 24 | 128,244 |
Tags: implementation
Correct Solution:
```
t=int(input())
for _ in range(t):
a,b,x,y=[int(s) for s in input().split()]
r1=b*x
r2=a*y
r3=(a-x-1)*b
r4=(b-y-1)*a
print(max(r1,r2,r3,r4))
``` | output | 1 | 64,122 | 24 | 128,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image> | instruction | 0 | 64,123 | 24 | 128,246 |
Tags: implementation
Correct Solution:
```
from collections import defaultdict, Counter
def getlist():
return list(map(int, input().split()))
def maplist():
return map(int, input().split())
def main():
t = int(input())
for num in range(t):
a,b,x,y = map(int, input().split())
if x>=abs(a-x):
size1 = abs(a -abs(a-x))*b
else:
size1 = abs(a-(x+1))*b
if y>=abs(b-y):
size2 = abs(b-abs(b-y))*a
else:
size2 = abs(b - (y + 1)) * a
# print(size1,size2)
print(max(size1,size2))
main()
``` | output | 1 | 64,123 | 24 | 128,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
t=int(input())
A=[]
for i in range (t):
a, b, x, y=map(int, input().split())
A.append(max(x*b, y*a,(b-y-1)*a,(a-x-1)*b))
for i in A:
print(i)
``` | instruction | 0 | 64,124 | 24 | 128,248 |
Yes | output | 1 | 64,124 | 24 | 128,249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
t = int(input())
new_l = list()
for i in range(t):
string = list(input().split(' '))
s1 = (int(string[0])-int(string[2])-1)*int(string[1])
s2 = (int(string[0]) - (int(string[0]) -
int(string[2])-1) - 1)*int(string[1])
s3 = int(string[0])*(int(string[1]) - int(string[3]) - 1)
s4 = int(string[0])*(int(string[1]) -
(int(string[1]) - int(string[3]) - 1) - 1)
new_l.append(max(s1,s2,s3,s4))
for i in new_l:
print(i)
``` | instruction | 0 | 64,125 | 24 | 128,250 |
Yes | output | 1 | 64,125 | 24 | 128,251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
'''
the left, right top and bottom and take the max of those
'''
def solve(a, b, x, y):
return max(x*b,(a-x-1)*b, a*y, a*(b-y-1))
n = int(input())
for _ in range(n):
a, b, x, y = list(map(int, input().split()))
print(solve(a, b, x, y))
``` | instruction | 0 | 64,126 | 24 | 128,252 |
Yes | output | 1 | 64,126 | 24 | 128,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
t = int(input())
for i in range(t):
a, b, x, y = map(int, input().split())
print(max(a * y, a * (b - y - 1), b * x, b * (a - x -1)))
``` | instruction | 0 | 64,127 | 24 | 128,254 |
Yes | output | 1 | 64,127 | 24 | 128,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
for _ in range(int(input())):
a,b,x,y = map(int, input().split())
li = [
a*y, (a-x-1)*b, a*(b-y-1), (a-x-1)*(b-y-1)
]
print(max(li))
``` | instruction | 0 | 64,128 | 24 | 128,256 |
No | output | 1 | 64,128 | 24 | 128,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
for i in range(int(input())):
a,b,x,y=map(int,input().split())
if x+y==0:print(a*b-b)
else:
if b/2>y:print(a*(b-y-1))
else:print(a*b - a*(b-y))
``` | instruction | 0 | 64,129 | 24 | 128,258 |
No | output | 1 | 64,129 | 24 | 128,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
t = int(input("The number of tests is : "))
for i in range(t) :
string = str(input("Dates : "))
st = string.split()
a = int(st[0])
b = int(st[1])
x = int(st[2])
y = int(st[3])
case1 = (b-y-1)*a
case2 = y*a
case3 = x*b
case4 = (a-x-1)*b
case = max(case1, case2, case3, case4)
print(case)
``` | instruction | 0 | 64,130 | 24 | 128,260 |
No | output | 1 | 64,130 | 24 | 128,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Screen resolution of Polycarp's monitor is a Γ b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x, y) (0 β€ x < a, 0 β€ y < b). You can consider columns of pixels to be numbered from 0 to a-1, and rows β from 0 to b-1.
Polycarp wants to open a rectangular window of maximal size, which doesn't contain the dead pixel. The boundaries of the window should be parallel to the sides of the screen.
Print the maximal area (in pixels) of a window that doesn't contain the dead pixel inside itself.
Input
In the first line you are given an integer t (1 β€ t β€ 10^4) β the number of test cases in the test. In the next lines you are given descriptions of t test cases.
Each test case contains a single line which consists of 4 integers a, b, x and y (1 β€ a, b β€ 10^4; 0 β€ x < a; 0 β€ y < b) β the resolution of the screen and the coordinates of a dead pixel. It is guaranteed that a+b>2 (e.g. a=b=1 is impossible).
Output
Print t integers β the answers for each test case. Each answer should contain an integer equal to the maximal possible area (in pixels) of a rectangular window, that doesn't contain the dead pixel.
Example
Input
6
8 8 0 0
1 10 0 3
17 31 10 4
2 1 0 0
5 10 3 9
10 10 4 8
Output
56
6
442
1
45
80
Note
In the first test case, the screen resolution is 8 Γ 8, and the upper left pixel is a dead pixel. Here you can see one of two possible layouts of the maximal window.
<image>
Submitted Solution:
```
x = int(input())
if (x>=1 and x<=10000):
tab = []
for i in range(x):
c = input().rstrip(" ")
c = c.split(" ")
if int(c[0]) + int(c[1]) > 2 and len(c)==4 and int(c[0])>int(c[2]) and int(c[1])>int(c[3]):
for j in range(len(c)):
tab.append(int(c[j]))
b = tab[3]
a = tab[0]
if tab[1] == 1:
b = 1
a = tab[0] - tab[2] - 1
elif (tab[1]//2) >= tab[3] :
b = tab[1] - tab[3] - 1
r = a*b
print(r)
tab = []
else:
print('impossible')
``` | instruction | 0 | 64,131 | 24 | 128,262 |
No | output | 1 | 64,131 | 24 | 128,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,297 | 24 | 130,594 |
Tags: constructive algorithms, implementation
Correct Solution:
```
# _
#####################################################################################################################
def fileNamePattern(nNamesToDelete, name_sLength, namesToDelete, namesWithSimilarLength):
nNamesToTest = len(namesWithSimilarLength)
pattern = ''
for i in range(name_sLength):
letter = namesToDelete[0][i]
for j in range(1, nNamesToDelete):
if namesToDelete[j][i] != letter:
letter = '?'
break
for k in range(nNamesToTest):
if namesWithSimilarLength[k] and namesWithSimilarLength[k][i] != letter and letter != '?':
namesWithSimilarLength[k] = False
pattern += letter
for name in namesWithSimilarLength:
if name:
return 'No'
return f'Yes\n{pattern}'
def main():
nNames, nNamesToDelete = map(int, input().split())
rawStorage = [input() for x in range(nNames)]
indices = set(map(lambda x: int(x)-1, input().split()))
name_sLength = len(rawStorage[next(iter(indices))])
namesToDelete, namesWithSimilarLength = [], []
for i in range(nNames):
if i in indices:
if name_sLength != len(rawStorage[i]):
return 'No'
namesToDelete.append(rawStorage[i])
elif name_sLength == len(rawStorage[i]):
namesWithSimilarLength.append(rawStorage[i])
return fileNamePattern(nNamesToDelete, name_sLength, namesToDelete, namesWithSimilarLength)
if __name__ == '__main__':
print(main())
``` | output | 1 | 65,297 | 24 | 130,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,298 | 24 | 130,596 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int,input().split())
w = [input() for _ in range(n)]
todel = [w[i-1] for i in map(int, input().split())]
if len(set(map(len,todel))) != 1:
print('No')
else:
pat = ''.join(['?' if len(set([todel[j][p] for j in range(m)])) != 1 else todel[0][p] for p in range(len(todel[0]))])
ok = True
for x in w:
if len(x) != len(pat):
continue
if not x in todel:
mat = True
for i in range(len(pat)):
if pat[i] != '?' and pat[i] != x[i]:
mat = False
break
if mat:
ok = False
break
if not ok:
print('No')
else:
print('Yes')
print(pat)
``` | output | 1 | 65,298 | 24 | 130,597 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,299 | 24 | 130,598 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import sys
n, m = map(int, input().split())
file_name_list = []
for _ in range(n):
file_name_list.append(input())
file_pos_to_delete = list(map(int, input().split()))
file_to_delete_list = [file_name_list[pos - 1] for pos in file_pos_to_delete]
l = len(file_to_delete_list[0])
if any(len(e) != l for e in file_to_delete_list):
print('No')
sys.exit(0)
pattern = []
for i in range(l):
pattern.append(file_to_delete_list[0][i])
for j in range(1, m):
if pattern[-1] != file_to_delete_list[j][i]:
pattern[-1] = '?'
break
for i in range(n):
w = file_name_list[i]
if i + 1 not in file_pos_to_delete and len(w) == l and all(w[k] == pattern[k] or pattern[k] == '?' for k in range(l)):
print('No')
sys.exit(0)
print('Yes')
print(''.join(pattern))
``` | output | 1 | 65,299 | 24 | 130,599 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,300 | 24 | 130,600 |
Tags: constructive algorithms, implementation
Correct Solution:
```
m,n=list(map(int,input().split()))
s=[input().strip() for i in range(m)]
a=list(map(lambda x:int(x)-1,input().split()))
stmpl=s[a[0]]
f=1
def peres(s1,s2):
return ''.join([i if i==j else '?' for i,j in zip(s1,s2)])
for i in a:
if len(stmpl)!=len(s[i]):
f=0
break
stmpl=peres(stmpl,s[i])
for i,e in enumerate(s):
if i in a:
continue
if len(stmpl)==len(e) and stmpl==peres(stmpl,e):
f=0
break
if f:
print('Yes')
print(stmpl)
else:
print('No')
``` | output | 1 | 65,300 | 24 | 130,601 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,301 | 24 | 130,602 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n = int(input().split()[0])
all_files = [str(input()) for i in range(n)]
index_to_del = [int(i) - 1 for i in (input().split())]
def find_pattern(all_files, index_to_del):
for i in index_to_del[1:]:
if len(all_files[i]) != len(all_files[index_to_del[0]]):
return "No"
pattern = ''
for i in range(len(all_files[index_to_del[0]])):
added = False
for j in (index_to_del[1:]):
if all_files[j][i] != all_files[index_to_del[0]][i]:
if not added:
pattern += '?'
added = True
if not added:
pattern += all_files[index_to_del[0]][i]
for i in range(len(all_files)):
if i not in index_to_del:
if len(all_files[i]) == len(pattern):
matching_chars = []
for index in range(len(pattern)):
matching_chars.append(all_files[i][index] == pattern[index] or pattern[index] == '?')
if all(matching_chars):
return "No"
print("Yes")
return pattern
print(find_pattern(all_files, index_to_del))
``` | output | 1 | 65,301 | 24 | 130,603 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,302 | 24 | 130,604 |
Tags: constructive algorithms, implementation
Correct Solution:
```
"""
Oh, Grantors of Dark Disgrace,
Do Not Wake Me Again.
"""
import sys
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
si = lambda: input()
n, m = mi()
f = []
for i in range(n):
f.append(si())
lm = li()
l = len(f[lm[0]-1])
z = ['']*l
for v in lm:
if len(f[v-1]) != l:
print("No")
sys.exit(0)
else:
for i in range(len(z)):
z[i] += f[v-1][i]
x = ''
for i in range(len(z)):
if len(set(z[i])) == 1:
x += z[i][0]
else:
x += '?'
for i, j in enumerate(f):
if i+1 in lm or len(j) != l: continue
else:
b = 1
for p in range(len(j)):
if x[p]!='?' and (x[p] != j[p]):
b = 0
if b == 1:
print("No")
sys.exit(0)
print("Yes")
print(x)
``` | output | 1 | 65,302 | 24 | 130,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,303 | 24 | 130,606 |
Tags: constructive algorithms, implementation
Correct Solution:
```
n, m = map(int, input().split())
f = [input() for _ in range(n)]
d = set(map(int, input().split()))
c = {}
l = 0
for x in d:
l = len(f[x - 1])
c[l] = 1
if len(c) > 1:
print('No')
else:
t = ['?'] * l
for i in range(l):
c = {}
ch = ''
for x in d:
ch = f[x - 1][i]
c[ch] = 1
if 1 == len(c):
t[i] = ch
for i in range(n):
if (i + 1) not in d:
if len(f[i]) == l:
ok = 0
for j in range(l):
if t[j] != '?' and f[i][j] != t[j]:
ok = 1
break
if not ok:
print('No')
break
else:
print('Yes')
print(''.join(t))
``` | output | 1 | 65,303 | 24 | 130,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.??? | instruction | 0 | 65,304 | 24 | 130,608 |
Tags: constructive algorithms, implementation
Correct Solution:
```
import sys
import re
[words, selected] = input().split(" ")
[words, selected] = [int(words), int(selected)]
wordBuffer = []
selectedWords = []
for i in range(words):
wordBuffer.append(input())
buffer = input().split(" ")
for i in buffer:
selectedWords.append(wordBuffer[int(i) - 1])
for i in range(len(selectedWords)):
if (i > 0 and len(selectedWords[i - 1]) != len(selectedWords[i])):
print("No")
exit()
reg = ""
res = ""
for letter in range(len(selectedWords[0])):
isQuested = False
for i in range(selected):
if (i > 0 and selectedWords[i - 1][letter] != selectedWords[i][letter]):
reg += "."
res += "?"
isQuested = True
break
if (isQuested == False):
if (selectedWords[0][letter] == "."):
reg += "\\" + selectedWords[0][letter]
else:
reg += selectedWords[0][letter]
res += selectedWords[0][letter]
matches = 0
for i in wordBuffer:
if (re.fullmatch(reg, i) != None):
matches += 1
if (matches == selected):
print("Yes\n" + res)
else:
print("No")
``` | output | 1 | 65,304 | 24 | 130,609 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
[m, n] = [int(x) for x in input().split()]
strings = []
for i in range(m):
strings.append(input())
to_delete_index = [int(x)-1 for x in input().split()]
to_delete = [strings[int(x)] for x in to_delete_index]
base_len = len(to_delete[0])
for s in to_delete:
if len(s) != base_len:
print('No')
exit()
match_string = ""
for i in range(base_len):
match = to_delete[0][i]
for s in to_delete:
if s[i] != match:
match = "?"
break
match_string += match
def match(s, match_string):
if len(s) != len(match_string):
return False
for i in range(len(s)):
if match_string[i] == "?":
continue
if match_string[i] != s[i]:
return False
return True
for i in range(len(strings)):
if i in to_delete_index:
continue
if match(strings[i], match_string):
print("No")
exit()
print("Yes")
print(match_string)
``` | instruction | 0 | 65,305 | 24 | 130,610 |
Yes | output | 1 | 65,305 | 24 | 130,611 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
n, m = map(int, input().split())
a = []
for i in range(n):
a.append(input())
b = [int(_) for _ in input().split()]
p = list(a[b[0] - 1])
for i in range(1, len(b)):
s = a[b[i] - 1]
if len(s) != len(p):
print("No")
raise SystemExit
for j in range(len(s)):
if s[j] != p[j] and p[j] != '?':
p[j] = '?'
k = 0
f = False
for i in range(n):
if k < m and i + 1 == b[k]:
k += 1
continue
s = a[i]
if len(s) == len(p):
f = True
for j in range(len(s)):
if s[j] != p[j] and p[j] != '?':
f = False
break
if f:
print("No")
raise SystemExit
print("Yes")
print(''.join(p))
``` | instruction | 0 | 65,306 | 24 | 130,612 |
Yes | output | 1 | 65,306 | 24 | 130,613 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
#!/bin/python
import sys
counter = 0
allstrs = []
def firstnum (inpu):
out = ""
for char in inpu:
if char == ' ':
break
out += char
return int(out)
def secondnum (inpu):
first = True
out = ""
for char in inpu:
if char == ' ' and not(first):
break
elif char == ' ' and first:
first = False
out += char
return int(out)
for line in sys.stdin:
if counter == 0:
counter += 1
else:
allstrs.append(line)
removalfiles = []
removalfilesnums = list(map(int, allstrs[allstrs.__len__() - 1].split(" ")))
for i in range(0, removalfilesnums.__len__() - 0):
removalfiles.append(allstrs[removalfilesnums[i] - 1])
removalfiles = [s.strip('\n') for s in removalfiles]
for ff in removalfiles:
if removalfiles[0].__len__() != ff.__len__():
print("No")
sys.exit(0)
outString = ""
for ii in range(0, removalfiles[0].__len__()):
broke = False
for ff in removalfiles:
if ff[ii] != removalfiles[0][ii]:
broke = True
outString += '?'
break
if not broke:
outString += removalfiles[0][ii]
checklist = [s.strip('\n') for s in [allstrs[i] for i in range(0, allstrs.__len__()) if i + 1 not in removalfilesnums]]
for line in checklist:
test = False
if line.__len__() == outString.__len__():
test = True
for charLine, charOut in zip(line, outString):
if charLine != charOut and charOut != '?':
test = False
if test:
print("No")
sys.exit(0)
print("Yes")
print(outString)
``` | instruction | 0 | 65,307 | 24 | 130,614 |
Yes | output | 1 | 65,307 | 24 | 130,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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")
#-------------------game starts now-----------------------------------------------------
n,m=map(int,input().split())
ini=list()
dl=list()
for i in range (n):
s=input()
ini.append(s)
a=list(map(int,input().split()))
ch=1
for i in a:
dl.append(ini[i-1])
l=len(dl[0])
c=list(dl[0])
for i in dl:
if len(i)!=l:
ch=0
break
for j in range (l):
if i[j]!=c[j]:
c[j]='?'
for i in range (n):
if i+1 in a:
continue
s=ini[i]
if len(s)!=l:
continue
ct=0
for j in range (l):
if s[j]==c[j] or c[j]=='?':
ct+=1
if ct==l:
ch=0
break
if ch==1:
print("Yes")
print(*c,sep='')
else:
print("No")
``` | instruction | 0 | 65,308 | 24 | 130,616 |
Yes | output | 1 | 65,308 | 24 | 130,617 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
"""
Oh, Grantors of Dark Disgrace,
Do Not Wake Me Again.
"""
import sys
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
si = lambda: input()
n, m = mi()
f = []
for i in range(n):
f.append(si())
lm = li()
l = len(f[lm[0]-1])
z = ['']*l
for v in lm:
if len(f[v-1]) != l:
print("No")
sys.exit(0)
else:
for i in range(len(z)):
z[i] += f[v-1][i]
x = ''
flag = 0
for i in range(len(z)):
if len(set(z[i])) == 1:
x += z[i][0]
else:
x += '?'
flag += 1
for i, j in enumerate(f):
if i+1 in lm or len(j) != l: continue
else:
b = 1
for p in range(len(j)):
if x[p]!='?' and (x[p] != j[p]):
b = 0
if b == 1:
print("No")
sys.exit(0)
if flag == len(x) and flag != 1:
print("No")
else:
print("Yes")
print(x)
``` | instruction | 0 | 65,309 | 24 | 130,618 |
No | output | 1 | 65,309 | 24 | 130,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
def delete():
num_file,num_delete = map(int, input().split())
list_file = []
for i in range(num_file):
list_file.append(input())
delete_file = [int(i)-1 for i in input().split()]
ans=[]
delete_list = sorted([list_file[i]for i in delete_file],key=len)
## print(delete_list)
tmp = list(delete_list[0])
for i in delete_list[1:]:
name = list(i)
if len(tmp) != len(i):
ans.append(tmp)
tmp=list(i)
for j in range(len(tmp)):
if name[j] != tmp[j]:
tmp[j] = "?"
ans.append(tmp)
## print(ans)
for i in []+ans:
tmp = i[0]
p = 1
for j in i:
if tmp != j:
p=0
if p:
ans.remove(i)
if len(ans) == 0:
print("No")
else:
print("Yes")
for i in ans:
for c in i:
print(c,end="")
print(" ",end="")
delete()
``` | instruction | 0 | 65,310 | 24 | 130,620 |
No | output | 1 | 65,310 | 24 | 130,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
def delete():
num_file,num_delete = map(int, input().split())
list_file = []
for i in range(num_file):
list_file.append(input())
delete_file = [int(i)-1 for i in input().split()]
ans=[]
delete_list = sorted([list_file[i]for i in delete_file],key=len)
## print(delete_list)
tmp = list(delete_list[0])
for i in delete_list[1:]:
name = list(i)
if len(tmp) != len(i):
ans.append(tmp)
tmp=list(i)
for j in range(len(tmp)):
if name[j] != tmp[j]:
tmp[j] = "?"
ans.append(tmp)
## print(ans)
for i in []+ans:
tmp = i[0]
p = 1
for j in i:
if tmp != j:
p=0
if p or all([i!='?' for j in i]):
ans.remove(i)
if len(ans) == 0:
print("No")
else:
print("Yes")
zzz = ""
for i in ans:
for c in i:
zzz+=c
zzz+=" "
print(zzz[:-1])
delete()
``` | instruction | 0 | 65,311 | 24 | 130,622 |
No | output | 1 | 65,311 | 24 | 130,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp is a beginner programmer. He is studying how to use a command line.
Polycarp faced the following problem. There are n files in a directory and he needs to delete some of them. Polycarp wants to run a single delete command with filename pattern as an argument. All the files to be deleted should match the pattern and all other files shouldn't match the pattern.
Polycarp doesn't know about an asterisk '*', the only special character he knows is a question mark '?' which matches any single character. All other characters in the pattern match themselves only.
Formally, a pattern matches a filename if and only if they have equal lengths and all characters in the corresponding positions are equal except when the character in the pattern is '?', in which case the corresponding filename character does not matter.
For example, the filename pattern "a?ba?":
* matches filenames "aabaa", "abba.", "a.ba9" and "a.ba.";
* does not match filenames "aaba", "abaab", "aabaaa" and "aabaa.".
Help Polycarp find a pattern which matches files to be deleted and only them or report if there is no such pattern.
Input
The first line of the input contains two integers n and m (1 β€ m β€ n β€ 100) β the total number of files and the number of files to be deleted.
The following n lines contain filenames, single filename per line. All filenames are non-empty strings containing only lowercase English letters, digits and dots ('.'). The length of each filename doesn't exceed 100. It is guaranteed that all filenames are distinct.
The last line of the input contains m distinct integer numbers in ascending order a1, a2, ..., am (1 β€ ai β€ n) β indices of files to be deleted. All files are indexed from 1 to n in order of their appearance in the input.
Output
If the required pattern exists, print "Yes" in the first line of the output. The second line should contain the required pattern. If there are multiple solutions, print any of them.
If the required pattern doesn't exist, print the only line containing "No".
Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
Submitted Solution:
```
def delete():
num_file,num_delete = map(int, input().split())
list_file = []
for i in range(num_file):
list_file.append(input())
delete_file = [int(i)-1 for i in input().split()]
ans=[]
delete_list = sorted([list_file[i]for i in delete_file],key=len)
## print(delete_list)
tmp = list(delete_list[0])
for i in delete_list[1:]:
name = list(i)
if len(tmp) != len(i):
ans.append(tmp)
tmp=list(i)
for j in range(len(tmp)):
if name[j] != tmp[j]:
tmp[j] = "?"
ans.append(tmp)
## print(ans)
for i in []+ans:
tmp = i[0]
p = 1
for j in i:
if tmp != j:
p=0
if p:
ans.remove(i)
if len(ans) == 0:
print("No")
else:
print("Yes")
for i in ans:
for c in i:
print(c,end="")
print()
delete()
``` | instruction | 0 | 65,312 | 24 | 130,624 |
No | output | 1 | 65,312 | 24 | 130,625 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,329 | 24 | 130,658 |
Tags: *special, binary search
Correct Solution:
```
n, k = map(int, input().split())
s = input()
l, r = int(-1), int(n)
while r - l > 1:
m = (l+r)//2
c, p = 1, 0
cond = True
while p < n and c < k:
i = p + m + 1
while i >= p and (i >= n or s[i] == '1'):
i = i - 1;
if (i == p):
break
c = c + 1
p = i
cond = cond and (p == n-1)
if cond:
r = m
else:
l = m
print(int(r))
``` | output | 1 | 65,329 | 24 | 130,659 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,330 | 24 | 130,660 |
Tags: *special, binary search
Correct Solution:
```
import sys
from math import *
from fractions import gcd
from random import * # randint(inclusive,inclusive)
readints=lambda:map(int, input().strip('\n').split())
from itertools import permutations, combinations
s = "abcdefghijklmnopqrstuvwxyz"
# print('', end=" ")
# for i in {1..5}; do echo "hi"; done
n,k=readints()
s=input()
g=[0]*n
for i in range(n):
if s[i]=='0':
g[i]=i
else:
g[i]=g[i-1]
def f(hop):
at=0
used=0
while used<k-2 and at+hop<n:
to=g[at+hop]
if to==at:
break
used+=1
at=to
if n-1-at>hop:
return False
return True
lo=-1
hi=n+1
while hi-lo>1:
mid=(lo+hi)//2
if f(mid):
hi=mid
else:
lo=mid
print(hi-1)
``` | output | 1 | 65,330 | 24 | 130,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,331 | 24 | 130,662 |
Tags: *special, binary search
Correct Solution:
```
def check(p):
cur = k - 2
p+=1
lastfree = 0
lasteat = 0
for i in range(1, n-1):
if tm[i] == '0':
lastfree = i
if i - lasteat >= p:
if lasteat == lastfree or cur <= 0:
return False
lasteat = lastfree
cur -= 1
return True
def bs(l, r):
while(l < r):
mid = (l + r) >> 1
if check(mid):
r = mid
else:
l = mid + 1
return l
n, k = map(int, input().split())
tm = input()
print(bs(0, n))
``` | output | 1 | 65,331 | 24 | 130,663 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,332 | 24 | 130,664 |
Tags: *special, binary search
Correct Solution:
```
from sys import exit
n=0
k=0
s=""
for i in input().split():
if n==0:
n=int(i)
else:
k=int(i)
s=str(input())
node=[]
for i in range(len(s)):
if s[int(i)]=='0':
node.append(i+1)
node.append(1000000000)
def check(dis):
current=0
num=k-2
for i in range(len(node)-1):
if num<1:
break
if node[i]-node[current]<=dis and node[i+1]-node[current]>dis:
current=i
num-=1
if n-node[current]>dis:
return -1
return 1
left=1
right=n
while left+1<right:
mid=int((left+right)/2)
t=check(mid)
if t==1:
right=mid
else:
left=mid
for i in range(left,right+1):
if check(i)==1:
print(i-1)
exit(0)
print(0)
``` | output | 1 | 65,332 | 24 | 130,665 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,333 | 24 | 130,666 |
Tags: *special, binary search
Correct Solution:
```
import sys
from math import *
from fractions import gcd
from random import * # randint(inclusive,inclusive)
readints=lambda:map(int, input().strip('\n').split())
from itertools import permutations, combinations
s = "abcdefghijklmnopqrstuvwxyz"
# print('', end=" ")
# for i in {1..5}; do echo "hi"; done
n,k=readints()
s=input()
lo=-1
hi=n+1
def test(x):
have=k-1
last=0
arr=[]
for i in range(n):
if s[i]=='0':
arr.append(i)
arr.append(10**9)
for i in range(1,len(arr)):
if arr[i]-last-1>x:
if arr[i-1]==last:
return False
if have==0:
return False
if arr[i-1]-last-1>x:
return False
last=arr[i-1]
have-=1
return True
while hi-lo>1:
mid=(lo+hi)//2
if test(mid):
hi=mid
else:
lo=mid
print(hi)
``` | output | 1 | 65,333 | 24 | 130,667 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,334 | 24 | 130,668 |
Tags: *special, binary search
Correct Solution:
```
import sys
from math import *
from fractions import gcd
from random import * # randint(inclusive,inclusive)
readints=lambda:map(int, input().strip('\n').split())
from itertools import permutations, combinations
s = "abcdefghijklmnopqrstuvwxyz"
# print('', end=" ")
# for i in {1..5}; do echo "hi"; done
n,k=readints()
s=input()
lo=-1
hi=n+1
hop = [0]*n
for i in range(n):
if s[i]=='0':
hop[i]=i
else:
hop[i]=hop[i-1]
def test(jump):
at=0
used=0
while used < k-2:
if at+jump<n:
to = hop[at+jump]
if to == at:
break
at = to
used += 1
else:
break
if n-1-at>jump:
return False
return True
while hi-lo>1:
mid=(lo+hi)//2
if test(mid):
hi=mid
else:
lo=mid
print(hi-1)
``` | output | 1 | 65,334 | 24 | 130,669 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,335 | 24 | 130,670 |
Tags: *special, binary search
Correct Solution:
```
import sys
from math import *
from fractions import gcd
from random import * # randint(inclusive,inclusive)
readints=lambda:map(int, input().strip('\n').split())
from itertools import permutations, combinations
s = "abcdefghijklmnopqrstuvwxyz"
# print('', end=" ")
# for i in {1..5}; do echo "hi"; done
n,k=readints()
s=input()
g=[0]*n
for i in range(n):
if s[i]=='0':
g[i]=i
else:
g[i]=g[i-1]
def f(hop):
at=0
used=0
while used<k-2 and n-1-at>hop:
to=g[at+hop]
if to==at:
break
used+=1
at=to
if n-1-at>hop:
return False
return True
lo=-1
hi=n+1
while hi-lo>1:
mid=(lo+hi)//2
if f(mid):
hi=mid
else:
lo=mid
print(hi-1)
``` | output | 1 | 65,335 | 24 | 130,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp's workday lasts exactly n minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has k bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that k is strictly greater than 1.
Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.
Consider that Polycarp eats a bar in the minute x and the next bar in the minute y (x < y). Then the break time is equal to y - x - 1 minutes. It is not necessary for Polycarp to eat all bars he has.
Input
The first line contains two integers n and k (2 β€ n β€ 200 000, 2 β€ k β€ n) β the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday.
The second line contains the string with length n consisting of zeros and ones. If the i-th symbol in the string equals to zero, Polycarp has no important things to do in the minute i and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute i and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.
Output
Print the minimum possible break in minutes between eating chocolate bars.
Examples
Input
3 3
010
Output
1
Input
8 3
01010110
Output
3
Note
In the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.
In the second example Polycarp will eat bars in the minutes 1 and 8 anyway, also he needs to eat the chocolate bar in the minute 5, so that the time of the maximum break will be equal to 3 minutes. | instruction | 0 | 65,336 | 24 | 130,672 |
Tags: *special, binary search
Correct Solution:
```
def ok(x, k, s, n):
i = 0
k-=1
while i < len(s):
if(i + x + 1 >= len(s)):
k -= 1
#print(len(s) - 1)
break
j = n[i + x + 1]
if(j == i):
return 0
i = j
#print(i)
k -= 1
if i == len(s) - 1:
break
#print(k)
return k >= 0
n, k = map(int, input().split())
s = input()
n = [0]
for i in range(1, len(s)):
if s[i] == '0':
n.append(i)
else:
n.append(n[-1])
#print(ok(2, k, s, n))
#exit(0)
l = -1
r = len(s)
while r - l > 1:
m = (l + r)//2
if ok(m, k, s, n):
r = m
else:
l = m
print(r)
``` | output | 1 | 65,336 | 24 | 130,673 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.