text stringlengths 216 39.6k | conversation_id int64 219 108k | embedding list | cluster int64 11 11 |
|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.
First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if ci ≤ aj ≤ bj ≤ di, i.e. each note of the part is in the actor's voice range.
According to the contract, the i-th actor can perform at most ki parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).
The rehearsal starts in two hours and you need to do the assignment quickly!
Input
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).
Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).
The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).
Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).
Output
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.
In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of them.
If there is no correct assignment, print a single word "NO" (without the quotes).
Examples
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2
Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO
Submitted Solution:
```
n = int(input())
prtlst = []
for i in range(n):
line = input().split()
lst = [int(line[0]), int(line[1]), i]
prtlst.append(lst)
m = int(input())
actlst = []
for i in range(m):
line = input().split()
lst = [int(line[0]), int(line[1]), int(line[2]), i + 1]
actlst.append(lst)
prtlst.sort()
actlst.sort()
ans = []
flag = True
i = 0
for prt in prtlst:
while i < m and actlst[i][2] < 1:
i += 1
if i >= m:
flag = False
break
while i < m and not (actlst[i][0] <= prt[0] and actlst[i][1] >= prt[1]):
i += 1
if i >= m:
flag = False
break
ans.append(actlst[i][3])
actlst[i][2] -= 1
if flag:
print('YES')
line = ''
for num in ans:
line += str(num) + ' '
print(line)
else:
print('NO')
```
No
| 64,379 | [
0.204345703125,
-0.0787353515625,
-0.24658203125,
-0.25927734375,
-0.42626953125,
-0.310302734375,
0.06182861328125,
-0.1353759765625,
0.187255859375,
0.86962890625,
0.603515625,
-0.2347412109375,
0.41259765625,
-1.0439453125,
-0.395263671875,
0.37841796875,
-0.76513671875,
-0.7124... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.
First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if ci ≤ aj ≤ bj ≤ di, i.e. each note of the part is in the actor's voice range.
According to the contract, the i-th actor can perform at most ki parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).
The rehearsal starts in two hours and you need to do the assignment quickly!
Input
The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).
Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).
The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).
Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).
Output
If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.
In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of them.
If there is no correct assignment, print a single word "NO" (without the quotes).
Examples
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2
Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO
Submitted Solution:
```
from itertools import *
def main(n,m,a,b,c,d,k, info=1):
global p,s, parts, singers
parts = [list(x) for x in sorted(zip(a,b,range(n),[0]*n))]
singers = [list(x)+[i] for i,x in enumerate(sorted(zip(c,d,k,range(m))))]
if info:
print("Parts: ",parts)
print("Singers: ",singers)
for j,p in enumerate(parts):
s = dropwhile(lambda x: x[1]<=p[0], singers)
s = list(takewhile(lambda x: x[0]<=p[0], s))
mn,ind = 1e9, -1
for i,x in enumerate(s):
if x[1]>=p[1] and x[2]>0 and x[1]<mn:
mn = x[1]
ind = x[4]
if info:
print(j,i,": ",p,mn,ind)
if s == [] or ind == -1:
print("NO")
return
singers[ind][2] -= 1 # reduce number of parts
parts[j][3] = singers[ind][3]+1
print("YES")
print(*[p[3] for p in sorted(parts,key=lambda x: x[2])])
def main_input():
global a,b,c,d,k,n,m
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
a[i], b[i] = [int(x) for x in input().split()]
m = int(input())
c,d,k = [0]*m, [0]*m, [0]*m
for i in range(m):
c[i], d[i], k[i] = [int(x) for x in input().split()]
main(n,m,a,b,c,d,k)
if __name__ == "__main__":
main_input()
```
No
| 64,380 | [
0.204345703125,
-0.0787353515625,
-0.24658203125,
-0.25927734375,
-0.42626953125,
-0.310302734375,
0.06182861328125,
-0.1353759765625,
0.187255859375,
0.86962890625,
0.603515625,
-0.2347412109375,
0.41259765625,
-1.0439453125,
-0.395263671875,
0.37841796875,
-0.76513671875,
-0.7124... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure:
* The crow sets ai initially 0.
* The crow then adds bi to ai, subtracts bi + 1, adds the bi + 2 number, and so on until the n'th number. Thus, ai = bi - bi + 1 + bi + 2 - bi + 3....
Memory gives you the values a1, a2, ..., an, and he now wants you to find the initial numbers b1, b2, ..., bn written in the row? Can you do it?
Input
The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.
The next line contains n, the i'th of which is ai ( - 109 ≤ ai ≤ 109) — the value of the i'th number.
Output
Print n integers corresponding to the sequence b1, b2, ..., bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.
Examples
Input
5
6 -4 8 -2 3
Output
2 4 6 1 3
Input
5
3 -2 -1 5 6
Output
1 -3 4 11 6
Note
In the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and - 4 = 4 - 6 + 1 - 3.
In the second sample test, the sequence 1, - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.
Submitted Solution:
```
def solution(l1):
i=0
while i<len(l1)-1:
l1[i]=str(int(l1[i])+int(l1[i+1]))+" "
i+=1
c_out="".join(l1)
return c_out
def answer():
a = int(input())
l1 = input().split()
print(solution(l1))
answer()
```
Yes
| 64,476 | [
0.471435546875,
0.2301025390625,
-0.06591796875,
-0.2247314453125,
-0.5634765625,
-0.457763671875,
-0.16943359375,
-0.0543212890625,
0.23486328125,
0.75830078125,
0.56982421875,
0.0841064453125,
-0.365478515625,
-0.74853515625,
-0.217041015625,
-0.108642578125,
-0.6416015625,
-0.55... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure:
* The crow sets ai initially 0.
* The crow then adds bi to ai, subtracts bi + 1, adds the bi + 2 number, and so on until the n'th number. Thus, ai = bi - bi + 1 + bi + 2 - bi + 3....
Memory gives you the values a1, a2, ..., an, and he now wants you to find the initial numbers b1, b2, ..., bn written in the row? Can you do it?
Input
The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.
The next line contains n, the i'th of which is ai ( - 109 ≤ ai ≤ 109) — the value of the i'th number.
Output
Print n integers corresponding to the sequence b1, b2, ..., bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.
Examples
Input
5
6 -4 8 -2 3
Output
2 4 6 1 3
Input
5
3 -2 -1 5 6
Output
1 -3 4 11 6
Note
In the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and - 4 = 4 - 6 + 1 - 3.
In the second sample test, the sequence 1, - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.
Submitted Solution:
```
# problem/712/A
import copy
n = int(input())
a = [int(n) for i,n in enumerate(input().split(" "))]
b = []
for i in range(n-1, -1, -1):
x = a[i]
for j, b_ in enumerate(b):
if j % 2 == 0:
x += b_
elif j % 2 == 1:
x -= b_
b.insert(0,x)
print(str(b)[1:-1])
```
No
| 64,478 | [
0.456787109375,
0.19091796875,
-0.07318115234375,
-0.2244873046875,
-0.5693359375,
-0.455322265625,
-0.192138671875,
-0.05548095703125,
0.26025390625,
0.7900390625,
0.625,
0.064697265625,
-0.328857421875,
-0.73046875,
-0.232421875,
-0.1094970703125,
-0.62841796875,
-0.5673828125,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
<image>
Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.
This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).
Chtholly wins if, at any time, all the sheets are filled with a number and the n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m rounds she still doesn't win, she loses the game.
Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.
Input
The first line contains 3 integers n, m and c (<image>, <image> means <image> rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.
Interaction
In each round, your program needs to read one line containing a single integer pi (1 ≤ pi ≤ c), indicating the number given to Chtholly.
Your program should then output a line containing an integer between 1 and n, indicating the number of sheet to write down this number in.
After outputting each line, don't forget to flush the output. For example:
* fflush(stdout) in C/C++;
* System.out.flush() in Java;
* sys.stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
If Chtholly wins at the end of a round, no more input will become available and your program should terminate normally. It can be shown that under the constraints, it's always possible for Chtholly to win the game.
Example
Input
2 4 4
2
1
3
Output
1
2
2
Note
In the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game.
Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.
The input format for hacking:
* The first line contains 3 integers n, m and c;
* The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.
Submitted Solution:
```
def get_int(string, n):
i = j = k = 0
for s in string:
k += 1
for s in string:
if i == n - 1:
break
if s == ' ':
i += 1
j += 1
i = 0
while j < k:
if string[j] == ' ':
break
i = 10 * i + int(string[j])
j += 1
return i
def check_order(ls, n):
for i in ls:
if i == None:
return 0
for i in range(0, n - 1):
if ls[i] > ls[i + 1]:
return -1
return 1
def forward(p, ls, n):
for i in range(0, n):
if ls[i] == None:
ls[i] = p
print(i + 1)
return 0
if ls[i] > p:
ls[i] = p
print(i + 1)
return 0
def reverse(p, ls, n):
i = -1
while i >= -n:
if ls[i] == None:
ls[i] = p
print(n + 1 - i)
return 0
if ls[i] < p:
ls[i] = p
print(n + 1 - i)
return 0
x = input()
n = get_int(x, 1)
m = get_int(x, 2)
c = get_int(x, 3)
ls = []
for i in range(0, n):
ls += [None]
for i in range(0, m):
p = int(input())
if p > c/2:
reverse(p, ls, n)
else:
forward(p, ls, n)
if check_order(ls, n) == 1:
print(ls)
break
```
No
| 64,542 | [
0.20458984375,
0.07403564453125,
0.09027099609375,
0.137939453125,
-0.9296875,
-0.6337890625,
-0.58349609375,
-0.014556884765625,
-0.028594970703125,
0.71533203125,
-0.08856201171875,
0.36767578125,
-0.00826263427734375,
-0.407470703125,
-0.49267578125,
0.0276947021484375,
-0.8129882... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
<image>
Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.
This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).
Chtholly wins if, at any time, all the sheets are filled with a number and the n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m rounds she still doesn't win, she loses the game.
Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.
Input
The first line contains 3 integers n, m and c (<image>, <image> means <image> rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.
Interaction
In each round, your program needs to read one line containing a single integer pi (1 ≤ pi ≤ c), indicating the number given to Chtholly.
Your program should then output a line containing an integer between 1 and n, indicating the number of sheet to write down this number in.
After outputting each line, don't forget to flush the output. For example:
* fflush(stdout) in C/C++;
* System.out.flush() in Java;
* sys.stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
If Chtholly wins at the end of a round, no more input will become available and your program should terminate normally. It can be shown that under the constraints, it's always possible for Chtholly to win the game.
Example
Input
2 4 4
2
1
3
Output
1
2
2
Note
In the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game.
Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.
The input format for hacking:
* The first line contains 3 integers n, m and c;
* The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.
Submitted Solution:
```
import sys
n, m, c = map(int, input().split())
free = n
nums = [0] * n
for i in range(m):
pi = int(input())
if(pi >= c//2):
current = n - 1
while(nums[current] > 0 and nums[current] >= pi and current >= 0):current -= 1
if(current == -1):current = 0
if(nums[current] == 0):free -= 1
nums[current] = pi
print(current + 1)
else:
current = 0
while(current < n and nums[current] > 0 and nums[current] <= pi):current += 1
if(current == n):current = n - 1
if(nums[current] == 0):free -=1
nums[current] = pi
print(current + 1)
if(free == 0):break
```
No
| 64,543 | [
0.20458984375,
0.07403564453125,
0.09027099609375,
0.137939453125,
-0.9296875,
-0.6337890625,
-0.58349609375,
-0.014556884765625,
-0.028594970703125,
0.71533203125,
-0.08856201171875,
0.36767578125,
-0.00826263427734375,
-0.407470703125,
-0.49267578125,
0.0276947021484375,
-0.8129882... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
<image>
Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.
This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).
Chtholly wins if, at any time, all the sheets are filled with a number and the n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m rounds she still doesn't win, she loses the game.
Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.
Input
The first line contains 3 integers n, m and c (<image>, <image> means <image> rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.
Interaction
In each round, your program needs to read one line containing a single integer pi (1 ≤ pi ≤ c), indicating the number given to Chtholly.
Your program should then output a line containing an integer between 1 and n, indicating the number of sheet to write down this number in.
After outputting each line, don't forget to flush the output. For example:
* fflush(stdout) in C/C++;
* System.out.flush() in Java;
* sys.stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
If Chtholly wins at the end of a round, no more input will become available and your program should terminate normally. It can be shown that under the constraints, it's always possible for Chtholly to win the game.
Example
Input
2 4 4
2
1
3
Output
1
2
2
Note
In the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game.
Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.
The input format for hacking:
* The first line contains 3 integers n, m and c;
* The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.
Submitted Solution:
```
import sys
n, m, c = map(int, input().split())
free = n
nums = [0] * n
for i in range(m):
pi = int(input())
index = int(((pi - c) * (1 - n) / (1 - c)) + (n - 1))
up = index
try:
while(nums[up] <= pi and nums[up] != 0):up += 1
except:
pass
down = index
while(down >= 0 and nums[down] <= pi and nums[down] != 0):down -= 1
answer = up
if(up == n):answer = down
print(answer + 1)
sys.stdout.flush()
if(nums[answer] == 0):free -= 1
nums[answer] = pi
if(free == 0):sys.exit()
```
No
| 64,544 | [
0.20458984375,
0.07403564453125,
0.09027099609375,
0.137939453125,
-0.9296875,
-0.6337890625,
-0.58349609375,
-0.014556884765625,
-0.028594970703125,
0.71533203125,
-0.08856201171875,
0.36767578125,
-0.00826263427734375,
-0.407470703125,
-0.49267578125,
0.0276947021484375,
-0.8129882... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
<image>
Initially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n from left to right.
This game will go on for m rounds. In each round, Ithea will give Chtholly an integer between 1 and c, and Chtholly needs to choose one of the sheets to write down this number (if there is already a number before, she will erase the original one and replace it with the new one).
Chtholly wins if, at any time, all the sheets are filled with a number and the n numbers are in non-decreasing order looking from left to right from sheet 1 to sheet n, and if after m rounds she still doesn't win, she loses the game.
Chtholly really wants to win the game as she wants to cook something for Willem. But she doesn't know how to win the game. So Chtholly finds you, and your task is to write a program to receive numbers that Ithea gives Chtholly and help her make the decision on which sheet of paper write this number.
Input
The first line contains 3 integers n, m and c (<image>, <image> means <image> rounded up) — the number of sheets, the number of rounds and the largest possible number Ithea can give to Chtholly respectively. The remaining parts of input are given throughout the interaction process.
Interaction
In each round, your program needs to read one line containing a single integer pi (1 ≤ pi ≤ c), indicating the number given to Chtholly.
Your program should then output a line containing an integer between 1 and n, indicating the number of sheet to write down this number in.
After outputting each line, don't forget to flush the output. For example:
* fflush(stdout) in C/C++;
* System.out.flush() in Java;
* sys.stdout.flush() in Python;
* flush(output) in Pascal;
* See the documentation for other languages.
If Chtholly wins at the end of a round, no more input will become available and your program should terminate normally. It can be shown that under the constraints, it's always possible for Chtholly to win the game.
Example
Input
2 4 4
2
1
3
Output
1
2
2
Note
In the example, Chtholly initially knew there were 2 sheets, 4 rounds and each number was between 1 and 4. She then received a 2 and decided to write it in the 1st sheet. Then she received a 1 and wrote it in the 2nd sheet. At last, she received a 3 and replaced 1 with 3 in the 2nd sheet. At this time all the sheets were filled with a number and they were non-decreasing, so she won the game.
Note that it is required that your program terminate immediately after Chtholly wins and do not read numbers from the input for the remaining rounds. If not, undefined behaviour may arise and it won't be sure whether your program will be accepted or rejected. Also because of this, please be careful when hacking others' codes. In the sample, Chtholly won the game after the 3rd round, so it is required that your program doesn't read the number of the remaining 4th round.
The input format for hacking:
* The first line contains 3 integers n, m and c;
* The following m lines each contains an integer between 1 and c, indicating the number given to Chtholly in each round.
Submitted Solution:
```
import sys
import math
N, M, C = map(int, input().split())
mid = C // 2
res = []
for i in range(0, N):
res.append(0)
l, r = 0, N - 1
for i in range(0, M):
val = int(input())
pos = 0
if (val <= mid):
for j in range(0, l + 1):
if (res[j] == 0 or val < res[j]):
res[j] = val
pos = j
break
if (pos == l):
l += 1
else:
for j in range(N - 1, r - 1, -1):
if (res[j] == 0 or val < res[j]):
res[j] = val
pos = j
break
if (pos == r):
r -= 1
print ("%d" % (pos + 1))
sys.stdout.flush()
if (l > r):
exit()
```
No
| 64,545 | [
0.20458984375,
0.07403564453125,
0.09027099609375,
0.137939453125,
-0.9296875,
-0.6337890625,
-0.58349609375,
-0.014556884765625,
-0.028594970703125,
0.71533203125,
-0.08856201171875,
0.36767578125,
-0.00826263427734375,
-0.407470703125,
-0.49267578125,
0.0276947021484375,
-0.8129882... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.
Since the teacher in charge is nasty, I am concerned about the score distribution that maximizes the difference between the average value and the median value. Output one such way of scoring.
Note: The average value is the sum of the points divided by n, and the median is the (n + 1) / second (1 − indexed) from the front if n is an odd number when the points are arranged in ascending order. If it is an even number, it is the score obtained by adding the n / 2nd and n / 2 + 1th scores from the front and dividing by 2.
input
n \ m
Constraint
* An integer
* 1 ≤ n ≤ 100
* 1 ≤ m ≤ 100
output
Output the n-point column of the answer on a single line separated by spaces, and finally output a line break. If there are multiple types, any one can be output.
sample
Sample input 1
3 100
Sample output 1
0 0 100
100 \ 100 \ 0 etc. are also correct answers.
Sample input 2
1 100
Sample output 2
50
Example
Input
3 100
Output
0 0 100
"Correct Solution:
```
# -*- coding: utf-8 -*-
(n,m)=[int(a) for a in input().split()]
for i in range(n):
if i:print(" ",end="")
if i<=n/2: print("0",end="")
else: print("{}".format(m),end="")
print("")
```
| 64,788 | [
-0.054931640625,
0.03839111328125,
-0.402099609375,
0.07135009765625,
-0.6796875,
-0.57421875,
-0.014801025390625,
-0.10382080078125,
-0.1007080078125,
1.0576171875,
0.478271484375,
-0.103515625,
0.387451171875,
-0.5732421875,
-0.51318359375,
-0.074951171875,
-0.91357421875,
-0.955... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.
Since the teacher in charge is nasty, I am concerned about the score distribution that maximizes the difference between the average value and the median value. Output one such way of scoring.
Note: The average value is the sum of the points divided by n, and the median is the (n + 1) / second (1 − indexed) from the front if n is an odd number when the points are arranged in ascending order. If it is an even number, it is the score obtained by adding the n / 2nd and n / 2 + 1th scores from the front and dividing by 2.
input
n \ m
Constraint
* An integer
* 1 ≤ n ≤ 100
* 1 ≤ m ≤ 100
output
Output the n-point column of the answer on a single line separated by spaces, and finally output a line break. If there are multiple types, any one can be output.
sample
Sample input 1
3 100
Sample output 1
0 0 100
100 \ 100 \ 0 etc. are also correct answers.
Sample input 2
1 100
Sample output 2
50
Example
Input
3 100
Output
0 0 100
"Correct Solution:
```
n, m = map(int, input().split())
if n % 2:
print(*[0] * (n // 2) + [m] * (n // 2 + 1))
else:
print(*[0] * (n // 2 - 1) + [m] * (n // 2 + 1))
```
| 64,789 | [
-0.043792724609375,
0.130126953125,
-0.43603515625,
0.0543212890625,
-0.65478515625,
-0.5654296875,
-0.143798828125,
-0.1358642578125,
-0.1593017578125,
1.080078125,
0.51611328125,
-0.1114501953125,
0.455810546875,
-0.62890625,
-0.461669921875,
0.0232086181640625,
-0.90283203125,
-... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.
Since the teacher in charge is nasty, I am concerned about the score distribution that maximizes the difference between the average value and the median value. Output one such way of scoring.
Note: The average value is the sum of the points divided by n, and the median is the (n + 1) / second (1 − indexed) from the front if n is an odd number when the points are arranged in ascending order. If it is an even number, it is the score obtained by adding the n / 2nd and n / 2 + 1th scores from the front and dividing by 2.
input
n \ m
Constraint
* An integer
* 1 ≤ n ≤ 100
* 1 ≤ m ≤ 100
output
Output the n-point column of the answer on a single line separated by spaces, and finally output a line break. If there are multiple types, any one can be output.
sample
Sample input 1
3 100
Sample output 1
0 0 100
100 \ 100 \ 0 etc. are also correct answers.
Sample input 2
1 100
Sample output 2
50
Example
Input
3 100
Output
0 0 100
"Correct Solution:
```
n,m=map(int,input().split());p=n//2+1;print(*[0]*p+[m]*(n-p))
```
| 64,790 | [
-0.009979248046875,
0.1107177734375,
-0.366455078125,
0.0806884765625,
-0.69140625,
-0.56689453125,
-0.168701171875,
-0.1268310546875,
-0.1600341796875,
1.0986328125,
0.505859375,
-0.099609375,
0.434814453125,
-0.599609375,
-0.4658203125,
0.029937744140625,
-0.87939453125,
-0.87304... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.
Since the teacher in charge is nasty, I am concerned about the score distribution that maximizes the difference between the average value and the median value. Output one such way of scoring.
Note: The average value is the sum of the points divided by n, and the median is the (n + 1) / second (1 − indexed) from the front if n is an odd number when the points are arranged in ascending order. If it is an even number, it is the score obtained by adding the n / 2nd and n / 2 + 1th scores from the front and dividing by 2.
input
n \ m
Constraint
* An integer
* 1 ≤ n ≤ 100
* 1 ≤ m ≤ 100
output
Output the n-point column of the answer on a single line separated by spaces, and finally output a line break. If there are multiple types, any one can be output.
sample
Sample input 1
3 100
Sample output 1
0 0 100
100 \ 100 \ 0 etc. are also correct answers.
Sample input 2
1 100
Sample output 2
50
Example
Input
3 100
Output
0 0 100
"Correct Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n,m = map(int,input().split())
points = ["0"] * n
for i in range(n//2 + 1, n):
points[i] = str(m)
print(" ".join(points))
```
| 64,791 | [
-0.008575439453125,
0.071533203125,
-0.45849609375,
0.0294647216796875,
-0.7041015625,
-0.5380859375,
-0.08819580078125,
-0.082763671875,
-0.155029296875,
1.0126953125,
0.461669921875,
-0.12030029296875,
0.4326171875,
-0.57470703125,
-0.45068359375,
-0.07452392578125,
-0.921875,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Problem statement
N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m.
Since the teacher in charge is nasty, I am concerned about the score distribution that maximizes the difference between the average value and the median value. Output one such way of scoring.
Note: The average value is the sum of the points divided by n, and the median is the (n + 1) / second (1 − indexed) from the front if n is an odd number when the points are arranged in ascending order. If it is an even number, it is the score obtained by adding the n / 2nd and n / 2 + 1th scores from the front and dividing by 2.
input
n \ m
Constraint
* An integer
* 1 ≤ n ≤ 100
* 1 ≤ m ≤ 100
output
Output the n-point column of the answer on a single line separated by spaces, and finally output a line break. If there are multiple types, any one can be output.
sample
Sample input 1
3 100
Sample output 1
0 0 100
100 \ 100 \ 0 etc. are also correct answers.
Sample input 2
1 100
Sample output 2
50
Example
Input
3 100
Output
0 0 100
Submitted Solution:
```
n,m = map(int,input().split())
a = [0 for i in range(n//2)]
for i in range(n-n//2):
a.append(m)
for i in range(n-1):
print(a[i], end = " ")
print(a[n-1])
```
No
| 64,792 | [
0.07147216796875,
-0.062744140625,
-0.39794921875,
0.06878662109375,
-0.6201171875,
-0.480224609375,
-0.15185546875,
-0.09918212890625,
-0.09844970703125,
1.18359375,
0.44384765625,
-0.06146240234375,
0.31982421875,
-0.599609375,
-0.37060546875,
-0.076416015625,
-0.84228515625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
q = deque()
i = 0
while i < n:
if i == 0:
q.append(a[i])
i += 1
else:
if i < n - 1:
q.append(a[i])
q.appendleft(a[i + 1])
i += 2
else:
q.append(a[i])
i += 1
q.append(q[0])
for i in range(1, n):
if q[i - 1] + q[i + 1] <= q[i]:
print('NO')
exit()
print('YES')
print(*list(q)[:-1])
```
Yes
| 64,903 | [
0.332763671875,
0.1468505859375,
0.016357421875,
-0.16650390625,
-0.4755859375,
-0.2486572265625,
-0.1302490234375,
0.261962890625,
0.29443359375,
1.0986328125,
0.76171875,
0.0679931640625,
0.1317138671875,
-0.337646484375,
-0.8671875,
0.14208984375,
-0.68603515625,
-0.64697265625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
n=int(input())
a=sorted(map(int,input().split()))
ans=[0]*n; l=0; r=1
for i in range(n):
if i%2:
ans[n-r]=a[i]
r+=1
else:
ans[l]=a[i]
l+=1
for i in range(n):
if ans[i-1]+ans[(i+1)%n]<=ans[i]:
print("NO"); exit()
print("YES"); print(*ans)
```
Yes
| 64,904 | [
0.377197265625,
0.06378173828125,
0.0186309814453125,
-0.119140625,
-0.486572265625,
-0.392822265625,
-0.10833740234375,
0.273193359375,
0.14501953125,
1.0390625,
0.75439453125,
0.03289794921875,
0.10614013671875,
-0.38671875,
-0.8759765625,
0.0819091796875,
-0.79833984375,
-0.7207... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
length = int(input())
rawInput = input()
parsedInput = rawInput.split(' ')
parsedInput = [ int(x) for x in parsedInput ]
parsedInput.sort(reverse=True)
def swap(i):
if(i==length - 1):
temp = parsedInput[0]
parsedInput[0] = parsedInput[i]
parsedInput[i] = temp
else:
temp = parsedInput[i]
parsedInput[i] = parsedInput[i + 1]
parsedInput[i + 1] = temp
i = 0
if(parsedInput[length - 1] + parsedInput[1] > parsedInput[0]):
print("YES")
print(' '.join(str(x) for x in parsedInput))
else:
while True:
swap(i)
i += 1
if(i==length):
print("NO")
break
if(parsedInput[i - 1] + parsedInput[(i + 1) % length] > parsedInput[i]):
print("YES")
print(' '.join(str(x) for x in parsedInput))
break
```
Yes
| 64,905 | [
0.36181640625,
0.00984954833984375,
0.0006084442138671875,
-0.08477783203125,
-0.49951171875,
-0.347412109375,
-0.05328369140625,
0.2254638671875,
0.1336669921875,
1.0751953125,
0.75390625,
0.04217529296875,
0.10888671875,
-0.496337890625,
-0.89404296875,
0.043426513671875,
-0.819335... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
from sys import stdin,stdout
for _ in range(1):#int(stdin.readline())):
n=int(stdin.readline())
a=list(map(int,stdin.readline().split()))
a.sort()
if a[-1]>=a[-2]+a[-3]:print('NO')
else:
print('YES')
a[-1],a[-2]=a[-2],a[-1]
print(*a)
```
Yes
| 64,906 | [
0.3408203125,
0.056427001953125,
0.06768798828125,
-0.1199951171875,
-0.54150390625,
-0.396728515625,
-0.1708984375,
0.240234375,
0.080810546875,
1.1162109375,
0.71826171875,
-0.0053863525390625,
0.1553955078125,
-0.364501953125,
-0.8740234375,
0.0201873779296875,
-0.783203125,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
if nums[-1] >= nums[-2] + nums[-3]:
print('NO')
else:
print('YES')
print(*nums[-1:0:-2], *nums[0:n:2])
```
No
| 64,907 | [
0.398681640625,
0.10736083984375,
-0.06671142578125,
-0.12078857421875,
-0.469970703125,
-0.382080078125,
-0.10040283203125,
0.25732421875,
0.146240234375,
1.068359375,
0.74560546875,
0.04278564453125,
0.16015625,
-0.371337890625,
-0.91650390625,
0.0572509765625,
-0.79296875,
-0.75... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
def main():
n = int(input())
arr = [int(i) for i in input().split()]
q = sorted(arr)
z = q[0::2] + q[1::2]
if q[-1] < q[-2] + q[-3]:
print("YES")
print(" ".join([str(i) for i in z]))
else:
print("NO")
if __name__ == "__main__":
main()
```
No
| 64,908 | [
0.3701171875,
0.0576171875,
-0.026031494140625,
-0.10443115234375,
-0.51318359375,
-0.38623046875,
-0.12744140625,
0.298095703125,
0.1468505859375,
1.0771484375,
0.72265625,
0.04736328125,
0.0972900390625,
-0.35791015625,
-0.89892578125,
0.0841064453125,
-0.8310546875,
-0.723632812... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
from math import *
from collections import *
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort()
if(a[-2]+a[0]>a[-1]):
print("YES")
print(*a)
elif(a[-3]+a[-2]>a[-1]):
print("YES")
a[-2],a[-1]=a[-1],a[-2]
else:
print("NO")
```
No
| 64,909 | [
0.34716796875,
0.099853515625,
-0.0235748291015625,
-0.152587890625,
-0.52197265625,
-0.36279296875,
-0.11737060546875,
0.28857421875,
0.184814453125,
1.076171875,
0.71875,
0.0062255859375,
0.1348876953125,
-0.351318359375,
-0.88525390625,
0.048004150390625,
-0.80419921875,
-0.7270... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n numbers a_1, a_2, …, a_n. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?
For example, for the array [1, 4, 5, 6, 7, 8], the arrangement on the left is valid, while arrangement on the right is not, as 5≥ 4 + 1 and 8> 1 + 6.
<image>
Input
The first line contains a single integer n (3≤ n ≤ 10^5) — the number of numbers.
The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
Output
If there is no solution, output "NO" in the first line.
If there is a solution, output "YES" in the first line. In the second line output n numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.
Examples
Input
3
2 4 3
Output
YES
4 2 3
Input
5
1 2 3 4 4
Output
YES
4 4 2 1 3
Input
3
13 8 5
Output
NO
Input
4
1 10 100 1000
Output
NO
Note
One of the possible arrangements is shown in the first example:
4< 2 + 3;
2 < 4 + 3;
3< 4 + 2.
One of the possible arrangements is shown in the second example.
No matter how we arrange 13, 8, 5 in a circle in the third example, 13 will have 8 and 5 as neighbors, but 13≥ 8 + 5.
There is no solution in the fourth example.
Submitted Solution:
```
#!/usr/bin/env python3
n = int(input())
a = input().split()
a.sort()
if int(a[n-2]) + int(a[n-3]) > int(a[n-1]):
a[n-1], a[n-2] = a[n-2], a[n-1]
print('YES')
for i in a:
print(i, end = ' ', flush = True)
else:
print('NO')
```
No
| 64,910 | [
0.3798828125,
0.045867919921875,
-0.033660888671875,
-0.1353759765625,
-0.5224609375,
-0.373779296875,
-0.0867919921875,
0.28955078125,
0.1888427734375,
1.0576171875,
0.70361328125,
0.017242431640625,
0.13037109375,
-0.391357421875,
-0.88427734375,
0.051727294921875,
-0.78466796875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
from collections import deque
from math import inf
def value(my_pos, sub):
sublen = len(sub)
size = sublen - my_pos
ans = inf
for i in range(sublen - size + 1):
curr = max(sub[i], sub[i+size-1])
ans = min(ans, curr)
return ans
def solve():
n, my_pos, no_of_infl = map(int, input().split())
arr = list(map(int, input().split()))
no_of_infl = min(no_of_infl, my_pos-1)
size = n - no_of_infl
my_pos -= no_of_infl + 1
ans = 0
sub = deque(arr[:size])
ans = max(ans, value(my_pos, sub))
for i in range(size, n):
sub.popleft()
sub.append(arr[i])
ans = max(ans, value(my_pos, sub))
return ans
for _ in range(int(input())):
print(solve())
```
Yes
| 64,967 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
for i in range(int(input())):
n,m,k=map(int,input().split())
k =min(k,m-1)
a = list(map(int,input().split()))
b = [max(a[i],a[i+n-m]) for i in range(0,m)]
x = max((min(b[i:i+(m-k)])) for i in range(k+1))
print(x)
```
Yes
| 64,968 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
for _ in range(int(input())):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
mn = min(k,m-1)
x,y = m-1,n-m
ans = -1
for i in range(mn+1):
val = float('inf')
for j in range(m-mn):
v = max(a[i+j],a[n-(m-i-j)])
val = min(val,v)
ans = max(ans,val)
print(ans)
```
Yes
| 64,969 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
from collections import deque
def main():
t = int(input().strip())
for _ in range(t):
n, m, k = [int(s) for s in input().strip().split()]
A = [int(s) for s in input().strip().split()]
k = min(k, m - 1)
B = []
for i in range(m):
j = i + n - m
B.append(max(A[i], A[j]))
# print(B)
result = float("-inf")
dq = deque()
for i in range(len(B) - k - 1):
while dq and dq[-1] > B[i]:
dq.pop()
dq.append(B[i])
for i in range(len(B) - k - 1, len(B)):
while dq and dq[-1] > B[i]:
dq.pop()
dq.append(B[i])
# print(dq)
result = max(result, dq[0])
if dq[0] == B[i - len(B) + k + 1]:
dq.popleft()
print(result)
main()
```
Yes
| 64,970 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
# Legends Always Come Up with Solution
# Author: Manvir Singh
import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf,gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit
def solve():
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
if k>=m-1:
return(max(max(a[:m]),max(a[n-m:])))
elif k==0:
a=deque(a)
for i in range(1,m):
if a[0]>a[-1]:
a.popleft()
else:
a.pop()
return max(a[0],a[-1])
else:
ma=0
for i in range(1,k+1):
b=deque(a[i:n-(k-i)])
for j in range(k+1,m):
if b[0]>b[-1]:
b.popleft()
else:
b.pop()
ma=max(ma,b[0],b[-1])
return ma
def main():
for _ in range(int(input())):
print(solve())
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
```
No
| 64,971 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
t = int(input().rstrip())
for i in range(t):
n, m, k = map(int, input().rstrip().split())
k = min(k, m-1)
nums = list(map(int, input().rstrip().split()))
pk = tuple(max(nums[i], nums[i+(n-m)]) for i in range(m));print(pk)
best = 0
for j in range(k+1):
best = max(best, min(pk[j:j+m-k]))
print(best)
```
No
| 64,972 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
def zip_sorted(a,b):
# sorted by a
a,b = zip(*sorted(zip(a,b)))
# sorted by b
sorted(zip(a, b), key=lambda x: x[1])
return a,b
import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
S = lambda : list(map(str,input().split()))
t,=I()
for t1 in range(t):
n,m,k = I()
a = I()
a = [0]+a
dp = [0]*(m)
for i in range(m):
dp[i] = max(a[i+1],a[n-m+i+1])
max1 = 0
for i in range(len(dp)):
min1 = dp[i]
for j in range(i,len(dp)):
if (i+len(dp)-j-1)<=k:
min1 = min(min1,dp[j])
max1 = max(max1,min1)
print(max1)
```
No
| 64,973 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You and your n - 1 friends have found an array of integers a_1, a_2, ..., a_n. You have decided to share it in the following way: All n of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps it for himself. He then gets out of line, and the next person in line continues the process.
You are standing in the m-th position in the line. Before the process starts, you may choose up to k different people in the line, and persuade them to always take either the first or the last element in the array on their turn (for each person his own choice, not necessarily equal for all people), no matter what the elements themselves are. Once the process starts, you cannot persuade any more people, and you cannot change the choices for the people you already persuaded.
Suppose that you're doing your choices optimally. What is the greatest integer x such that, no matter what are the choices of the friends you didn't choose to control, the element you will take from the array will be greater than or equal to x?
Please note that the friends you don't control may do their choice arbitrarily, and they will not necessarily take the biggest element available.
Input
The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three space-separated integers n, m and k (1 ≤ m ≤ n ≤ 3500, 0 ≤ k ≤ n - 1) — the number of elements in the array, your position in line and the number of people whose choices you can fix.
The second line of each test case contains n positive integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — elements of the array.
It is guaranteed that the sum of n over all test cases does not exceed 3500.
Output
For each test case, print the largest integer x such that you can guarantee to obtain at least x.
Example
Input
4
6 4 2
2 9 2 3 8 5
4 4 1
2 13 60 4
4 1 3
1 2 2 1
2 2 0
1 2
Output
8
4
1
1
Note
In the first test case, an optimal strategy is to force the first person to take the last element and the second person to take the first element.
* the first person will take the last element (5) because he or she was forced by you to take the last element. After this turn the remaining array will be [2, 9, 2, 3, 8];
* the second person will take the first element (2) because he or she was forced by you to take the first element. After this turn the remaining array will be [9, 2, 3, 8];
* if the third person will choose to take the first element (9), at your turn the remaining array will be [2, 3, 8] and you will take 8 (the last element);
* if the third person will choose to take the last element (8), at your turn the remaining array will be [9, 2, 3] and you will take 9 (the first element).
Thus, this strategy guarantees to end up with at least 8. We can prove that there is no strategy that guarantees to end up with at least 9. Hence, the answer is 8.
In the second test case, an optimal strategy is to force the first person to take the first element. Then, in the worst case, both the second and the third person will take the first element: you will end up with 4.
Submitted Solution:
```
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def RL(): return map(int, sys.stdin.readline().rstrip().split())
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
# ------------------------------
def main():
for _ in range(N()):
n, m, k = RL()
arr = list(RL())
ret = float('-inf')
for i in range(min(k+1, m)):
e = n-(k-i)-1
pt = max(m-k-1, 0)
res = float('inf')
# print(i, e, pt)
for j in range(pt+1):
nb = i+j
ne = e-(pt-j)
res = min(res, max(arr[nb], arr[ne]))
ret = max(res, ret)
print(ret)
# if m==1:
# print(max(arr[0], arr[-1]))
# else:
# res = []
# for i in range(n):
# if m==2:
# b = 2
# else:
# b = 1
#
# sf = i+(n-(m-2))-b
# # print(i, sf)
# if sf>=n: break
# res.append((min(arr[i], arr[sf]), i))
# # print(res)
# res.sort(key=lambda a: min(n-a[1], a[1]))
if __name__ == "__main__":
main()
```
No
| 64,974 | [
0.4169921875,
-0.0266876220703125,
-0.0178680419921875,
0.3642578125,
-0.63427734375,
-0.75537109375,
-0.1129150390625,
0.2783203125,
0.311279296875,
0.72705078125,
0.888671875,
-0.2188720703125,
0.375732421875,
-0.54833984375,
-0.62109375,
-0.0211639404296875,
-1.0029296875,
-0.79... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n = int(input())
li = []
for i in range(n):
if all(int(i) <= 0 or int(i) == 2 for i in input().split()):
li.append(i+1)
print(len(li))
print(*li)
```
Yes
| 65,198 | [
0.0170135498046875,
0.56005859375,
0.214111328125,
0.2139892578125,
-0.69873046875,
-0.8427734375,
-0.1943359375,
0.217529296875,
0.23681640625,
0.71142578125,
0.54052734375,
0.33935546875,
-0.287841796875,
-0.7802734375,
-0.6416015625,
0.136474609375,
-0.59814453125,
-0.7065429687... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
#!/usr/bin/python3
n=int(input())
res=list()
for i in range(0,n):
num=map(int,input().split())
if all(map(lambda x:x!=1 and x!=3,num)):
res.append(i+1)
print (len(res))
if len(res) != 0:
print(*res)
```
Yes
| 65,199 | [
0.0350341796875,
0.5888671875,
0.181884765625,
0.17236328125,
-0.69482421875,
-0.81494140625,
-0.2017822265625,
0.2391357421875,
0.253173828125,
0.72607421875,
0.4990234375,
0.332275390625,
-0.280029296875,
-0.7451171875,
-0.64892578125,
0.12890625,
-0.58447265625,
-0.68212890625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n = int(input())
matrix = [list(map(int,input().split())) for i in range(n)]
c = 0
i = 2
j = 1
k = []
for i in range(0,n):
if 1 in matrix[i] or 3 in matrix[i]:
pass
else :
c += 1
k.append(i + 1)
print(c)
print(' ' .join([str(x) for x in k]))
```
Yes
| 65,200 | [
0.015838623046875,
0.52880859375,
0.2178955078125,
0.2078857421875,
-0.7197265625,
-0.8212890625,
-0.1995849609375,
0.2156982421875,
0.213623046875,
0.7109375,
0.53125,
0.3388671875,
-0.253173828125,
-0.7529296875,
-0.60791015625,
0.129150390625,
-0.58837890625,
-0.7060546875,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
import sys
n = int(input())
mat = []
ans = []
for i in range(n):
l = list(map(int, sys.stdin.readline().split()))
mat.append(l)
good = True
for j in range(n):
if l[j] == 1 or l[j] == 3:
good = False
if good:
ans.append(i+1)
num = len(ans)
print(num)
if num > 0:
print(' '.join(map(str, ans)))
```
Yes
| 65,201 | [
0.01216888427734375,
0.57958984375,
0.20849609375,
0.24951171875,
-0.69677734375,
-0.8505859375,
-0.1954345703125,
0.216064453125,
0.2379150390625,
0.71240234375,
0.5283203125,
0.328369140625,
-0.28857421875,
-0.77783203125,
-0.6513671875,
0.1541748046875,
-0.5908203125,
-0.7236328... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n = int(input())
#n, m = map(int, input().split())
#s = input()
a = []
for i in range(1, n):
c = list(map(int, input().split()))
for j in range(n):
if c[j] == 1 or c[j] == 3:
break
else:
a.append(i)
print(len(a))
print(*a)
```
No
| 65,202 | [
0.027374267578125,
0.556640625,
0.196533203125,
0.2149658203125,
-0.71728515625,
-0.82958984375,
-0.2093505859375,
0.22119140625,
0.21484375,
0.7216796875,
0.52587890625,
0.3330078125,
-0.2373046875,
-0.75634765625,
-0.60791015625,
0.1156005859375,
-0.59814453125,
-0.70703125,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n = int(input())
ans = 0
for i in range(n):
l = list(input().split())
if not(l.count("1")) and not(l.count("3")):
ans += 1
print(ans)
```
No
| 65,203 | [
0.038818359375,
0.5478515625,
0.19921875,
0.2176513671875,
-0.73046875,
-0.841796875,
-0.215576171875,
0.25,
0.2393798828125,
0.71240234375,
0.52783203125,
0.347412109375,
-0.276123046875,
-0.75732421875,
-0.62060546875,
0.1429443359375,
-0.59765625,
-0.71923828125,
-0.4750976562... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n = int(input())
A = []
for i in range(n):
A.append(list(map(int,input().split())))
B = [1] * n
for i in range(n):
for j in range(n):
if A[i][j] == 1:
B[i] = 0
elif A[i][j] == 2:
B[j] = 0
elif A[i][j] == 3:
B[j] = 0
B[i] = 0
print(sum(B))
# if sum(B) > 0:
# for i in range(n):
# if B[i] > 0:
# print(i+1,end=' ')
```
No
| 65,204 | [
0.01033782958984375,
0.54736328125,
0.20166015625,
0.1922607421875,
-0.71728515625,
-0.81884765625,
-0.206787109375,
0.2210693359375,
0.2337646484375,
0.72412109375,
0.5302734375,
0.33447265625,
-0.283935546875,
-0.765625,
-0.62060546875,
0.12646484375,
-0.59521484375,
-0.719238281... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
* - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
* 0: if no car turned over during the collision.
* 1: if only the i-th car turned over during the collision.
* 2: if only the j-th car turned over during the collision.
* 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
Input
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.
Output
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
Examples
Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
Submitted Solution:
```
n=int(input())
x=[]
y=[0 for i in range(n)]
for i in range(n):
x.append(list(map(int,input().split())))
for i in range(n):
for j in range(n):
if x[i][j]!=-1 and x[i][j]==0:
y[i]+=1
y[j]+=1
elif x[i][j]!=-1 and x[i][j]==1:
y[i]-=1
y[j]+=1
elif x[i][j]!=-1 and x[i][j]==2:
y[j]-=1
y[i]+=1
else:
y[i]-=1
y[j]-=1
ans=[]
for i in range(len(y)):
if y[i]>0:
ans.append(i+1)
print(len(ans))
print(*ans)
```
No
| 65,205 | [
0.0161285400390625,
0.55712890625,
0.2120361328125,
0.22265625,
-0.70947265625,
-0.8369140625,
-0.2030029296875,
0.22705078125,
0.236328125,
0.72216796875,
0.5380859375,
0.342041015625,
-0.280517578125,
-0.765625,
-0.6240234375,
0.1434326171875,
-0.6015625,
-0.712890625,
-0.47485... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
'In Boolean logic, a formula is in conjunctive normal form (CNF) or clausal normal form if it is a conjunction of clauses, where a clause is a disjunction of literals' (cited from https://en.wikipedia.org/wiki/Conjunctive_normal_form)
In the other words, CNF is a formula of type <image>, where & represents a logical "AND" (conjunction), <image> represents a logical "OR" (disjunction), and vij are some boolean variables or their negations. Each statement in brackets is called a clause, and vij are called literals.
You are given a CNF containing variables x1, ..., xm and their negations. We know that each variable occurs in at most two clauses (with negation and without negation in total). Your task is to determine whether this CNF is satisfiable, that is, whether there are such values of variables where the CNF value is true. If CNF is satisfiable, then you also need to determine the values of the variables at which the CNF is true.
It is guaranteed that each variable occurs at most once in each clause.
Input
The first line contains integers n and m (1 ≤ n, m ≤ 2·105) — the number of clauses and the number variables, correspondingly.
Next n lines contain the descriptions of each clause. The i-th line first contains first number ki (ki ≥ 1) — the number of literals in the i-th clauses. Then follow space-separated literals vij (1 ≤ |vij| ≤ m). A literal that corresponds to vij is x|vij| either with negation, if vij is negative, or without negation otherwise.
Output
If CNF is not satisfiable, print a single line "NO" (without the quotes), otherwise print two strings: string "YES" (without the quotes), and then a string of m numbers zero or one — the values of variables in satisfying assignment in the order from x1 to xm.
Examples
Input
2 2
2 1 -2
2 2 -1
Output
YES
11
Input
4 3
1 1
1 2
3 -1 -2 3
1 -3
Output
NO
Input
5 6
2 1 2
3 1 -2 3
4 -3 5 4 6
2 -6 -4
1 5
Output
YES
100010
Note
In the first sample test formula is <image>. One of possible answer is x1 = TRUE, x2 = TRUE.
Submitted Solution:
```
def solve():
n, m = [int(x) for x in input().split()]
variables = {i: None for i in range(-m, m+1)} #values of variables, -x == not x
S = {i: None for i in range(-m, m+1)} #sets variables are included in
E = [{int(x) for x in input().split()[1:]} for k in range(n)] #clauses
stack = []
for k in range(n):
for i in E[k]:
if S[i] is None:
S[i] = k
else:
stack.append((k, i))
stack.extend((S[i], i) for i in range(-m, m+1) if S[-i] is None and S[i] is not None)
def check(v):
if len(v) == 0:
return False
elif len(v) == 1:
i = v.pop()
variables[i] = True
variables[-i] = False
if S[-i] is None:
return True
else:
E[S[-i]].remove(-i)
return check(E[S[-i]])
return True
for v in E:
if not check(v):
print("NO")
return
print("YES")
visited = {k: False for k in range(n)}
def dfs(stack):
while stack:
node, i = stack.pop()
if node is None or visited[node]: continue
visited[node] = True
if variables[i] is None:
variables[i] = True
variables[-i] = False
stack.extend((S[-j], -j) for j in E[node])
dfs(stack)
for k in range(n):
if visited[k]: continue
stack.append((k, E[k].pop()))
dfs(stack)
print(''.join('1' if variables[i] else '0' for i in range(1, m+1)))
solve()
```
No
| 65,206 | [
-0.028167724609375,
-0.270263671875,
0.11480712890625,
0.2841796875,
-0.0083770751953125,
-0.1502685546875,
0.0007905960083007812,
0.0682373046875,
-0.28662109375,
0.79541015625,
0.6240234375,
0.2261962890625,
0.2449951171875,
-1.154296875,
-0.548828125,
-0.0987548828125,
-0.39941406... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=[]
for i,j in zip(a,b):
c.append(i-j)
cm=[i for i in c if i<0]
cp=[i for i in c if i>=0]
cp.sort(reverse=True)
scm=sum(cm)
ans=len(cm)
for i in cp:
if scm>=0:break
ans+=1
scm+=i
if scm<0:ans=-1
print(ans)
```
| 65,459 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
D=[i-j for i,j in zip(a,b)]
c=[i for i in D if i>0]
c.sort()
d=[i for i in D if i<0]
e=sum(d)
if sum(a)<sum(b):
print(-1)
elif len(d)==0:
print(0)
else:
ans=0
for i in c[::-1]:
ans+=1
e+=i
if e>=0:
print(ans+len(d))
exit()
```
| 65,460 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
from collections import deque
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ans=0
m=0
p=0
pl=deque()
for a,b in zip(al,bl):
if a<b:
m+=b-a
ans+=1
else:
p+=a-b
pl.append(a-b)
if m==0:
print(0)
exit()
if m>p:
print(-1)
exit()
pl=sorted(pl)
t=0
while t<m:
t+=pl.pop()
ans+=1
print(ans)
```
| 65,461 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
BA = [b-a for a, b in zip(A, B) if b > a]
AB = sorted([a-b for a, b in zip(A, B) if a > b], reverse=True)
if len(BA) == 0:
print(0)
else:
S = sum(BA)
Sd = 0
for i, ab in enumerate(AB):
Sd += ab
if Sd >= S:
break
if Sd >= S:
print(len(BA)+i+1)
else:
print(-1)
```
| 65,462 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
print(-1)
exit()
diff = [A[i]-B[i] for i in range(N)]
m = 0
cnt = 0
for d in diff:
if d < 0:
m += d
cnt += 1
diff.sort(reverse = 1)
for d in diff:
if m >= 0:
break
m += d
cnt += 1
print(cnt)
```
| 65,463 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[a-b for a,b in zip(A,B)]
plus=[i for i in C if i>=0]
minus=[i for i in C if i<0]
plus.sort(reverse=True)
sum_minus=sum(minus)
ans=len(minus)
for i in plus:
if sum_minus>=0:
break
sum_minus+=i
ans+=1
if sum_minus<0:
ans=-1
print(ans)
```
| 65,464 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
def solve():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [a-b for a,b in zip(A,B)]
if sum(C)<0:
return -1
c = sum([-a for a in C if a<0])
C.sort(reverse=True)
ans = 0
for i in range(N):
if C[i]<0:
ans += 1
continue
if C[i]==0 or c==0:
continue
c = max(c-C[i],0)
ans += 1
return ans
print(solve())
```
| 65,465 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Provide a correct Python 3 solution for this coding contest problem.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
"Correct Solution:
```
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A)<sum(B):
print(-1);exit()
s_ab = sorted(list(i-j for i,j in zip(A,B)))
s = 0
c = 0
for i in s_ab:
if i<0:
s+=i
c+=1
else:
break
s_ab = s_ab[::-1]
for i in s_ab:
if s<0:
s+=i
c+=1
else:
break
print(c)
```
| 65,466 | [
0.30908203125,
0.194091796875,
0.27587890625,
-0.07879638671875,
-0.360107421875,
-0.2330322265625,
-0.344482421875,
0.142822265625,
-0.30859375,
1.0654296875,
0.62939453125,
-0.11175537109375,
0.203369140625,
-1.1396484375,
-0.64013671875,
-0.1561279296875,
-0.90625,
-0.5107421875... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
n,*l=map(int,open(0).read().split())
d=sorted([a-b for a,b in zip(l[:n],l[n:])])+[0]
m=[x for x in d if x<0];s=sum(m)
c=~n-1 if sum(d)<0 else len(m)-1
for i in d[::-1]:
s+=i;c+=1
if s>=0:
break
print(c)
```
Yes
| 65,467 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [a[i] - b[i] for i in range(n)]
if sum(c) < 0:
print(-1)
else:
c.sort()
s = 0
q = 0
for i in range(n):
if c[i] < 0:
s += c[i]
q += 1
else:
break
for i in range(n):
if s >= 0:
print(q)
break
s += c[n-1-i]
q += 1
```
Yes
| 65,468 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
p = 0
m = 0
ans = 0
for i in range(n):
d.append(a[i]-b[i])
if d[-1]>0:
p+= d[-1]
if d[-1]<0:
m-= d[-1]
ans +=1
if p<m:
print(-1)
exit()
d.sort()
d.reverse()
i = 0
while m>0:
m-=d[i]
ans += 1
i += 1
print(ans)
```
Yes
| 65,469 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
n,*d=map(int,open(0).read().split())
f=[d[i]-d[n+i]for i in range(n)]
m=[v for v in f if v<0];p=sorted(v for v in f if v>0)
c=len(m);s=sum(m)
while s<0and p:s+=p.pop();c+=1
print([c,-1][s<0])
```
Yes
| 65,470 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted([a[i]-b[i] for i in range(n)],reverse=True)
if sum(c)<0:
print(-1)
else:
d=[i for i in c if i<0]
cnt=len(d)
d=abs(sum(d))
i=0
while d>0:
d-=c[i]
cnt+=1
print(cnt)
```
No
| 65,471 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
N=int(input())
A=list(map(int,input().split(' ')))
B=list(map(int,input().split(' ')))
plus=[]
minus = 0
ans = 0
if sum(A)<sum(B):
print(-1)
exit()
for a,b in zip(A,B):
if a-b >=0:
plus.append(a-b)
elif a-b<0:
minus += a-b
ans += 1
if minus==0:
print(0)
exit()
sorted(plus,reverse=True)
for i in sorted(plus,reverse=True):
print(i)
minus += i
ans += 1
if minus >=0:
print(ans)
break
```
No
| 65,472 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
N = int(input())
taka = list(map(int,input().split()))
exam = list(map(int,input().split()))
sa = list()
for t,e in zip(taka,exam):
sa.append(t-e)
sa = sorted(sa)
minus = list(filter(lambda x:x<0,sa))
plus = list(filter(lambda x:x>0,sa))
sum_plus = 0
sum_minus = sum(minus)
for idx,p in enumerate(plus[::-1]):
sum_plus += p
if sum_plus>=-sum_minus:
print(idx+1+len(minus))
break
else:
if all([s==0 for s in sa]):
print(0)
else:
print(-1)
```
No
| 65,473 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination.
Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness.
For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions:
* The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal.
* For every i, B_i \leq C_i holds.
If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Constraints
* 1 \leq N \leq 10^5
* 1 \leq A_i \leq 10^9
* 1 \leq B_i \leq 10^9
* A_i and B_i are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_{N}
B_1 B_2 ... B_{N}
Output
Print the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the conditions. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
Examples
Input
3
2 3 5
3 4 1
Output
3
Input
3
2 3 3
2 2 1
Output
0
Input
3
17 7 1
25 6 14
Output
-1
Input
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
Output
5
Submitted Solution:
```
import numpy as np
from collections import deque
import sys
N=int(input())
A=np.array([int(i) for i in input().split()])
B=np.array([int(i) for i in input().split()])
C = A-B
minus_idx=np.where(C<0)
plus_idx=np.where(C>0)
minus = np.sum(C[minus_idx])
plus = deque(np.sort(C[plus_idx]))
len_plus = len(plus)
if len_plus == 0:
print(-1)
sys.exit()
count = 0
while minus<0:
minus += plus.pop()
count += 1
len_plus -= 1
if len_plus == 0:
print(-1)
sys.exit()
print(len(minus_idx[0])+count)
```
No
| 65,474 | [
0.32958984375,
0.158203125,
0.25341796875,
-0.01299285888671875,
-0.339111328125,
-0.15478515625,
-0.286865234375,
0.10125732421875,
-0.27294921875,
1.0634765625,
0.58740234375,
-0.03204345703125,
0.1572265625,
-1.048828125,
-0.6982421875,
-0.1259765625,
-0.79296875,
-0.5009765625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
n=input()
n=int(n)
s=""
for i in range(1,n+1):
if i%3==0:
s+=" "+str(i)
elif "3" in list(str(i)):
s+=" "+str(i)
print(s)
```
Yes
| 65,602 | [
0.0128173828125,
-0.4052734375,
-0.137939453125,
-0.017730712890625,
-0.333984375,
-0.3310546875,
-0.02947998046875,
0.383544921875,
-0.0018262863159179688,
0.744140625,
0.498046875,
-0.115966796875,
0.1795654296875,
-1.0556640625,
-0.492431640625,
-0.11871337890625,
-0.302734375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
N = int(input())
result = ' '.join([str(c) for c in range(1, N + 1)
if c % 3 == 0 or '3' in str(c)])
print(' ' + result)
```
Yes
| 65,603 | [
0.024322509765625,
-0.416015625,
-0.1063232421875,
0.007198333740234375,
-0.309814453125,
-0.384765625,
-0.005123138427734375,
0.36865234375,
0.0117340087890625,
0.72509765625,
0.54541015625,
-0.09375,
0.1396484375,
-1.0810546875,
-0.480224609375,
-0.1160888671875,
-0.302978515625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
#1から入力数までで3で割り切れる数と3が入ってるかずを出力する
for i in range(1,int(input()) + 1):
if "3" in str(i) or i % 3 == 0:print(" " + str(i),end="")
print()
```
Yes
| 65,604 | [
0.00433349609375,
-0.411376953125,
-0.1414794921875,
-0.049560546875,
-0.28759765625,
-0.344970703125,
0.014556884765625,
0.34521484375,
0.031951904296875,
0.74755859375,
0.53125,
-0.07501220703125,
0.1546630859375,
-1.1044921875,
-0.53564453125,
-0.1468505859375,
-0.31396484375,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
n = int(input())
for i in range(3, n+1):
if i % 3 == 0 or "3" in str(i):
print("", i, end="")
print()
```
Yes
| 65,605 | [
0.039459228515625,
-0.40771484375,
-0.132568359375,
-0.053924560546875,
-0.283935546875,
-0.330810546875,
0.0012941360473632812,
0.369384765625,
0.01544952392578125,
0.7646484375,
0.5185546875,
-0.0946044921875,
0.1661376953125,
-1.048828125,
-0.4609375,
-0.12078857421875,
-0.2827148... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
# coding: utf-8
num = int(input())
i = 0
print(" ",end="")
while (i != num):
i+=1
if i % 3 == 0:
print(i, end="")
if i != num:
print(" ", end="")
elif "3" in str(i):
print(i, end="")
if i != num:
print(" ",end="")
```
No
| 65,606 | [
-0.005157470703125,
-0.38525390625,
-0.1766357421875,
-0.037078857421875,
-0.306884765625,
-0.366943359375,
0.0989990234375,
0.3466796875,
-0.032989501953125,
0.734375,
0.51611328125,
-0.085693359375,
0.17724609375,
-1.0146484375,
-0.51416015625,
-0.1195068359375,
-0.28173828125,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
def call(n):
i = 1
while i <= n:
if i % 3 == 0:
print(' {}'.format(i),end='')
elif i % 10 == 3:
print(' {}'.format(i),end='')
i += 1
call(int(input()))
```
No
| 65,607 | [
0.046966552734375,
-0.3935546875,
-0.191162109375,
0.021087646484375,
-0.264892578125,
-0.318359375,
0.047576904296875,
0.43017578125,
0.0092010498046875,
0.73828125,
0.50634765625,
-0.1094970703125,
0.229248046875,
-1.0146484375,
-0.435302734375,
-0.056121826171875,
-0.31982421875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
n=int(input())
for i in range(1,n):
if i%3==0:
print(i,end=" ")
elif str(i).find("3")>-1:
print(i,end=" ")
```
No
| 65,608 | [
0.02734375,
-0.40283203125,
-0.1295166015625,
-0.0335693359375,
-0.296875,
-0.328369140625,
-0.01285552978515625,
0.3857421875,
0.0219573974609375,
0.771484375,
0.51171875,
-0.104248046875,
0.17236328125,
-1.0390625,
-0.45263671875,
-0.0863037109375,
-0.281494140625,
-0.71337890625... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.
Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto.
Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements.
void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;
cout << endl;
}
Constraints
* 3 ≤ n ≤ 10000
Input
An integer n is given in a line.
Output
Print the output result of the above program for given integer n.
Example
Input
30
Output
3 6 9 12 13 15 18 21 23 24 27 30
Submitted Solution:
```
input("")
print(3 6 9 12 13 15 18 21 23 24 27 30)
```
No
| 65,609 | [
0.043365478515625,
-0.34619140625,
-0.11358642578125,
-0.012786865234375,
-0.32177734375,
-0.320556640625,
-0.0200347900390625,
0.367919921875,
-0.0009226799011230469,
0.7421875,
0.494140625,
-0.061309814453125,
0.11810302734375,
-0.9921875,
-0.455078125,
-0.11846923828125,
-0.262939... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.
Input
The only line contains three integers n, a and b (0 ≤ a, b < n ≤ 100).
Output
Print the single number — the number of the sought positions.
Examples
Input
3 1 1
Output
2
Input
5 2 3
Output
3
Note
The possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).
In the second sample they are 3, 4 and 5.
Submitted Solution:
```
import sys,os,io,time,copy
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
import math
def main():
# start=time.time()
n,a,b=map(int,input().split())
res=0
for i in range(1,n+1):
if n-i>=a and i-1<=b:
res+=1
print(res)
# end=time.time()
main()
```
Yes
| 65,717 | [
0.39404296875,
-0.2322998046875,
-0.1337890625,
0.306396484375,
-0.44921875,
-0.51123046875,
-0.170654296875,
0.46875,
0.24365234375,
0.65478515625,
0.72314453125,
-0.255859375,
0.1796875,
-0.2587890625,
-0.49609375,
-0.129638671875,
-0.701171875,
-0.859375,
-0.32666015625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n,m = map(int,input().split())
a = [input() for i in range(n)]
a = [[a[i][j] for j in range(m)] for i in range(n)]
res = []
for x in range(0,n,2):
for y in range(0,m,2):
if x<n-1:
if y<m-1:
i,j = x,y
else:
i,j = x,y-1
else:
if y<m-1:
i,j = x-1,y
else:
i,j = x-1,y-1
tmp = int(a[i][j]) + int(a[i+1][j]) + int(a[i][j+1]) + int(a[i+1][j+1])
if tmp==1:
if a[i][j] == "1":
res.append((i,j,i,j))
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
elif a[i+1][j] == "1":
res.append((i+1,j,i,j))
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j+1] == "1":
res.append((i,j+1,i,j))
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i+1][j+1] == "1":
res.append((i+1,j+1,i,j))
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
elif tmp==2:
if a[i][j]=="1" and a[i+1][j]=="1":
res.append((i,j+1,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j]=="1" and a[i][j+1]=="1":
res.append((i+1,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i+1][j]=="1" and a[i][j+1]=="1":
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
elif a[i+1][j]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i,j+1,i,j))
elif a[i][j+1]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i+1,j,i,j))
elif tmp==3:
if a[i][j]=="0":
res.append((i+1,j+1,i,j))
elif a[i+1][j]=="0":
res.append((i,j+1,i,j))
elif a[i][j+1]=="0":
res.append((i+1,j,i,j))
else:
res.append((i,j,i,j))
elif tmp==4:
res.append((i,j,i,j))
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
res.append((i+1,j+1,i,j))
a[i][j],a[i+1][j],a[i][j+1],a[i+1][j+1]="0","0","0","0"
print(len(res))
assert len(res)<=3*n*m
for x,y,bx,by in res:
#print(x,y,bx,by)
tmp = []
d_x = bx + (1-((x-bx)%2))
d_y = by + (1-((y-by)%2))
for i in range(2):
for j in range(2):
if bx+i!=d_x or by+j!=d_y:
tmp.append(bx+i+1)
tmp.append(by+j+1)
print(*tmp)
```
Yes
| 65,794 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
def multiLineArrayOfArraysPrint(arr):
print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
def fix2by2(x,y): #x,y are the coordinates of the bottom left corner
cnt=0
for i in range(x,x+2):
for j in range(y,y+2):
if arr[i][j]==1:
cnt+=1
if cnt==0:
return []
if cnt==1:
return fixOne(x,y)
if cnt==2:
return fixTwo(x,y)
if cnt==3:
return fixThree(x,y)
if cnt==4:
return fixFour(x,y)
def getOneTwoThreeFour(x,y):
blx=x+1
bly=y+1
one=[blx+1,bly,blx,bly,blx,bly+1]
two=[blx,bly,blx,bly+1,blx+1,bly+1]
three=[blx,bly+1,blx+1,bly+1,blx+1,bly]
four=[blx,bly,blx+1,bly,blx+1,bly+1]
return [one,two,three,four]
def fixOne(x,y):
one,two,three,four=getOneTwoThreeFour(x,y)
if arr[x][y]==1:return [one,two,four]
if arr[x+1][y]==1:return [one,three,four]
if arr[x+1][y+1]==1:return[two,three,four]
if arr[x][y+1]==1:return[one,two,three]
def fixTwo(x,y):
one,two,three,four=getOneTwoThreeFour(x,y)
if arr[x][y]==arr[x][y+1]==1:return [three,four]
if arr[x][y]==arr[x+1][y]==1:return [two,three]
if arr[x][y]==arr[x+1][y+1]==1:return [one,three]
if arr[x+1][y]==arr[x+1][y+1]==1:return [one,two]
if arr[x][y+1]==arr[x+1][y+1]==1:return [one,four]
if arr[x+1][y]==arr[x][y+1]==1:return [two,four]
def fixThree(x,y):
one,two,three,four=getOneTwoThreeFour(x,y)
if arr[x][y]==0:return [three]
if arr[x+1][y]==0:return [two]
if arr[x][y+1]==0:return [four]
if arr[x+1][y+1]==0:return [one]
def fixFour(x,y):
one,two,three,four=getOneTwoThreeFour(x,y)
return [one,two,three,four]
import sys
input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.
t=int(input())
for _ in range(t):
n,m=[int(x) for x in input().split()]
arr=[]
for _ in range(n):
arr.append([int(x) for x in list(input())])
# arrTest=[x.copy() for x in arr]
ans=[]
starti=0 if n%2==0 else 1
startj=0 if m%2==0 else 1
if n%2==1 and m%2==1:
starti=1
startj=1
if arr[0][0]==1:
ans.append([1,1,1,2,2,1])
arr[0][0]=0
arr[0][1]=1-arr[0][1]
arr[1][0]=1-arr[1][0]
if n%2==1:
i=0
for j in range(startj,m):
if arr[i][j]==1:
if j==0:
ans.append([i+1,j+1,i+2,j+1,i+2,j+2])
arr[i][j]=0
arr[i+1][j]=1-arr[i+1][j]
arr[i+1][j+1]=1-arr[i+1][j+1]
else:
ans.append([i+1,j+1,i+2,j,i+2,j+1])
arr[i][j]=0
arr[i+1][j]=1-arr[i+1][j]
arr[i+1][j-1]=1-arr[i+1][j-1]
if m%2==1:
j=0
for i in range(starti,n):
if arr[i][j]==1:
if i!=n-1:
ans.append([i+1,j+1,i+1,j+2,i+2,j+2])
arr[i][j]=0
arr[i][j+1]=1-arr[i][j+1]
arr[i+1][j+1]=1-arr[i+1][j+1]
else:
ans.append([i+1,j+1,i+1,j+2,i,j+2])
arr[i][j]=0
arr[i][j+1]=1-arr[i][j+1]
arr[i-1][j+1]=1-arr[i-1][j+1]
for i in range(starti,n,2):
for j in range(startj,m,2):
for res in fix2by2(i,j):
ans.append(res)
print(len(ans))
multiLineArrayOfArraysPrint(ans)
# arr=arrTest
# print('\n')
# for a in ans:
# for i in range(len(a)):
# a[i]-=1
# for x1,y1,x2,y2,x3,y3 in ans:
# arr[x1][y1]=1-arr[x1][y1]
# arr[x2][y2]=1-arr[x2][y2]
# arr[x3][y3]=1-arr[x3][y3]
#
# multiLineArrayOfArraysPrint(arr)
# print('')
```
Yes
| 65,795 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
for _ in range(int(input())):
r, c = map(int, input().split())
a = []
b = []
[a.append(list(input())) for i in range(r)]
for i in range(r - 1):
for j in range(c):
if j == 0 and int(a[i][j]):
a[i][j] = (int(a[i][j]) + 1) % 2
a[i + 1][j] = (int(a[i + 1][j]) + 1) % 2
a[i + 1][j + 1] = (int(a[i + 1][j + 1]) + 1) % 2
b.append([i + 1, j + 1, i + 2, j + 1, i + 2, j + 2])
elif int(a[i][j]):
a[i][j] = (int(a[i][j]) + 1) % 2
a[i + 1][j] = (int(a[i + 1][j]) + 1) % 2
a[i + 1][j - 1] = (int(a[i + 1][j - 1]) + 1) % 2
b.append([i + 1, j + 1, i + 2, j + 1, i + 2, j])
for j in range(c - 1):
i = r - 1
if int(a[-1][j]):
b.append([i, j + 1, i + 1, j + 1, i + 1, j + 2])
b.append([i, j + 1, i, j + 2, i + 1, j + 1])
b.append([i + 1, j + 2, i + 1, j + 1, i, j + 2])
if int(a[-1][-1]):
i = r - 1
j = c - 1
b.append([i + 1, j + 1, i, j + 1, i + 1, j])
b.append([i, j + 1, i + 1, j + 1, i, j])
b.append([i + 1, j, i + 1, j + 1, i, j])
print(len(b))
for i in b:
print(*i)
```
Yes
| 65,796 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
read = lambda: map(int, input().split())
t = int(input())
for _ in range(t):
n, m = read()
a = [list(map(int, input())) for i in range(n)]
def add(x, y, z):
a[x[0]][x[1]] ^= 1
a[y[0]][y[1]] ^= 1
a[z[0]][z[1]] ^= 1
ans.append(' '.join(map(lambda x: str(x + 1), (x[0], x[1], y[0], y[1], z[0], z[1]))))
ans = []
for i in range(n - 1, 1, -1):
for j in range(m):
if a[i][j]:
add((i, j), (i - 1, j), (i - 1, j + (1 if j < m - 1 else -1)))
for j in range(m - 1, 1, -1):
for i in (0, 1):
if a[i][j]:
add((i, j), (0, j - 1), (1, j - 1))
for i in (0, 1):
for j in (0, 1):
s = a[0][0] + a[0][1] + a[1][0] + a[1][1]
if (s + a[i][j]) % 2:
add((i ^ 1, j), (i, j ^ 1), (i ^ 1, j ^ 1))
print(len(ans))
print('\n'.join(ans))
```
Yes
| 65,797 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n,m = map(int,input().split())
a = [input() for i in range(n)]
a = [[a[i][j] for j in range(m)] for i in range(n)]
res = []
for x in range(0,n,2):
for y in range(0,m,2):
if x<n-1:
if y<m-1:
i,j = x,y
else:
i,j = x,y-1
else:
if y<m-1:
i,j = x-1,y
else:
i,j = x-1,y-1
tmp = int(a[i][j]) + int(a[i+1][j]) + int(a[i][j+1]) + int(a[i+1][j+1])
if tmp==1:
if a[i][j] == "1":
res.append((i,j,i,j))
res.append((i+1,j,i,j))
res.append((j+1,i,i,j))
elif a[i+1][j] == "1":
res.append((i+1,j,i,j))
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j+1] == "1":
res.append((i,j+1,i,j))
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i+1][j+1] == "1":
res.append((i+1,j+1,i,j))
res.append((i+1,j,i,j))
res.append((j+1,i,i,j))
elif tmp==2:
if a[i][j]=="1" and a[i+1][j]=="1":
res.append((i,j+1,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j]=="1" and a[i][j+1]=="1":
res.append((i+1,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i][j]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i+1,j+1,i,j))
elif a[i+1][j]=="1" and a[i][j+1]=="1":
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
elif a[i+1][j]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i,j+1,i,j))
elif a[i][j+1]=="1" and a[i+1][j+1]=="1":
res.append((i,j,i,j))
res.append((i+1,j,i,j))
elif tmp==3:
if a[i][j]=="0":
res.append((i+1,j+1,i,j))
elif a[i+1][j]=="0":
res.append((i,j+1,i,j))
elif a[i][j+1]=="0":
res.append((i+1,j,i,j))
else:
res.append((i,j,i,j))
elif tmp==4:
res.append((i,j,i,j))
res.append((i+1,j,i,j))
res.append((i,j+1,i,j))
res.append((i+1,j+1,i,j))
a[i][j],a[i+1][j],a[i][j+1],a[i+1][j+1]="0","0","0","0"
print(len(res))
for x,y,bx,by in res:
#print(x,y,bx,by)
tmp = []
d_x = bx + (1-((x-bx)%2))
d_y = by + (1-((y-by)%2))
for i in range(2):
for j in range(2):
if bx+i!=d_x or by+j!=d_y:
tmp.append(bx+i+1)
tmp.append(by+j+1)
print(*tmp)
```
No
| 65,798 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
def fun3():
x = []
for i1 in range(i,i+2):
for j1 in range(j,j+2):
if l[i1][j1]==1:
x.append(i1+1)
x.append(j1+1)
ans.append(x)
def fun2():
#10
#01
if (l[i][j]==1 and l[i+1][j+1]==1):
x = [i+1,j+1,i+1+1,j+1,i+1,j+1+1]
ans.append(x)
x = [i+1+1,j,i+1,j+1+1,i+1+1,j+1+1]
ans.append(x)
return
if (l[i+1][j]==1 and l[i][j+1]==1):
x = [i+1+1,j+1+1,i+1+1,j+1,i+1,j+1]
ans.append(x)
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1+1]
ans.append(x)
return
#01
#10
if (l[i][j]==1 and l[i+1][j]==1):
x = [i+1+1,j+1+1,i+1+1,j+1,i+1,j+1+1]
ans.append(x)
x = [i+1,j+1,i+2,j+1,i+1,j+2]
ans.append(x)
#10
#10
return
if (l[i][j+1]==1 and l[i+1][j+1]==1):
x = [i+1,j+1,i+1+1,j+1+1,i+1+1,j+1]
ans.append(x)
x = [i+1,j+1,i+1,j+2,i+2,j+1]
ans.append(x)
#01
#01
return
if (l[i][j]==1 and l[i][j+1]==1):
#11
#00
x = [i+1,j+1+1,i+1+1,j+1+1,i+1+1,j+1]
ans.append(x)
x = [i+1,j+1,i+1+1,j+1+1,i+1+1,j+1]
ans.append(x)
return
if (l[i+1][j]==1 and l[i+1][j]==1):
#00
#11
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1]
ans.append(x)
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1+1]
ans.append(x)
return
def fun1():
if (l[i][j]==1):
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1+1]
l[i][j]=0
l[i+1][j]=1
l[i+1][j+1]=1
if (l[i][j+1]==1):
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1+1]
l[i][j]=1
l[i+1][j]=0
l[i+1][j+1]=1
if (l[i+1][j]==1):
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1]
l[i][j]=1
l[i][j+1]=1
l[i+1][j]=0
if (l[i+1][j+1]==1):
x = [i+1,j+1,i+1,j+1+1,i+1+1,j+1+1]
l[i][j]=1
l[i][j+1]=1
l[i+1][j+1]=0
ans.append(x)
fun2()
count=0
def fun4():
x = [i+1,j+1,i+1,j+1,i+1,j+2,i+2,j+2]
ans.append(x)
def fun(block,b):
if (b.count(1)==0):
return
if (b.count(1)==1):
fun1()
return
if (b.count(1)==2):
fun2()
return
if (b.count(1)==3):
fun3()
return
if (b.count(1)==4):
fun4()
return
t = int(input())
for _ in range(t):
n,m = [int(x) for x in input().split()]
l = []
for i in range(n):
a = list(input())
l.append(a)
for i in range(n):
for j in range(m):
l[i][j]=int(l[i][j])
count = 0
ans = []
for i in range(n-1):
for j in range(n-1):
block = l[i:i+2][j:j+2]
b = []
block1 = []
block1.append(l[i][j:j+2])
block1.append(l[i+1][j:j+2])
block = block1[:]
for element in block:
for ele1 in element:
b.append(ele1)
fun(block,b)
l[i][j]=0
l[i+1][j]=0
l[i][j+1]=0
l[i+1][j+1]=0
print(len(ans))
for i in ans:
print(*i)
#print(l)
```
No
| 65,799 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
def flip(i,j):
res=[]
if j==w-1:j-=1
cnt=3
if aa[i][j]:
aa[i][j]=0
cnt-=1
res+=[i+1,j+1]
if aa[i][j+1]:
aa[i][j+1]=0
cnt-=1
res+=[i+1,j+2]
if cnt==2 or aa[i+1][j+1]:
aa[i+1][j]=0
cnt-=1
res+=[i+2,j+1]
if cnt:
aa[i+1][j+1]=0
cnt-=1
res+=[i+2,j+2]
return res
def zero(sj):
ij1=[]
ij0=[]
res=[]
for i in range(h-2,h):
for j in range(sj,sj+2):
if aa[i][j]:ij1.append((i,j))
else:ij0.append((i,j))
if len(ij1)==3:
for i,j in ij1:
aa[i][j]=0
res+=[i+1,j+1]
elif len(ij1)==2:
i,j=ij1[0]
aa[i][j] = 0
res += [i+1, j+1]
for i,j in ij0:
aa[i][j]=0
res+=[i+1,j+1]
else:
i,j=ij1[0]
aa[i][j] = 0
res += [i+1, j+1]
for i,j in ij0[:2]:
aa[i][j]=0
res+=[i+1,j+1]
return res
for _ in range(II()):
h,w=MI()
aa=[[int(c) for c in SI()] for _ in range(h)]
ans=[]
for i in range(h-1):
for j in range(w):
if aa[i][j]:
ans.append(flip(i,j))
for j in range(w-1):
while aa[h-2][j]+aa[h-2][j+1]+aa[h-1][j]+aa[h-1][j+1]:
ans.append(zero(j))
# p2D(aa)
print(len(ans))
for row in ans:
print(*row)
```
No
| 65,800 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).
Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.
It can be proved that it is always possible.
Input
The first line contains a single integer t (1 ≤ t ≤ 5000) — the number of test cases. The next lines contain descriptions of test cases.
The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).
Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.
It is guaranteed that the sum of nm for all test cases does not exceed 20000.
Output
For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.
In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.
Example
Input
5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101
Output
1
1 1 2 1 2 2
2
2 1 3 1 3 2
1 2 1 3 2 3
4
1 1 1 2 2 2
1 3 1 4 2 3
3 2 4 1 4 2
3 3 4 3 4 4
4
1 2 2 1 2 2
1 4 1 5 2 5
4 1 4 2 5 1
4 4 4 5 3 4
2
1 3 2 2 2 3
1 2 2 1 2 2
Note
In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.
In the second test case:
* operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:
011
001
000
* operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:
000
000
000
In the fifth test case:
* operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:
010
110
* operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:
000
000
Submitted Solution:
```
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n,m = map(int,input().split())
l = [[ i for i in input()] for _ in range(n)]
r = []
for i in range(n):
for j in range(m):
if l[i][j]=='1':
#print(i,j)
if i+1>=n or j+1>=m:
l[i][j]='0'
r.append([i-1+1,j-1+1,i+1,j-1+1,i+1,j+1])
r.append([i+1,j-1+1,i+1,j+1,i-1+1,j+1])
r.append([i+1,j+1,i-1+1,j+1,i-1+1,j-1+1])
else:
l[i][j]='0'
r.append([i+1+1,j+1+1,i+1+1,j+1,i+1,j+1])
r.append([i+1+1,j+1,i+1,j+1,i+1,j+1+1])
r.append([i+1,j+1,i+1,j+1+1,i+1+1,j+1+1])
print(len(r))
for i in r:
print(*i)
```
No
| 65,801 | [
0.1719970703125,
0.007114410400390625,
-0.0394287109375,
-0.2083740234375,
-0.61181640625,
-0.351318359375,
-0.07958984375,
-0.036285400390625,
0.1978759765625,
0.8388671875,
0.87060546875,
-0.09039306640625,
0.24853515625,
-0.76416015625,
-0.30908203125,
-0.0297393798828125,
-0.6474... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
t=int(input())
for i in range(t):
n=int(input())
b=[int(x) for x in input().split()]
b.sort()
temp=sum(b[:n])
if b[n]==temp or b[n+1]==temp:
b=[str(x) for x in b]
print(" ".join(b[:n]))
continue
temp=sum(b[:n+1])
flag=False
for i in range(n):
temp1=temp-b[i]
if temp1==b[n+1]:
flag=True
b.pop(i)
break
if flag:
b=[str(x) for x in b]
print(" ".join(b[:n]))
else:
print(-1)
```
Yes
| 65,827 | [
0.5078125,
0.07720947265625,
-0.408203125,
0.11810302734375,
-0.4990234375,
-0.58984375,
-0.223876953125,
0.169921875,
0.1390380859375,
1.076171875,
0.5615234375,
-0.1859130859375,
0.050079345703125,
-0.91845703125,
-0.74365234375,
-0.2147216796875,
-0.60498046875,
-0.75537109375,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
import sys
import math as mt
import collections as cc
import itertools as it
input = sys.stdin.readline
I = lambda:list(map(int,input().split()))
for tc in range(int(input())):
n , = I()
ar = I()
ar.sort()
ans = []
su = sum(ar)
#print(ar)
#print(su)
for i in [len(ar)-1,len(ar)-2]:
tar = ar[i]
now = su - tar
#print(tar,now)
for j in range(len(ar)):
if j!=i:
if now - ar[j] == tar:
ans.append([i,j])
if ans:
#print(ans[0],ar)
for i in range(len(ar)):
if i not in ans[0]:
print(ar[i],end=" ")
print()
else:
print(-1)
```
Yes
| 65,828 | [
0.53076171875,
0.065185546875,
-0.388427734375,
0.130859375,
-0.50146484375,
-0.5205078125,
-0.274658203125,
0.1248779296875,
0.1700439453125,
1.12109375,
0.56640625,
-0.19189453125,
0.058837890625,
-0.88916015625,
-0.77880859375,
-0.1968994140625,
-0.583984375,
-0.783203125,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
for _ in range(int(input())):
n = int(input())
arrB = list(map(int, input().split()))
arrB.sort()
sumB = sum(arrB)
for i in range(n+2):
if i != n+1:
if sumB-arrB[i] == 2*arrB[n+1]:
print(*arrB[:i]+arrB[i+1:n+1])
break
else:
if sumB-arrB[n+1] == 2*arrB[n]:
print(*arrB[:n])
break
else:
print(-1)
```
Yes
| 65,829 | [
0.50390625,
0.01415252685546875,
-0.364990234375,
0.1422119140625,
-0.486083984375,
-0.62890625,
-0.2099609375,
0.149658203125,
0.12841796875,
1.103515625,
0.58837890625,
-0.20068359375,
0.0357666015625,
-0.9169921875,
-0.7431640625,
-0.2095947265625,
-0.630859375,
-0.7431640625,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
import sys
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()
import bisect,string,math,time,functools,random,fractions
from bisect import*
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def I():return int(input())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def AI():return map(int,open(0).read().split())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def NLI(n):return [[int(i) for i in input().split()] for i in range(n)]
def NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]
def RI(a=1,b=10):return random.randint(a,b)
def INP():
N=10
n=random.randint(1,N)
a=RLI(n,0,n-1)
return n,a
def Rtest(T):
case,err=0,0
for i in range(T):
inp=INP()
a1=naive(*inp)
a2=solve(*inp)
if a1!=a2:
print(inp)
print('naive',a1)
print('solve',a2)
err+=1
case+=1
print('Tested',case,'case with',err,'errors')
def GI(V,E,ls=None,Directed=False,index=1):
org_inp=[];g=[[] for i in range(V)]
FromStdin=True if ls==None else False
for i in range(E):
if FromStdin:
inp=LI()
org_inp.append(inp)
else:
inp=ls[i]
if len(inp)==2:a,b=inp;c=1
else:a,b,c=inp
if index==1:a-=1;b-=1
aa=(a,c);bb=(b,c);g[a].append(bb)
if not Directed:g[b].append(aa)
return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
mp=[boundary]*(w+2);found={}
for i in R(h):
s=input()
for char in search:
if char in s:
found[char]=((i+1)*(w+2)+s.index(char)+1)
mp_def[char]=mp_def[replacement_of_found]
mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
mp+=[boundary]*(w+2)
return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
rt=[0]
for i in ls:rt+=[rt[-1]+i]
return rt
def bit_combination(n,base=2):
rt=[]
for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
return rt
def gcd(x,y):
if y==0:return x
if x%y==0:return y
while x%y!=0:x,y=y,x%y
return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
if show_flg:print(*inp,end=end)
mo=10**9+7
#mo=998244353
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
alp=[chr(ord('a')+i)for i in range(26)]
#sys.setrecursionlimit(10**7)
def gcj(c,x):
print("Case #{0}:".format(c+1),x)
########################################################################################################################################################################
# Verified by
# https://yukicoder.me/problems/no/979
# https://atcoder.jp/contests/abc152/tasks/abc152_e
## return prime factors of N as dictionary {prime p:power of p}
## within 2 sec for N = 2*10**20+7
def primeFactor(N):
i,n=2,N
ret={}
d,sq=2,99
while i<=sq:
k=0
while n%i==0:
n,k,ret[i]=n//i,k+1,k+1
if k>0 or i==97:
sq=int(n**(1/2)+0.5)
if i<4:
i=i*2-1
else:
i,d=i+d,d^6
if n>1:
ret[n]=1
return ret
## return divisors of n as list
def divisor(n):
div=[1]
for i,j in primeFactor(n).items():
div=[(i**k)*d for d in div for k in range(j+1)]
return div
## return the list of prime numbers in [2,N], using eratosthenes sieve
## around 800 ms for N = 10**6 by PyPy3 (7.3.0) @ AtCoder
def PrimeNumSet(N):
M=int(N**0.5)
seachList=[i for i in range(2,N+1)]
primes=[]
while seachList:
if seachList[0]>M:
break
primes.append(seachList[0])
tmp=seachList[0]
seachList=[i for i in seachList if i%tmp!=0]
return primes+seachList
## retrun LCM of numbers in list b
## within 2sec for no of B = 10*5 and Bi < 10**6
def LCM(b,mo=10**9+7):
prs=PrimeNumSet(max(b))
M=dict(zip(prs,[0]*len(prs)))
for i in b:
dc=primeFactor(i)
for j,k in dc.items():
M[j]=max(M[j],k)
r=1
for j,k in M.items():
if k!=0:
r*=pow(j,k,mo)
r%=mo
return r
## return (a,b,gcd(x,y)) s.t. a*x+b*y=gcd(x,y)
def extgcd(x,y):
if y==0:
return 1,0
r0,r1,s0,s1 = x,y,1,0
while r1!= 0:
r0,r1,s0,s1=r1,r0%r1,s1,s0-r0//r1*s1
return s0,(r0-s0*x)//y,x*s0+y*(r0-s0*x)//y
## return x,LCM(mods) s.t. x = rem_i (mod_i), x = -1 if such x doesn't exist
## verified by ABC193E
## https://atcoder.jp/contests/abc193/tasks/abc193_e
def crt(rems,mods):
n=len(rems)
if n!=len(mods):
return NotImplemented
x,d=0,1
for r,m in zip(rems,mods):
a,b,g=extgcd(d,m)
x,d=(m*b*x+d*a*r)//g,d*(m//g)
x%=d
for r,m in zip(rems,mods):
if r!=x%m:
return -1,d
return x,d
## returns the maximum integer rt s.t. rt*rt<=x
## verified by ABC191D
## https://atcoder.jp/contests/abc191/tasks/abc191_d
def intsqrt(x):
if x<0:
return NotImplemented
rt=int(x**0.5)-1
while (rt+1)**2<=x:
rt+=1
return rt
class Comb:
def __init__(self,n,mo=10**9+7):
self.fac=[0]*(n+1)
self.inv=[1]*(n+1)
self.fac[0]=1
self.fact(n)
for i in range(1,n+1):
self.fac[i]=i*self.fac[i-1]%mo
self.inv[n]*=i
self.inv[n]%=mo
self.inv[n]=pow(self.inv[n],mo-2,mo)
for i in range(1,n):
self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
return
def fact(self,n):
return self.fac[n]
def invf(self,n):
return self.inv[n]
def comb(self,x,y):
if y<0 or y>x:
return 0
return self.fac[x]*self.inv[x-y]*self.inv[y]%mo
def cat(self,x):
if x<0:
return 0
return self.fac[2*x]*self.inv[x]*self.inv[x+1]%mo
show_flg=False
show_flg=True
ans=0
for _ in range(I()):
n=I()
b=sorted(LI())[::-1]
orb=b[:]
s=sum(b[1:])
x,y=b[:2]
if s-x in b[1:]:
b.remove(s-x)
print(*b[1:])
elif y==s-y:
print(*b[2:])
else:
print(-1)
```
Yes
| 65,830 | [
0.5244140625,
0.0714111328125,
-0.3447265625,
0.1663818359375,
-0.5283203125,
-0.50732421875,
-0.239013671875,
0.1337890625,
0.1524658203125,
1.1123046875,
0.54541015625,
-0.22314453125,
0.072265625,
-0.85986328125,
-0.81005859375,
-0.2451171875,
-0.580078125,
-0.74560546875,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
def isSum(a,sumy,val):
for i in range(len(a)):
if val == sumy-a[i]:
return (True,i)
return (False,0)
for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
arr = sorted(arr)
# print(arr)
cond,ind = isSum(arr[:-1],sum(arr[:-1]),arr[-1])
# print(cond,ind)
if cond:
for i in range(n+1):
if i != ind:
print(arr[i],end=' ')
print()
elif sum(arr[::-2]) == arr[-2] :
for i in range(n+1):
print(arr[i],end=' ')
print()
# print(arr[::-1])
else:
print(-1)
# print(sum(arr))
```
No
| 65,833 | [
0.58544921875,
0.06878662109375,
-0.4033203125,
0.15380859375,
-0.485595703125,
-0.58740234375,
-0.1849365234375,
0.1258544921875,
0.21923828125,
1.0361328125,
0.57275390625,
-0.2276611328125,
0.07427978515625,
-0.90869140625,
-0.76416015625,
-0.1595458984375,
-0.61962890625,
-0.73... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a number n and an array b_1, b_2, …, b_{n+2}, obtained according to the following algorithm:
* some array a_1, a_2, …, a_n was guessed;
* array a was written to array b, i.e. b_i = a_i (1 ≤ i ≤ n);
* The (n+1)-th element of the array b is the sum of the numbers in the array a, i.e. b_{n+1} = a_1+a_2+…+a_n;
* The (n+2)-th element of the array b was written some number x (1 ≤ x ≤ 10^9), i.e. b_{n+2} = x; The
* array b was shuffled.
For example, the array b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:
* a=[2, 2, 3] and x=12;
* a=[3, 2, 7] and x=2.
For the given array b, find any array a that could have been guessed initially.
Input
The first line contains a single integer t (1 ≤ t ≤ 10^4). Then t test cases follow.
The first line of each test case contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
The second row of each test case contains n+2 integers b_1, b_2, …, b_{n+2} (1 ≤ b_i ≤ 10^9).
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
Output
For each test case, output:
* "-1", if the array b could not be obtained from any array a;
* n integers a_1, a_2, …, a_n, otherwise.
If there are several arrays of a, you can output any.
Example
Input
4
3
2 3 7 12 2
4
9 1 7 1 6 5
5
18 2 2 3 2 9 2
3
2 6 9 2 1
Output
2 3 7
-1
2 2 2 3 9
1 2 6
Submitted Solution:
```
import sys
input=sys.stdin.buffer.readline
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a[:n])==a[n+1]:
for i in range(n):
print(a[i],end=' ')
continue
sum_a=sum(a[:n+1])
b=[]
flag=0
for i in range(n+1):
if sum_a-a[i]==max(a):
b=a[:i]+a[i+1:n+2]
flag=1
break
if flag==1:
for i in range(n):
print(b[i],end=' ')
else:
print(-1)
print()
```
No
| 65,834 | [
0.529296875,
0.08563232421875,
-0.343017578125,
0.16748046875,
-0.5439453125,
-0.497314453125,
-0.267578125,
0.1441650390625,
0.1468505859375,
1.0859375,
0.54833984375,
-0.208740234375,
0.06781005859375,
-0.884765625,
-0.82861328125,
-0.2198486328125,
-0.57080078125,
-0.7353515625,... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
a=int(input())
n=list(map(int,input().split()))
chet=0
nechet=0
for i in n:
if i%2==0:
chet+=1
else:
nechet+=1
if chet>nechet:
for i in n:
if i%2!=0:
print(n.index(i)+1)
else:
for i in n:
if i%2==0:
print(n.index(i)+1)
```
Yes
| 65,879 | [
0.40478515625,
0.1796875,
-0.297119140625,
-0.206298828125,
-0.921875,
-0.6298828125,
-0.14453125,
0.14306640625,
-0.035003662109375,
1.3291015625,
0.366943359375,
0.18505859375,
-0.12744140625,
-0.9453125,
-0.4580078125,
-0.29052734375,
-0.87060546875,
-0.68212890625,
-0.4621582... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
n=int(input())
l=[int(x) for x in input().split()]
e=0
o=0
for x in l:
if x%2==0:
e+=1
else:
o+=1
if e==1:
for x in l:
if x%2==0:
print(l.index(x)+1)
break
else:
for x in l:
if x%2!=0:
print(l.index(x)+1)
break
```
Yes
| 65,880 | [
0.38134765625,
0.1253662109375,
-0.1549072265625,
-0.161376953125,
-0.80712890625,
-0.60546875,
-0.1644287109375,
0.0635986328125,
-0.0084228515625,
1.3955078125,
0.34130859375,
0.308837890625,
-0.17919921875,
-0.98583984375,
-0.427490234375,
-0.31005859375,
-0.9169921875,
-0.67480... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
def _25A(numbers):
modulus = list(map(lambda x: x % 2, numbers))
if modulus.count(1) >1:
return(modulus.index(0) + 1)
else:
return(modulus.index(1) + 1)
input()
print(_25A(list(map(lambda x: int(x), input().split()))))
```
Yes
| 65,881 | [
0.4912109375,
0.1756591796875,
-0.188232421875,
-0.08465576171875,
-0.95703125,
-0.45458984375,
-0.1668701171875,
0.1109619140625,
-0.0235595703125,
1.4208984375,
0.2344970703125,
0.104248046875,
-0.2120361328125,
-0.87890625,
-0.35107421875,
-0.173095703125,
-0.7861328125,
-0.5810... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
n=int(input())
number=list(map(int,input().split()))
even=0;odd=0
for i in range(n):
if int(number[i]/2)*2==number[i]:
even+=1
else:
odd+=1
if odd==1:
for i in range(n):
if int(number[i]/2)*2!=number[i]:
print(i+1)
elif even==1:
for i in range(n):
if int(number[i]/2)*2==number[i]:
print(i+1)
```
Yes
| 65,882 | [
0.36083984375,
0.08917236328125,
-0.25048828125,
-0.1893310546875,
-0.84033203125,
-0.5673828125,
-0.1650390625,
0.118408203125,
-0.0005998611450195312,
1.4404296875,
0.337890625,
0.275146484375,
-0.06304931640625,
-0.96240234375,
-0.37939453125,
-0.3916015625,
-0.8828125,
-0.62060... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
if i==0 and a[i]%2!=a[i+1]%2 and a[i]%2!=a[i+2]%2:
print(1)
elif i==n-1 and a[i]%2!=a[i-1]%2 and a[i]%2!=a[i-2]%2:
print(n)
elif i!=0 and i!=2 and a[i]%2!=a[i-1]%2 and a[i]%2!=a[i+1]%2:
print(i+1)
```
No
| 65,883 | [
0.367919921875,
0.1749267578125,
-0.24462890625,
-0.1932373046875,
-0.8896484375,
-0.56884765625,
-0.1968994140625,
0.1510009765625,
-0.038909912109375,
1.3681640625,
0.34912109375,
0.29150390625,
-0.10382080078125,
-0.95361328125,
-0.393798828125,
-0.43603515625,
-0.87353515625,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
n=int(input())
a=list(map(int,input().split()))
o,e=[],[]
for i in range(n):
if a[i]%2==0:
e.append(i)
else:
o.append(i)
if len(o)==1:
print(o[0])
else:
print(e[0])
```
No
| 65,884 | [
0.36279296875,
0.14599609375,
-0.2406005859375,
-0.1873779296875,
-0.91943359375,
-0.6083984375,
-0.1622314453125,
0.129638671875,
-0.02520751953125,
1.376953125,
0.353515625,
0.26171875,
-0.145263671875,
-0.9541015625,
-0.40869140625,
-0.375,
-0.9033203125,
-0.65576171875,
-0.43... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
input()
l = list(map(int,input().split()))
e,o=0,0
b = False
for pos,i in enumerate(l):
if i % 2 == 0:
e += 1
else:
o += 1
if e > 0 and o > 0:
if e > o or o > e:
print(pos)
b = True
if b:
break
```
No
| 65,885 | [
0.414794921875,
0.1829833984375,
-0.231201171875,
-0.2152099609375,
-0.89013671875,
-0.6025390625,
-0.15087890625,
0.138916015625,
-0.0019121170043945312,
1.3505859375,
0.34765625,
0.30712890625,
-0.1033935546875,
-0.9599609375,
-0.4404296875,
-0.371826171875,
-0.90380859375,
-0.62... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.
Input
The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.
Output
Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.
Examples
Input
5
2 4 7 8 10
Output
3
Input
4
1 2 1 1
Output
2
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
v=-1
for i in range(1,n):
for j in range(1,n):
if i!=j and abs(l[0]-l[i])==abs(l[0]-l[j]):
v=0
break
for i in range(n-1):
for j in range(n-1):
if i!=j and abs(l[-1]-l[i])==abs(l[-1]-l[j]):
v=n-1
break
for k in range(1,n-1):
for i in range(n):
for j in range(n):
if i!=j and k!=i and k!=j and abs(l[k]-l[i])==abs(l[k]-l[j]):
v=k
break
print(k)
```
No
| 65,886 | [
0.29345703125,
0.2291259765625,
-0.1451416015625,
-0.1112060546875,
-0.8740234375,
-0.56591796875,
-0.27001953125,
0.0885009765625,
-0.0850830078125,
1.3916015625,
0.327392578125,
0.27587890625,
-0.1318359375,
-0.97900390625,
-0.414794921875,
-0.31640625,
-0.955078125,
-0.653320312... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is a little bit unusual. Here you are to implement an interaction with a testing system. That means that you can make queries and get responses in the online mode. Please be sure to use the stream flushing operation after each query's output in order not to leave part of your output in some buffer. For example, in C++ you've got to use the fflush(stdout) function, in Java — call System.out.flush(), and in Pascal — flush(output).
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking paper and pencil game for two players, predating the similar commercially marketed board game Mastermind.
On a sheet of paper, the first player thinks a secret string. This string consists only of digits and has the length 4. The digits in the string must be all different, no two or more equal digits are allowed.
Then the second player tries to guess his opponent's string. For every guess the first player gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Thus a response is a pair of numbers — the number of "bulls" and the number of "cows". A try can contain equal digits.
More formally, let's the secret string is s and the second player are trying to guess it with a string x. The number of "bulls" is a number of such positions i (1 ≤ i ≤ 4) where s[i] = x[i]. The number of "cows" is a number of such digits c that s contains c in the position i (i.e. s[i] = c), x contains c, but x[i] ≠ c.
For example, the secret string is "0427", the opponent's try is "0724", then the answer is 2 bulls and 2 cows (the bulls are "0" and "2", the cows are "4" and "7"). If the secret string is "0123", the opponent's try is "0330", then the answer is 1 bull and 1 cow.
In this problem you are to guess the string s that the system has chosen. You only know that the chosen string consists of 4 distinct digits.
You can make queries to the testing system, each query is the output of a single 4-digit string. The answer to the query is the number of bulls and number of cows. If the system's response equals "4 0", that means the interaction with your problem is over and the program must terminate. That is possible for two reasons — the program either guessed the number x or made an invalid action (for example, printed letters instead of digits).
Your program is allowed to do at most 50 queries.
You can hack solutions of other participants providing a 4-digit string containing distinct digits — the secret string.
Input
To read answers to the queries, the program must use the standard input.
The program will receive pairs of non-negative integers in the input, one pair per line. The first number in a pair is a number of bulls and the second one is a number of cows of the string s and the string xi printed by your program. If the system response equals "4 0", then your solution should terminate.
The testing system will let your program read the i-th pair of integers from the input only after your program displays the corresponding system query in the output: prints value xi in a single line and executes operation flush.
Output
The program must use the standard output to print queries.
Your program must output requests — 4-digit strings x1, x2, ..., one per line. After the output of each line the program must execute flush operation. The program should read the answer to the query from the standard input.
Your program is allowed to do at most 50 queries.
Examples
Input
0 1
2 0
1 1
0 4
2 1
4 0
Output
8000
0179
3159
3210
0112
0123
Note
The secret string s in the example is "0123".
Submitted Solution:
```
import itertools
def get_all_possibilities(nums):
return [x for x in itertools.permutations(nums)]
def guess_dec():
"""
We can bruteforce this game by trying out all the possible guesses.
In the worst case, there will be 26 guesses.
In the best case, there will be 11 guesses.
First, we make use of the secret digits being "distinct" digis.
We can use identical digits per guess(e.g. "0000", "1111", etc) to
identify all four distict digits.
Once we have all the "cows", we can try out all the possible
combinations of four digits which is 16.
So in total, we can guess the correct combination in 11 guesses if lucky.
If unlucky, we have to consume all 16 possibilities of combinations.
"""
secret_numbers = []
try_outs = []
counter = 0
first_time = True
def inner(bulls, cows):
nonlocal counter, try_outs, secret_numbers, first_time
if bulls > 0:
secret_numbers.append(counter - 1)
if counter < 10:
guess = str(counter) * 4
counter += 1
return guess
# now we have all four digits
if first_time:
try_outs = get_all_possibilities(secret_numbers)
first_time = False
if len(try_outs) > 0:
return try_outs.pop()
return inner
def main():
bulls = 0
cows = 0
guess = guess_dec()
for _ in range(50):
print(guess(bulls, cows))
answer = input()
b, c = answer.split()
bulls = int(b)
cows = int(c)
if bulls == 4 and cows == 0:
break
if __name__ == '__main__':
main()
```
No
| 66,083 | [
0.445068359375,
0.046539306640625,
0.0460205078125,
0.2203369140625,
-0.736328125,
-0.62646484375,
-0.390380859375,
0.25146484375,
-0.006801605224609375,
0.76806640625,
0.6015625,
0.0513916015625,
0.20654296875,
-0.404052734375,
-0.344970703125,
0.0880126953125,
-0.27587890625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is a little bit unusual. Here you are to implement an interaction with a testing system. That means that you can make queries and get responses in the online mode. Please be sure to use the stream flushing operation after each query's output in order not to leave part of your output in some buffer. For example, in C++ you've got to use the fflush(stdout) function, in Java — call System.out.flush(), and in Pascal — flush(output).
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking paper and pencil game for two players, predating the similar commercially marketed board game Mastermind.
On a sheet of paper, the first player thinks a secret string. This string consists only of digits and has the length 4. The digits in the string must be all different, no two or more equal digits are allowed.
Then the second player tries to guess his opponent's string. For every guess the first player gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Thus a response is a pair of numbers — the number of "bulls" and the number of "cows". A try can contain equal digits.
More formally, let's the secret string is s and the second player are trying to guess it with a string x. The number of "bulls" is a number of such positions i (1 ≤ i ≤ 4) where s[i] = x[i]. The number of "cows" is a number of such digits c that s contains c in the position i (i.e. s[i] = c), x contains c, but x[i] ≠ c.
For example, the secret string is "0427", the opponent's try is "0724", then the answer is 2 bulls and 2 cows (the bulls are "0" and "2", the cows are "4" and "7"). If the secret string is "0123", the opponent's try is "0330", then the answer is 1 bull and 1 cow.
In this problem you are to guess the string s that the system has chosen. You only know that the chosen string consists of 4 distinct digits.
You can make queries to the testing system, each query is the output of a single 4-digit string. The answer to the query is the number of bulls and number of cows. If the system's response equals "4 0", that means the interaction with your problem is over and the program must terminate. That is possible for two reasons — the program either guessed the number x or made an invalid action (for example, printed letters instead of digits).
Your program is allowed to do at most 50 queries.
You can hack solutions of other participants providing a 4-digit string containing distinct digits — the secret string.
Input
To read answers to the queries, the program must use the standard input.
The program will receive pairs of non-negative integers in the input, one pair per line. The first number in a pair is a number of bulls and the second one is a number of cows of the string s and the string xi printed by your program. If the system response equals "4 0", then your solution should terminate.
The testing system will let your program read the i-th pair of integers from the input only after your program displays the corresponding system query in the output: prints value xi in a single line and executes operation flush.
Output
The program must use the standard output to print queries.
Your program must output requests — 4-digit strings x1, x2, ..., one per line. After the output of each line the program must execute flush operation. The program should read the answer to the query from the standard input.
Your program is allowed to do at most 50 queries.
Examples
Input
0 1
2 0
1 1
0 4
2 1
4 0
Output
8000
0179
3159
3210
0112
0123
Note
The secret string s in the example is "0123".
Submitted Solution:
```
while True:
print('abcd')
```
No
| 66,084 | [
0.445068359375,
0.046539306640625,
0.0460205078125,
0.2203369140625,
-0.736328125,
-0.62646484375,
-0.390380859375,
0.25146484375,
-0.006801605224609375,
0.76806640625,
0.6015625,
0.0513916015625,
0.20654296875,
-0.404052734375,
-0.344970703125,
0.0880126953125,
-0.27587890625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is a little bit unusual. Here you are to implement an interaction with a testing system. That means that you can make queries and get responses in the online mode. Please be sure to use the stream flushing operation after each query's output in order not to leave part of your output in some buffer. For example, in C++ you've got to use the fflush(stdout) function, in Java — call System.out.flush(), and in Pascal — flush(output).
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking paper and pencil game for two players, predating the similar commercially marketed board game Mastermind.
On a sheet of paper, the first player thinks a secret string. This string consists only of digits and has the length 4. The digits in the string must be all different, no two or more equal digits are allowed.
Then the second player tries to guess his opponent's string. For every guess the first player gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Thus a response is a pair of numbers — the number of "bulls" and the number of "cows". A try can contain equal digits.
More formally, let's the secret string is s and the second player are trying to guess it with a string x. The number of "bulls" is a number of such positions i (1 ≤ i ≤ 4) where s[i] = x[i]. The number of "cows" is a number of such digits c that s contains c in the position i (i.e. s[i] = c), x contains c, but x[i] ≠ c.
For example, the secret string is "0427", the opponent's try is "0724", then the answer is 2 bulls and 2 cows (the bulls are "0" and "2", the cows are "4" and "7"). If the secret string is "0123", the opponent's try is "0330", then the answer is 1 bull and 1 cow.
In this problem you are to guess the string s that the system has chosen. You only know that the chosen string consists of 4 distinct digits.
You can make queries to the testing system, each query is the output of a single 4-digit string. The answer to the query is the number of bulls and number of cows. If the system's response equals "4 0", that means the interaction with your problem is over and the program must terminate. That is possible for two reasons — the program either guessed the number x or made an invalid action (for example, printed letters instead of digits).
Your program is allowed to do at most 50 queries.
You can hack solutions of other participants providing a 4-digit string containing distinct digits — the secret string.
Input
To read answers to the queries, the program must use the standard input.
The program will receive pairs of non-negative integers in the input, one pair per line. The first number in a pair is a number of bulls and the second one is a number of cows of the string s and the string xi printed by your program. If the system response equals "4 0", then your solution should terminate.
The testing system will let your program read the i-th pair of integers from the input only after your program displays the corresponding system query in the output: prints value xi in a single line and executes operation flush.
Output
The program must use the standard output to print queries.
Your program must output requests — 4-digit strings x1, x2, ..., one per line. After the output of each line the program must execute flush operation. The program should read the answer to the query from the standard input.
Your program is allowed to do at most 50 queries.
Examples
Input
0 1
2 0
1 1
0 4
2 1
4 0
Output
8000
0179
3159
3210
0112
0123
Note
The secret string s in the example is "0123".
Submitted Solution:
```
from itertools import permutations
from random import shuffle
try:
raw_input
except:
raw_input = input
try:
from itertools import izip
except:
izip = zip
digits = '0123456789'
size = 4
def parse_score(score):
score = score.strip().split()
return tuple(int(s.strip()) for s in score)
def scorecalc(guess, chosen):
bulls = cows = 0
for g,c in izip(guess, chosen):
if g == c:
bulls += 1
elif g in chosen:
cows += 1
return bulls, cows
choices = list(permutations(digits, size))
shuffle(choices)
answers = []
scores = []
while True:
ans = choices[0]
answers.append(ans)
#print ("(Narrowed to %i possibilities)" % len(choices))
score = raw_input("%*s\n" % (size, ''.join(ans)))
score = parse_score(score)
scores.append(score)
#print("Bulls: %i, Cows: %i" % score)
found = score == (size, 0)
if found:
break
choices = [c for c in choices if scorecalc(c, ans) == score]
if not choices:
print ("Bad scoring? nothing fits those scores you gave:")
print (' ' + '\n '.join("%s -> %s" % (''.join(an),sc) for an,sc in izip(answers, scores)))
break
```
No
| 66,085 | [
0.445068359375,
0.046539306640625,
0.0460205078125,
0.2203369140625,
-0.736328125,
-0.62646484375,
-0.390380859375,
0.25146484375,
-0.006801605224609375,
0.76806640625,
0.6015625,
0.0513916015625,
0.20654296875,
-0.404052734375,
-0.344970703125,
0.0880126953125,
-0.27587890625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This problem is a little bit unusual. Here you are to implement an interaction with a testing system. That means that you can make queries and get responses in the online mode. Please be sure to use the stream flushing operation after each query's output in order not to leave part of your output in some buffer. For example, in C++ you've got to use the fflush(stdout) function, in Java — call System.out.flush(), and in Pascal — flush(output).
Bulls and Cows (also known as Cows and Bulls or Pigs and Bulls or Bulls and Cleots) is an old code-breaking paper and pencil game for two players, predating the similar commercially marketed board game Mastermind.
On a sheet of paper, the first player thinks a secret string. This string consists only of digits and has the length 4. The digits in the string must be all different, no two or more equal digits are allowed.
Then the second player tries to guess his opponent's string. For every guess the first player gives the number of matches. If the matching digits are on their right positions, they are "bulls", if on different positions, they are "cows". Thus a response is a pair of numbers — the number of "bulls" and the number of "cows". A try can contain equal digits.
More formally, let's the secret string is s and the second player are trying to guess it with a string x. The number of "bulls" is a number of such positions i (1 ≤ i ≤ 4) where s[i] = x[i]. The number of "cows" is a number of such digits c that s contains c in the position i (i.e. s[i] = c), x contains c, but x[i] ≠ c.
For example, the secret string is "0427", the opponent's try is "0724", then the answer is 2 bulls and 2 cows (the bulls are "0" and "2", the cows are "4" and "7"). If the secret string is "0123", the opponent's try is "0330", then the answer is 1 bull and 1 cow.
In this problem you are to guess the string s that the system has chosen. You only know that the chosen string consists of 4 distinct digits.
You can make queries to the testing system, each query is the output of a single 4-digit string. The answer to the query is the number of bulls and number of cows. If the system's response equals "4 0", that means the interaction with your problem is over and the program must terminate. That is possible for two reasons — the program either guessed the number x or made an invalid action (for example, printed letters instead of digits).
Your program is allowed to do at most 50 queries.
You can hack solutions of other participants providing a 4-digit string containing distinct digits — the secret string.
Input
To read answers to the queries, the program must use the standard input.
The program will receive pairs of non-negative integers in the input, one pair per line. The first number in a pair is a number of bulls and the second one is a number of cows of the string s and the string xi printed by your program. If the system response equals "4 0", then your solution should terminate.
The testing system will let your program read the i-th pair of integers from the input only after your program displays the corresponding system query in the output: prints value xi in a single line and executes operation flush.
Output
The program must use the standard output to print queries.
Your program must output requests — 4-digit strings x1, x2, ..., one per line. After the output of each line the program must execute flush operation. The program should read the answer to the query from the standard input.
Your program is allowed to do at most 50 queries.
Examples
Input
0 1
2 0
1 1
0 4
2 1
4 0
Output
8000
0179
3159
3210
0112
0123
Note
The secret string s in the example is "0123".
Submitted Solution:
```
s="0123"
from itertools import permutations
perm = permutations(s)
for i in perm:
s=""
for j in i:
s+=j
print(s)
a,b=input().split()
a=int(a)
if(a==4):
print(s)
break
# print(i)
```
No
| 66,086 | [
0.445068359375,
0.046539306640625,
0.0460205078125,
0.2203369140625,
-0.736328125,
-0.62646484375,
-0.390380859375,
0.25146484375,
-0.006801605224609375,
0.76806640625,
0.6015625,
0.0513916015625,
0.20654296875,
-0.404052734375,
-0.344970703125,
0.0880126953125,
-0.27587890625,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
dic={}
for _ in range(int(input())):
a=int(input())
if a in dic:
dic[a]=1-dic[a]
else:
dic[a]=1
print(sum(dic.values()))
```
Yes
| 66,330 | [
0.201904296875,
0.049468994140625,
-0.1978759765625,
-0.05792236328125,
-0.47900390625,
-0.5087890625,
-0.23193359375,
0.310546875,
0.52734375,
0.86181640625,
0.50537109375,
0.313720703125,
0.0102996826171875,
-0.27490234375,
-0.343994140625,
-0.026580810546875,
-0.7607421875,
-0.7... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
n=int(input())
se=set()
for _ in range(n):
a=int(input())
if a in se:se.discard(a)
else:se.add(a)
print(len(se))
```
Yes
| 66,331 | [
0.2410888671875,
0.1129150390625,
-0.2210693359375,
-0.017730712890625,
-0.54296875,
-0.53466796875,
-0.214111328125,
0.36767578125,
0.5341796875,
0.79638671875,
0.54931640625,
0.314208984375,
0.0079803466796875,
-0.26318359375,
-0.3330078125,
-0.017730712890625,
-0.7470703125,
-0.... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
x=int(input())
a=[]
B={-1}
for i in range(x):
Y=int(input())
if Y not in B:
B.add(Y)
else:
B.discard(Y)
print(len(B)-1)
```
Yes
| 66,332 | [
0.259521484375,
0.12445068359375,
-0.224609375,
-0.032623291015625,
-0.5537109375,
-0.51416015625,
-0.252197265625,
0.397705078125,
0.490478515625,
0.826171875,
0.56494140625,
0.30322265625,
-0.017547607421875,
-0.2371826171875,
-0.32666015625,
0.0138397216796875,
-0.71337890625,
-... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
from collections import Counter
N = int(input())
A = [int(input()) for _ in range(N)]
print(sum([vi % 2 for vi in Counter(A).values()]))
```
Yes
| 66,333 | [
0.2376708984375,
0.11651611328125,
-0.25927734375,
-0.03729248046875,
-0.5400390625,
-0.548828125,
-0.201416015625,
0.385009765625,
0.5439453125,
0.7236328125,
0.51513671875,
0.304443359375,
0.0285186767578125,
-0.2447509765625,
-0.385009765625,
0.0284881591796875,
-0.73779296875,
... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
n=int(input())
list=[]
ans=0
for i in range(n):
a=int(input())
list.append(a)
for i in range(n):
if list.count(list[i])%2!=0:
ans+=1
print(ans)
```
No
| 66,334 | [
0.227783203125,
0.10968017578125,
-0.2154541015625,
-0.0289459228515625,
-0.54248046875,
-0.57958984375,
-0.2425537109375,
0.39404296875,
0.5556640625,
0.80126953125,
0.57080078125,
0.307861328125,
0.00820159912109375,
-0.239501953125,
-0.342529296875,
0.0426025390625,
-0.70751953125... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
n=int(input())
S=set()
for i in range(n):
S=S^set([int(input())])
print(len(S))
```
No
| 66,335 | [
0.2459716796875,
0.1226806640625,
-0.2054443359375,
-0.0148773193359375,
-0.54736328125,
-0.53759765625,
-0.234619140625,
0.33935546875,
0.4970703125,
0.7783203125,
0.59716796875,
0.319091796875,
0.0102386474609375,
-0.2607421875,
-0.3359375,
0.00589752197265625,
-0.74951171875,
-0... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
import sys
input = sys.stdin.readline
N=int(input())
count=0
for _ in range(n):
a=[int(input())]
for x in a:
if a.count(x)%2==1:
count+=1
print(count)
```
No
| 66,336 | [
0.257080078125,
0.1353759765625,
-0.220458984375,
-0.0273895263671875,
-0.56396484375,
-0.56787109375,
-0.26318359375,
0.3564453125,
0.51318359375,
0.806640625,
0.55712890625,
0.296630859375,
-0.017852783203125,
-0.226318359375,
-0.333740234375,
0.0236663818359375,
-0.703125,
-0.84... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbers are written on the sheet now?
The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
Constraints
* 1≤N≤100000
* 1≤A_i≤1000000000(=10^9)
* All input values are integers.
Input
Input is given from Standard Input in the following format:
N
A_1
:
A_N
Output
Print how many numbers will be written on the sheet at the end of the game.
Examples
Input
3
6
2
6
Output
1
Input
4
2
5
5
2
Output
0
Input
6
12
22
16
22
18
12
Output
2
Submitted Solution:
```
import numpy as np
n = int(input())
num = np.zeros(10 ** 9, dtype = bool)
for i in range(n):
a = int(input())
num[a] = not(num[a])
sum = np.where(num == True)
print(len(sum[0]))
```
No
| 66,337 | [
0.28857421875,
0.120849609375,
-0.279541015625,
-0.030303955078125,
-0.499267578125,
-0.5869140625,
-0.20849609375,
0.393310546875,
0.4990234375,
0.82421875,
0.61572265625,
0.2491455078125,
0.024871826171875,
-0.211669921875,
-0.35693359375,
0.020965576171875,
-0.66064453125,
-0.82... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
0 3 1 7 5 9 8 6 4 2
7 0 9 2 1 5 4 8 6 3
4 2 0 6 8 7 1 3 5 9
1 7 5 0 9 8 3 4 2 6
6 1 2 3 0 4 5 9 7 8
3 6 7 4 2 0 9 5 8 1
5 8 6 9 7 2 0 1 3 4
8 9 4 5 3 6 2 0 1 7
9 4 3 8 6 1 7 2 0 5
2 5 8 1 4 3 6 7 9 0
Output
0
Submitted Solution:
```
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
a = [LI() for _ in range(10)]
sm = {}
for i in range(10**4):
c = 0
t = 10**3
while t > 0:
k = i // t % 10
c = a[c][k]
t //= 10
sm[i] = c
e = collections.defaultdict(set)
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
t = i * 1000 + j * 100 + k * 10 + l
for m in range(10):
if i != m:
u = m * 1000 + j * 100 + k * 10 + l
e[t].add(u)
if j != m:
u = i * 1000 + m * 100 + k * 10 + l
e[t].add(u)
if k != m:
u = i * 1000 + j * 100 + m * 10 + l
e[t].add(u)
if l != m:
u = i * 1000 + j * 100 + k * 10 + m
e[t].add(u)
if i != j:
u = j * 1000 + i * 100 + k * 10 + l
e[t].add(u)
if j != k:
u = i * 1000 + k * 100 + j * 10 + l
e[t].add(u)
if k != l:
u = i * 1000 + j * 100 + l * 10 + k
e[t].add(u)
r = 0
for i in range(10**4):
t = sm[i]
if i % 10 != t and sm[i - i % 10 + t] == i % 10:
r += 1
continue
for k in e[i]:
if sm[k] == t:
r += 1
break
rr.append(r)
break
return '\n'.join(map(str, rr))
print(main())
```
No
| 66,409 | [
0.3701171875,
0.154296875,
0.2197265625,
-0.1507568359375,
-0.9296875,
-0.14892578125,
-0.333984375,
0.314208984375,
0.1949462890625,
1.06640625,
0.396484375,
-0.07391357421875,
0.2880859375,
-0.5966796875,
-0.76171875,
-0.0216827392578125,
-0.58544921875,
-0.97607421875,
-0.6635... | 11 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Example
Input
0 3 1 7 5 9 8 6 4 2
7 0 9 2 1 5 4 8 6 3
4 2 0 6 8 7 1 3 5 9
1 7 5 0 9 8 3 4 2 6
6 1 2 3 0 4 5 9 7 8
3 6 7 4 2 0 9 5 8 1
5 8 6 9 7 2 0 1 3 4
8 9 4 5 3 6 2 0 1 7
9 4 3 8 6 1 7 2 0 5
2 5 8 1 4 3 6 7 9 0
Output
0
Submitted Solution:
```
import copy
T = [[int(x) for x in input().split()] for i in range(10)]
def E(ID):
if len(ID)!=4:
print(len(ID))
ret = 0
for d in ID:
d =int(d)
ret = T[ret][d]
return ret
def solve(ID):
e = E(ID)
for i in range(4):
for j in range(10):
kari = copy.deepcopy(ID)
if kari[i] == str(j):
continue
kari[i] = str(j)
if E(kari) == e:
# print(kari,ID)
return 1
for i in range(3):
kari = copy.deepcopy(ID)
if kari[i] == kari[i+1]:
continue
kari[i],kari[i+1] =kari[i+1],kari[i]
if E(kari) == e:
# print(kari,ID)
return 1
if E(ID[:3]+[str(e)]) == int(ID[3]) and int(ID[3])!=e:
return 1
return 0
ans = 0
for i in range(10000):
ID =[j for j in str(i)]
ID = ['0']*(4-len(ID)) + ID
ans += solve(ID)
print(ans)
```
No
| 66,410 | [
0.380859375,
-0.0296783447265625,
-0.0439453125,
0.015625,
-0.84716796875,
-0.4541015625,
-0.318115234375,
0.2286376953125,
0.2047119140625,
0.81298828125,
0.327880859375,
0.04986572265625,
0.162841796875,
-0.76708984375,
-0.55615234375,
-0.07720947265625,
-0.378662109375,
-0.70898... | 11 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An online contest will soon be held on ForceCoders, a large competitive programming platform. The authors have prepared n problems; and since the platform is very popular, 998244351 coder from all over the world is going to solve them.
For each problem, the authors estimated the number of people who would solve it: for the i-th problem, the number of accepted solutions will be between l_i and r_i, inclusive.
The creator of ForceCoders uses different criteria to determine if the contest is good or bad. One of these criteria is the number of inversions in the problem order. An inversion is a pair of problems (x, y) such that x is located earlier in the contest (x < y), but the number of accepted solutions for y is strictly greater.
Obviously, both the creator of ForceCoders and the authors of the contest want the contest to be good. Now they want to calculate the probability that there will be no inversions in the problem order, assuming that for each problem i, any integral number of accepted solutions for it (between l_i and r_i) is equally probable, and all these numbers are independent.
Input
The first line contains one integer n (2 ≤ n ≤ 50) — the number of problems in the contest.
Then n lines follow, the i-th line contains two integers l_i and r_i (0 ≤ l_i ≤ r_i ≤ 998244351) — the minimum and maximum number of accepted solutions for the i-th problem, respectively.
Output
The probability that there will be no inversions in the contest can be expressed as an irreducible fraction x/y, where y is coprime with 998244353. Print one integer — the value of xy^{-1}, taken modulo 998244353, where y^{-1} is an integer such that yy^{-1} ≡ 1 (mod 998244353).
Examples
Input
3
1 2
1 2
1 2
Output
499122177
Input
2
42 1337
13 420
Output
578894053
Input
2
1 1
0 0
Output
1
Input
2
1 1
1 1
Output
1
Note
The real answer in the first test is 1/2.
Tags: combinatorics, dp, probabilities
Correct Solution:
```
import sys
input = sys.stdin.readline
mod=998244353
n=int(input())
LR=[list(map(int,input().split())) for i in range(n)]
RMIN=1<<31
ALL=1
for l,r in LR:
ALL=ALL*pow(r-l+1,mod-2,mod)%mod
for i in range(n):
if LR[i][1]>RMIN:
LR[i][1]=RMIN
RMIN=min(RMIN,LR[i][1])
LMAX=-1
for i in range(n-1,-1,-1):
if LR[i][0]<LMAX:
LR[i][0]=LMAX
LMAX=max(LMAX,LR[i][0])
compression=[]
for l,r in LR:
compression.append(l)
compression.append(r+1)
compression=sorted(set(compression))
co_dict={a:ind for ind,a in enumerate(compression)}
LEN=len(compression)-1
if LEN==0:
print(0)
sys.exit()
DP=[[0]*LEN for i in range(n)]
for i in range(co_dict[LR[0][0]],co_dict[LR[0][1]+1]):
x=compression[i+1]-compression[i]
now=x
#print(i,x)
for j in range(n):
if LR[j][0]<=compression[i] and LR[j][1]+1>=compression[i+1]:
DP[j][i]=now
else:
break
now=now*(x+j+1)*pow(j+2,mod-2,mod)%mod
#print(DP)
for i in range(1,n):
SUM=DP[i-1][LEN-1]
#print(DP)
for j in range(LEN-2,-1,-1):
if LR[i][0]<=compression[j] and LR[i][1]+1>=compression[j+1]:
x=SUM*(compression[j+1]-compression[j])%mod
now=x
t=compression[j+1]-compression[j]
#print(x,t)
for k in range(i,n):
if LR[k][0]<=compression[j] and LR[k][1]+1>=compression[j+1]:
DP[k][j]=(DP[k][j]+now)%mod
else:
break
now=now*(t+k-i+1)*pow(k-i+2,mod-2,mod)%mod
SUM+=DP[i-1][j]
print(sum(DP[-1])*ALL%mod)
```
| 66,564 | [
0.202392578125,
-0.2198486328125,
-0.028839111328125,
0.2386474609375,
-0.468505859375,
-0.77392578125,
-0.134765625,
0.16796875,
-0.0193939208984375,
1.2197265625,
0.8544921875,
-0.154541015625,
0.27880859375,
-0.578125,
-0.27587890625,
0.33203125,
-0.451416015625,
-0.72265625,
... | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.