text stringlengths 198 433k | conversation_id int64 0 109k |
|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
N = int(input())
count = 0
ans = "No"
for _ in range(N):
a,b = map(int,input().split())
if a == b:
count += 1
else:
count = 0
if count == 3:
ans = "Yes"
print(ans)
```
Yes
| 89,000 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
N=input()
n=int(N)
x=0
for s in range(n):
ds1,ds2=input().split()
if ds1==ds2:
x+=1
else:
x=0
if x==3:
print("Yes")
break
else:
print("No")
```
Yes
| 89,001 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
N = int(input())
cnt = 0
mx = 0
for _ in range(N):
a,b = map(int,input().split())
if a==b:
cnt+=1
mx = max(cnt,mx)
else :
cnt=0
print("Yes" if mx >2 else "No")
```
Yes
| 89,002 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
N=int(input())
cnt=0
for i in range(N):
if cnt==3:
print('Yes')
break
D_1,D_2=map(int,input().split())
if D_1==D_2:
cnt+=1
else:
cnt=0
else:
print('No')
```
No
| 89,003 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
n = int(input())
x = 0
for i in range(n):
a, b = map(int, input().split())
if a == b:
x += 1
if x >= 3:
print('Yes')
else:
print('No')
```
No
| 89,004 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
h = 'No'
for i in range(n):
if i > 2:
if d1[i] == d2[i]:
if d1[i-1] == d2[i-1]:
if d1[i-2] == d2[i-2]:
h = 'Yes'
break
print(h)
```
No
| 89,005 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}.
Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.
Constraints
* 3 \leq N \leq 100
* 1\leq D_{i,j} \leq 6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}
Output
Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise.
Examples
Input
5
1 2
6 6
4 4
3 3
3 2
Output
Yes
Input
5
1 1
2 2
3 4
5 5
6 6
Output
No
Input
6
1 1
2 2
3 3
4 4
5 5
6 6
Output
Yes
Submitted Solution:
```
import sys
ls = []
N = int(input())
for l in sys.stdin:
ls.append(l.split())
c = 0
p = 0
ans = 'No'
while len(ls) > (c+1):
if ls[c][0] != ls[c][1]:
c += 1
p = 0
continue
else:
c += 1
p += 1
if p == 3:
ans = 'Yes'
break
print(ans)
```
No
| 89,006 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
from collections import deque
n,m = map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
path = [[] for _ in range(n+1)]
for a,b in ab:
path[a].append(b)
path[b].append(a)
q = deque([1])
ans = [0] * (n+1)
while q:
v = q.popleft()
for w in path[v]:
if ans[w] == 0:
ans[w] = v
q.append(w)
print('Yes')
print(*ans[2:], sep="\n")
```
| 89,007 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
import sys
input = sys.stdin.readline
from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n+1)]
for _ in range(m):
u, v = map(int, input().split())
G[u].append(v)
G[v].append(u)
q = deque([1])
p = [0]*(n+1)
while q:
v = q.popleft()
for u in G[v]:
if p[u] == 0:
p[u] = v
q.append(u)
print("Yes\n"+"\n".join(map(str, p[2:])))
```
| 89,008 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
import queue
n,m=map(int,input().split())
e=[[] for _ in range(n+1)]
INF=10**18
d=[INF]*(n+1)
ans=[0]*(n+1)
for _ in range(m):
a,b=map(int,input().split())
e[a]+=[b]
e[b]+=[a]
q=queue.Queue()
q.put(1)
d[1]=0
while not q.empty():
now=q.get()
for to in e[now]:
if d[to]==INF:
ans[to]=now
d[to]=d[now]+1
q.put(to)
print('Yes')
for i in ans[2:]:
print(i)
```
| 89,009 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
n,m=map(int,input().split())
g=[[] for x in range(n)]
for c in range(m):
a,b= map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
ans_list=[-1]*n
queue=[0]
while queue:
qi=queue.pop(0)
for gi in g[qi]:
if ans_list[gi]==-1:
queue.append(gi)
ans_list[gi]=qi
print("Yes")
for ans in ans_list[1:]:
print(ans+1)
```
| 89,010 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
(n,m),*t=[map(int,t.split())for t in open(0)]
e=[[]for _ in range(n+1)]
for a,b in t:
e[a]+=b,
e[b]+=a,
q=[1]
d=[0]*-~n
for v in q:
for w in e[v]:
if d[w]<1:
d[w]=v
q+=w,
print('Yes',*d[2:])
```
| 89,011 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
q = deque([0])
pre = [-1 for _ in range(n)]
while q:
v = q.popleft()
for t in g[v]:
if pre[t] == -1:
pre[t] = v
q.append(t)
print('Yes')
for i in range(1, n):
print(pre[i]+1)
```
| 89,012 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
from collections import deque
n,m = map(int,input().split())
net = [[] for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
net[a].append(b)
net[b].append(a)
a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
u = d.popleft()
for child in net[u]:
if a[child] != -1:continue
a[child] = u
d.append(child)
print("Yes")
print(*a[2:], sep = " ")
```
| 89,013 |
Provide a correct Python 3 solution for this coding contest problem.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
"Correct Solution:
```
from collections import deque
N, M = map(int, input().split())
d = {i:[] for i in range(1, N+1)}
for _ in range(M):
A, B = map(int, input().split())
d[A].append(B)
d[B].append(A)
par = [-1]*(N+1)
par[1] = 0
q = deque([1])
while q:
a = q.popleft()
for b in d[a]:
if par[b]!=-1:continue
par[b] = a
q.append(b)
print("Yes")
for i in range(2, N+1):
print(par[i])
```
| 89,014 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
from collections import deque
n,m = map(int,input().split())
ab=[[] for _ in range(n+1)]
for _ in range(m):
a,b=map(int,input().split())
ab[a].append(b)
ab[b].append(a)
ans=[0]*(n+1)
ans[1]=1
que=deque()
que.append(1)
while que:
x=que.popleft()
for i in ab[x]:
if ans[i]==0:
ans[i]=x
que.append(i)
print("Yes")
for j in range(2,n+1):
print(ans[j])
```
Yes
| 89,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
from collections import deque
n,m=map(int,input().split())
path=[[] for _ in range(n+1)]
for i in range(m):
a,b=map(int,input().split())
path[b].append(a)
path[a].append(b)
q=deque()
q.append(1)
l=[-1]*(n+1)
while q:
v=q.popleft()
for i in path[v]:
if l[i]==-1:
l[i]=v
q.append(i)
print('Yes')
for i in l[2:]:
print(i)
```
Yes
| 89,016 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
f=lambda:map(int,input().split());n,m=f();g=[[] for _ in range(n)]
for _ in [0]*m:a,b=f();g[a-1]+=[b-1];g[b-1]+=[a-1]
p=[0]*n;from queue import*;q=Queue();q.put(0)
while not q.empty():
v=q.get()
for c in g[v]:
if p[c]<1:p[c]=v+1;q.put(c)
print('Yes',*p[1:],sep='\n')
```
Yes
| 89,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
from collections import deque
N, M = map(int, input().split())
X = [[] for x in range(N+1)]
for m in range(M):
A, B = map(int, input().split())
X[A].append(B)
X[B].append(A)
Q = deque()
Q.append(1)
D = [-1]*(N+1)
D[0] = 0
D[1] = 0
while Q:
v = Q.pop()
for i in X[v]:
if D[i] == -1:
D[i] = v
Q.appendleft(i)
if -1 in D:
print('No')
else:
print('Yes')
print(*D[2:])
```
Yes
| 89,018 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
#!/usr/bin/env python3
# vim: set fileencoding=utf-8
# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation
"""Module docstring
"""
import functools
import heapq
import itertools
import logging
import math
import os
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from io import BytesIO, IOBase
from typing import Dict, List, Optional, Set, Tuple
def solve(values: List[Tuple[int, int]], n: int) -> List[int]:
passages = defaultdict(set)
for a, b in values:
passages[a].add(b)
passages[b].add(a)
if len(passages) < n:
return []
to_visit = deque((1,))
visited = set()
# 0 idx is not used
distances = [n + 1] * (n + 1)
distances[1] = 0
signs = [1] * (n + 1)
while to_visit:
cur = to_visit.popleft()
for neighbour in passages[cur]:
tmp = distances[cur] + 1
if tmp < distances[neighbour]:
distances[neighbour] = tmp
signs[neighbour] = cur
if neighbour not in visited:
to_visit.append(neighbour)
visited.add(cur)
# LOG.debug((visited))
# LOG.debug((distances))
if len(visited) < n:
return []
return signs[2:]
def do_job(stdin, stdout):
"Do the work"
LOG.debug("Start working")
N, M = map(int, stdin.readline().split())
if M < N:
print("No", file=stdout)
return
values = []
for _ in range(M):
a, b = map(int, stdin.readline().split())
values.append((a, b))
result = solve(values, N)
if not result:
print("No", file=stdout)
else:
print("Yes", file=stdout)
print("\n".join(map(str, result)), file=stdout)
def print_output(testcase: int, result, stdout) -> None:
"Formats and print result"
if result is None:
result = "IMPOSSIBLE"
print("Case #{}: {}".format(testcase + 1, result), file=stdout)
# 6 digits float precision {:.6f} (6 is the default value)
# print("Case #{}: {:f}".format(testcase + 1, result), file=stdout)
BUFSIZE = 8192
class FastIO(IOBase):
# pylint: disable=super-init-not-called, expression-not-assigned
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):
# pylint: disable=super-init-not-called
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def configure_log() -> None:
"Configure the log output"
log_formatter = logging.Formatter("L%(lineno)d - " "%(message)s")
handler = logging.StreamHandler(IOWrapper(sys.stderr))
handler.setFormatter(log_formatter)
LOG.addHandler(handler)
LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
LOG = logging.getLogger("template")
configure_log()
def main(argv=None):
"Program wrapper."
if argv is None:
argv = sys.argv[1:]
parser = ArgumentParser()
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
action="store_true",
default=False,
help="run as verbose mode",
)
args = parser.parse_args(argv)
if args.verbose:
LOG.setLevel(logging.DEBUG)
stdin = IOWrapper(sys.stdin)
stdout = IOWrapper(sys.stdout)
do_job(stdin, stdout)
stdout.flush()
for h in LOG.handlers:
h.flush()
return 0
if __name__ == "__main__":
sys.exit(main())
```
No
| 89,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
n,m = (int(x) for x in input().split())
E = [[] for i in range(n+1)]
for i in range(m):
a,b = (int(x) for x in input().split())
E[a].append(b)
E[b].append(a)
#print(E)
flag = [False]*(n+1)
vs = [1]
flag[1] = True
res = [0]*(n+1)
while(vs):
this_v = vs[0]
for i in E[this_v]:
if flag[i]:
continue
else:
res[i] = this_v
flag[i] = True
vs.append(i)
vs = vs[1:]
print("Yes")
for i in res[2:]:
print(i)
```
No
| 89,020 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
n, m = map(int, input().split())
ways = [tuple(map(int, input().split())) for _ in range(m)]
table = [list() for _ in range(n+1)]
hush = {}
hush2 = {}
for i in range(1, n+1):
hush[i] = False
hush2[i] = False
ans = [0 for _ in range(n+1)]
for a, b in ways:
table[a].append(b)
table[b].append(a)
hush[1] = True
def bfs(i):
if hush2[i] == True: return
else: hush2[i] = True
for room in table[i]:
if hush[room] == False:
ans[room] = i
hush[room] = True
for room in table[i]:
bfs(room)
bfs(1)
print('Yes')
for i in range(2, n+1):
print(ans[i])
```
No
| 89,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.
Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.
* If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
Constraints
* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)
* A_i \neq B_i\ (1 \leq i \leq M)
* One can travel between any two rooms by traversing passages.
Input
Input is given from Standard Input in the following format:
N M
A_1 B_1
:
A_M B_M
Output
If there is no way to place signposts satisfying the objective, print `No`.
Otherwise, print N lines. The first line should contain `Yes`, and the i-th line (2 \leq i \leq N) should contain the integer representing the room indicated by the signpost in Room i.
Examples
Input
4 4
1 2
2 3
3 4
4 2
Output
Yes
1
2
2
Input
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
Output
Yes
6
5
5
1
1
Submitted Solution:
```
# N = int(input())
import numpy as np
N,M = list(map(int, input().split()))
paths = []
connection_dic = {}
for i in range(N):
connection_dic[i+1] = set()
for i in range(M):
A,B = list(map(int, input().split()))
connection_dic[A].add(B)
connection_dic[B].add(A)
for i in range(N):
if len(connection_dic[i+1]) == 0:
print("No")
exit()
ans_list = np.zeros(N-1, dtype = np.int)
current_distance = 0
parents = set([1])
next_parents = set()
while len(parents) > 0:
current_distance += 1
while len(parents) > 0:
parent = parents.pop()
for node in connection_dic[parent]:
if ans_list[node-2] == 0:
ans_list[node-2] = parent
next_parents.add(node)
parents = next_parents
next_parents = set()
print("Yes")
for ans in ans_list:
print(int(ans))
```
No
| 89,022 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n = int(input())
musics = [input().split() for _ in range(n)]
x = input()
not_yet = True
ans = 0
for m, s in musics:
if not not_yet:
ans += int(s)
if x == m:
not_yet = False
print(ans)
```
| 89,023 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n=int(input())
S=[]
T=[]
for i in range(n):
s,t=input().split()
S.append(s)
T.append(int(t))
print(sum(T[S.index(input())+1:]))
```
| 89,024 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
N=int(input())
s,t=[0]*N,[0]*N
for i in range(N):
s[i],t[i]=input().split()
X=input()
print(sum(list(map(int,t[s.index(X)+1:]))))
```
| 89,025 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n = int(input())
title = []
length = []
for i in range(n):
a, b = input().split()
title.append(a)
length.append(int(b))
i = title.index(input())
print(sum((length[i+1:])))
```
| 89,026 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n=int(input())
s=[]
t=[]
for i in range(n):
ss,tt=input().split()
s.append(ss)
t.append(int(tt))
print(sum(t[s.index(input())+1:]))
```
| 89,027 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
N = int(input())
s = [None] * N
t = [None] * N
for i in range(N):
p, q = input().split()
s[i] = p
t[i] = int(q)
X = input()
print(sum(t[s.index(X)+1:]))
```
| 89,028 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n = int(input())
s,t = [0]*n,[0]*n
for i in range(n):
s[i],t[i] = input().split()
t = list(map(int,t))
print(sum(t[s.index(input())+1:]))
```
| 89,029 |
Provide a correct Python 3 solution for this coding contest problem.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
"Correct Solution:
```
n=int(input())
l=[input().split() for i in range(n)]
x=input()
ans=0
for i in range(n):
if l[i][0]==x:
ans=0
else:
ans+=int(l[i][1])
print(ans)
```
| 89,030 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
n = int(input())
ans = 0
music = {}
for i in range(n):
a, b = input().split()
ans += int(b)
music[a] = ans
print(ans-music[input()])
```
Yes
| 89,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
n=int(input())
box1=[]
box2=[]
for i in range(n):
i=input().rstrip().split(" ")
box1.append(i[0])
box2.append(int(i[1]))
num=box1.index(input())
del box2[:num+1]
print(sum(box2))
```
Yes
| 89,032 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
N = int(input())
S = []
T = []
for _ in range(N):
s, t = input().split()
S.append(s)
T.append(int(t))
X = input()
ans = sum(T[S.index(X)+1:])
print(ans)
```
Yes
| 89,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
n=int(input())
l=[list(input().split()) for _ in range(n)]
x=input()
ans=0
for i in range(n):
s,t=l[i]
t=int(t)
ans+=t
if s==x:
c=ans
print(ans-c)
```
Yes
| 89,034 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
def f(X,s,t):
N=len(s)
i=0
c=0
while s[i]!=X:
c+=int(t[i])
i+=1
return sum(t)-(c+int(t[i]))
N=int(input())
s=[0]*N
t=[0]*N
for a in range(0,N):
(s[a],t[a])=map(str,input().split())
X=input()
print(f(X,s,t))
```
No
| 89,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
s[i], t[i] = map(str, input().split())
x = input()
a = 0
b = 0
c = 0
while a <= n - 1:
if s[a] == x:
while b <= n - 1:
c += int(t[b])
b += 1
else:
a += 1
b += 1
else:
print(c)
```
No
| 89,036 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
n,k = map(int,input().split())
a = tuple(map(int,input().split()))
mod = 10**9+7
rng = 1001
fctr = [1]
finv = [1]
for i in range(1,rng):
fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
if n<0 or k<0:
return 0
else:
return fctr[n]*finv[n-k]*finv[k]%mod
dp = [[0 for i in range(n+1)] for j in range(k+1)]
dp[0][0] = 1
for i in range(1,k+1):
x = a[i-1]
for j in range(n+1):
for t in range(min(n-j,x)+1):
dp[i][j+t]=(dp[i][j+t]+dp[i-1][j]*cmb(n-j,t)*cmb(n-t,x-t))%mod
print(dp[k][n])
```
No
| 89,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.
Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.
Find the duration of time when some song was played while Niwango was asleep.
Constraints
* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.
Input
Input is given from Standard Input in the following format:
N
s_1 t_1
\vdots
s_{N} t_N
X
Output
Print the answer.
Examples
Input
3
dwango 2
sixth 5
prelims 25
dwango
Output
30
Input
1
abcde 1000
abcde
Output
0
Input
15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu
Output
6348
Submitted Solution:
```
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq
## input functions for me
def rsa(sep = ''):
if sep == '' :
return input().split()
else: return input().split(sep)
def rip(sep = ''):
if sep == '' :
return map(int, input().split())
else: return map(int, input().split(sep))
def ria(sep = ''):
return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
N = ri()
S = []
T = []
for i in range(N):
S[i], T[i] = rip()
X = ri()
ans = 0
sleep = False
for i in range(N):
if S[i] == X:
sleep = True
continue
if sleep:
ans += T[i]
print(ans)
if __name__ == "__main__":
main()
```
No
| 89,038 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
"Correct Solution:
```
from collections import defaultdict, deque
N, M = map(int, input().split())
A = [[0] * M for _ in range(N)]
B = [[0] * M for _ in range(N)]
C = [[0] * M for _ in range(N)]
G = defaultdict(lambda: defaultdict(int))
F = defaultdict(lambda: defaultdict(int))
rows = [0] * (N * M + 1)
for i in range(N):
A_list = list(map(int, input().split()))
A[i] = A_list
for a in A_list:
G[i + 1][N + (a + M - 1) // M] += 1
G[N + (a + M - 1) // M][i + 1] = 0
# dfs
for t1 in range(M):
for i in range(1, N + 1):
G[0][i] = 1
F[0][i] = 0
G[N + i][2 * N + 1] = 1
F[N + i][2 * N + 1] = 0
for t2 in range(N):
queue = deque([0])
searched = [0] * (2 * N + 2)
searched[0] = 1
parent = [0] * (2 * N + 2)
while len(queue) > 0:
p = queue.pop()
for q in G[p].keys():
if (G[p][q] > 0 or F[q][p] > 0) and searched[q] == 0:
parent[q] = p
searched[q] = 1
queue.append(q)
if searched[2 * N + 1] == 1:
break
path = [2 * N + 1]
while True:
path.append(parent[path[-1]])
if path[-1] == 0:
break
for i in range(len(path) - 1, 0, -1):
p, q = path[i], path[i-1]
if G[p][q] > 0:
G[p][q] -= 1
F[p][q] += 1
elif F[q][p] > 0:
F[q][p] -= 1
G[q][p] += 1
for i in range(1, N + 1):
ji = 0
for j in range(N + 1, 2 * N + 1):
if F[i][j] == 1:
ji = j
break
F[i][ji] -= 1
for a in A[i - 1]:
if N + (a + M - 1) // M == ji:
A[i - 1].remove(a)
B[i - 1][t1] = a
break
for j in range(M):
c_j = list(sorted([B[i][j] for i in range(N)]))
for i in range(N):
C[i][j] = c_j[i]
if __name__ == "__main__":
for i in range(N):
print(*B[i])
for i in range(N):
print(*C[i])
```
| 89,039 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
"Correct Solution:
```
import sys
readline = sys.stdin.readline
import collections
class Dinic:
def __init__(self, vnum):
self.edge = [[] for i in range(vnum)]
self.n = vnum
# infはint型の方が良いかもね
self.inf = float('inf')
def addedge(self, st, en, c):
self.edge[st].append([en, c, len(self.edge[en])])
self.edge[en].append([st, 0, len(self.edge[st])-1])
def bfs(self, vst):
dist = [-1]*self.n
dist[vst] = 0
Q = collections.deque([vst])
while Q:
nv = Q.popleft()
for vt, c, r in self.edge[nv]:
if dist[vt] == -1 and c > 0:
dist[vt] = dist[nv] + 1
Q.append(vt)
self.dist = dist
def dfs(self, nv, en, nf):
nextv = self.nextv
if nv == en:
return nf
dist = self.dist
ist = nextv[nv]
for i, (vt, c, r) in enumerate(self.edge[nv][ist:], ist):
if dist[nv] < dist[vt] and c > 0:
df = self.dfs(vt, en, min(nf, c))
if df > 0:
self.edge[nv][i][1] -= df
self.edge[vt][r][1] += df
return df
nextv[nv] += 1
return 0
def getmf(self, st, en):
mf = 0
while True:
self.bfs(st)
if self.dist[en] == -1:
break
self.nextv = [0]*self.n
while True:
fl = self.dfs(st, en, self.inf)
if fl > 0:
mf += fl
else:
break
return mf
N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for _ in range(N)]
B = [[None]*M for _ in range(N)]
st = 2*N
en = 2*N+1
used = set()
for num in range(M):
T = Dinic(2*N+2)
for i in range(N):
T.addedge(st, i, 1)
T.addedge(N+i, en, 1)
for j in range(M):
aij = A[i][j]
if aij not in used:
T.addedge(i, N+(aij-1)//M, 1)
T.getmf(st, en)
for i in range(N):
candi = [e for e, cost, _ in T.edge[i+N] if cost == 1][0]
for j in range(M):
if A[candi][j] not in used and (A[candi][j]-1)//M == i:
used.add(A[candi][j])
B[candi][num] = A[candi][j]
break
C = list(map(list, zip(*B)))
C = [sorted(c) for c in C]
C = list(map(list, zip(*C)))
for b in B:
print(*b)
for c in C:
print(*c)
```
| 89,040 |
Provide a correct Python 3 solution for this coding contest problem.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
"Correct Solution:
```
"""
https://atcoder.jp/contests/agc037/tasks/agc037_d
まず分かりやすさのため全部-1してMで割る
2番目の操作後に上から0行目には全部0 , 1行目には全部1…となればおk
すなわち、1番目の操作では各列に1個づつ数字が入るようにする必要がある
→これは貪欲にやればok・・・じゃない
ある列をうまくはめれば必ず次も可能?
→最後の列を考えると、足りない要素と残りの要素のsetは等しいのでokそう
→2部マッチング!
=====解説=====
そもそも何をマッチングさせてた?
→各行の置けるaとa
→ 次数は不定 & 不定
→ Hallが成り立つと証明できない…
→ あれ???????正解解法もおかしくないか
"""
from collections import defaultdict
from collections import deque
route = []
def Ford_Fulkerson_Func(s,g,lines,cost):
global route
N = len(cost)
ans = 0
queue = deque([ [s,float("inf")] ])
ed = [True] * N
ed[s] = False
route = [0] * N
route[s] = -1
while queue:
now,flow = queue.pop()
for nex in lines[now]:
if ed[nex]:
flow = min(cost[now][nex],flow)
route[nex] = now
queue.append([nex,flow])
ed[nex] = False
if nex == g:
ans += flow
break
else:
continue
break
else:
return False,ans
t = g
s = route[t]
while s != -1:
cost[s][t] -= flow
if cost[s][t] == 0:
lines[s].remove(t)
if cost[t][s] == 0:
lines[t].add(s)
cost[t][s] += flow
t = s
s = route[t]
return True,ans
def Ford_Fulkerson(s,g,lines,cost):
ans = 0
while True:
fl,nans = Ford_Fulkerson_Func(s,g,lines,cost)
if fl:
ans += nans
continue
else:
break
return ans
from sys import stdin
import sys
sys.setrecursionlimit(10000)
N,M = map(int,stdin.readline().split())
B = [[None] * M for i in range(N)]
Bs = [[True] * M for i in range(N)]
A = []
for loop in range(N):
a = list(map(int,stdin.readline().split()))
A.append(a)
for loop in range(M):
lines = defaultdict(set)
cost = [ [0] * (2*N+2) for i in range(2*N+2) ]
for i in range(N):
lines[2*N].add(i)
cost[2*N][i] = 1
for i in range(N,2*N):
lines[i].add(2*N+1)
cost[i][2*N+1] = 1
for i in range(N):
for j in range(len(A[i])):
lines[i].add((A[i][j]-1)//M + N)
cost[i][(A[i][j]-1)//M + N] = 1
Ford_Fulkerson(2*N,2*N+1,lines,cost)
ans = []
for i in range(N):
for j in range(len(A[i])):
if cost[i][(A[i][j]-1)//M + N] == 0:
ans.append(A[i][j])
del A[i][j]
break
#print (ans)
for i in range(N):
B[i][loop] = ans[i]
for i in B:
print (*i)
C = [[None] * M for i in range(N)]
for j in range(M):
tmp = []
for i in range(N):
tmp.append(B[i][j])
tmp.sort()
for i in range(N):
C[i][j] = tmp[i]
for i in C:
print (*i)
```
| 89,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
Submitted Solution:
```
import sys
from collections import Counter
input = sys.stdin.readline
N, M = list(map(int,input().split())) # N:row M:column
A = [list(map(int,input().split())) for i in range(N)]
B = [list(map(lambda x:int((x-1)/M) ,A[i])) for i in range(N)]
rrow = [-1]*N
maxnum = [[i,0,-1] for i in range(N)]
order = 1
while min(rrow)==-1:
for i in range(N):
if rrow[i]==-1:
C = Counter(B[i])
value, num = C.most_common(order)[-1]
if maxnum[value][1]<num:
maxnum[value][1] = num
rrow[maxnum[value][2]] = -1
rrow[i] = value
maxnum[value][2] = i
order += 1
fix = [[0]*M for i in range(N)]
ss = [set(range(N)) for i in range(M)]
for iy in range(N):
t = rrow[iy]
col = 0
for ix in range(M):
if B[iy][ix]==t:
B[iy][col], B[iy][ix] = B[iy][ix], B[iy][col]
A[iy][col], A[iy][ix] = A[iy][ix], A[iy][col]
fix[iy][col] = 1
ss[col].remove(t)
col += 1
for ix in range(M):
while True:
ty = -1
minlen = 1000
for iy in range(N):
if fix[iy][ix]==0:
notfix = True
iset = ss[ix].intersection(B[iy][ix::])
ilen = len(iset)
if ilen<minlen:
ty = iy
tset = iset
minlen = ilen
if minlen==1: break
if ty==-1: break
jy, jx = ty, ix
while B[jy][jx] not in tset: jx+=1
ss[ix].remove(B[jy][jx])
B[jy][jx], B[jy][ix] = B[jy][ix], B[jy][jx]
A[jy][jx], A[jy][ix] = A[jy][ix], A[jy][jx]
fix[jy][ix] = 1
for i in A:print(*i)
for ix in range(M):
for iy in range(N):
row = B[iy][ix]
B[iy][ix], B[row][ix] = B[row][ix], B[iy][ix]
A[iy][ix], A[row][ix] = A[row][ix], A[iy][ix]
for i in A:print(*i)
```
No
| 89,042 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
Submitted Solution:
```
import copy
n,m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for n in range(n)]
ngset = {}
for i in range(n):
tmp = []
for j in range(1,m+1):
tmp.append((i*m+j))
for k in tmp:
ngset[k] = tmp
ngs = {}
for i, aa in enumerate(A):
if i == 0:
for j, a in enumerate(aa):
ngs[j] = []
ngs[j].extend(ngset[a])
else:
for j, a in enumerate(aa):
if a in ngs[j]:
k = None
if j+1 < m:
for jtmp in range(j+1, m):
if A[i][j] not in ngs[jtmp] and A[i][jtmp] not in ngs[j]:
k = jtmp
break
if not k:
for jtmp in range(j, -1, -1):
if A[i][j] not in ngs[jtmp] and A[i][jtmp] not in ngs[j]:
k = jtmp
break
A[i][j] , A[i][k] = A[i][k], A[i][j]
for j, a in enumerate(aa):
print(ngs[j])
print(ngset[a])
```
No
| 89,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
Submitted Solution:
```
import copy
n,m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for n in range(n)]
ngset = {}
for i in range(n):
tmp = []
for j in range(1,m+1):
tmp.append((i*m+j))
for k in tmp:
ngset[k] = tmp
ngs = {}
for i, aa in enumerate(A):
if i == 0:
for j, a in enumerate(aa):
ngs[j] = []
ngs[j].extend(ngset[a])
else:
for j, a in enumerate(aa):
if a in ngs[j]:
k = None
if j+1 < m:
for jtmp in range(j+1, m):
if A[i][j] not in ngs[jtmp] and A[i][jtmp] not in ngs[j]:
k = jtmp
break
if not k:
for jtmp in range(j, -1, -1):
if A[i][j] not in ngs[jtmp] and A[i][jtmp] not in ngs[j]:
k = jtmp
break
A[i][j] , A[i][k] = A[i][k], A[i][j]
for j, a in enumerate(aa):
ngs[j].extend(ngset[a])
B = copy.deepcopy(A)
import numpy as np
A = np.array(A)
for i in range(m):
A[:,i].sort()
for i in range(n):
text = ""
for j in range(m):
text += str(B[i][j]) + " "
print(text[:-1])
for i in range(n):
text = ""
for j in range(m):
text += str(A[i][j]) + " "
print(text[:-1])
```
No
| 89,044 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numbers as follows:
1. First, for each of the N rows, rearrange the numbers written in it as you like.
2. Second, for each of the M columns, rearrange the numbers written in it as you like.
3. Finally, for each of the N rows, rearrange the numbers written in it as you like.
After rearranging the numbers, you want the number written in the square at the i-th row from the top and the j-th column from the left to be M\times (i-1)+j. Construct one such way to rearrange the numbers. The constraints guarantee that it is always possible to achieve the objective.
Constraints
* 1 \leq N,M \leq 100
* 1 \leq A_{ij} \leq NM
* A_{ij} are distinct.
Input
Input is given from Standard Input in the following format:
N M
A_{11} A_{12} ... A_{1M}
:
A_{N1} A_{N2} ... A_{NM}
Output
Print one way to rearrange the numbers in the following format:
B_{11} B_{12} ... B_{1M}
:
B_{N1} B_{N2} ... B_{NM}
C_{11} C_{12} ... C_{1M}
:
C_{N1} C_{N2} ... C_{NM}
Here B_{ij} is the number written in the square at the i-th row from the top and the j-th column from the left after Step 1, and C_{ij} is the number written in that square after Step 2.
Examples
Input
3 2
2 6
4 3
1 5
Output
2 6
4 3
5 1
2 1
4 3
5 6
Input
3 4
1 4 7 10
2 5 8 11
3 6 9 12
Output
1 4 7 10
5 8 11 2
9 12 3 6
1 4 3 2
5 8 7 6
9 12 11 10
Submitted Solution:
```
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
"""
正則二部グラフの辺彩色
"""
import numpy as np
N,M = map(int,input().split())
grid = [[int(x) for x in input().split()] for _ in range(N)]
edge = []
for i,row in enumerate(grid):
for j,x in enumerate(row):
edge.append(((x-1)//M,N+i))
graph = [dict() for _ in range(N+N)] # 頂点ごろに、色->相手
rest_color = [set(range(M)) for _ in range(N+N)]
for u,v in edge:
c = rest_color[u].pop()
if c in rest_color[v]:
graph[u][c] = v
graph[v][c] = u
rest_color[v].remove(c)
continue
# 交互道を作って色c,dと当てていく
d = rest_color[v].pop()
cd = c + d
V = [u,v]
next_c = c
while next_c not in rest_color[v]:
v = graph[v][next_c]
V.append(v)
next_c = cd - next_c
rest_color[v].remove(next_c)
rest_color[v].add(cd - next_c)
for i,(u,v) in enumerate(zip(V,V[1:])):
if i%2 == 0:
graph[u][c] = v
graph[v][c] = u
else:
graph[u][d] = v
graph[v][d] = u
after = [[None] * M for _ in range(N)]
for i,row in enumerate(grid):
mod_to_x = [[] for _ in range(N)]
for x in row:
mod_to_x[(x-1)//M].append(x)
for color in range(M):
after[i][color] = mod_to_x[graph[i][color] - N].pop()
B = np.array(after)
C = B.copy()
C.sort(axis = 0)
print('\n'.join(' '.join(row) for row in B.astype(str)))
print('\n'.join(' '.join(row) for row in C.astype(str)))
```
No
| 89,045 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
x, y, z = map(int,input().split())
if x == y == z:
print("Yes")
else:
print("No")
```
| 89,046 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
x,y,z= map(int,input().split())
if x==y and y==z:
print("Yes")
else:
print("No")
```
| 89,047 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
A,B,C=[int(i) for i in input().split(" ")]
print("Yes" if A==B==C else "No")
```
| 89,048 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
A,B,C=map(int,input().split())
if A==C and A==B:
print('Yes')
else :
print('No')
```
| 89,049 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
A, B, C = map(int, input().split())
if (A==B and B==C):
print('Yes')
else:
print('No')
```
| 89,050 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
a, b, c = map(int, input().split())
print("Yes" if a == b and a == c and b == c else "No")
```
| 89,051 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
i = input().split()
if i[0]==i[1] and i[1]==i[2]:
print("Yes")
else:
print("No")
```
| 89,052 |
Provide a correct Python 3 solution for this coding contest problem.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
"Correct Solution:
```
a,b,c = input().split()
print("Yes" if a == b == c else "No")
```
| 89,053 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
if len(set(map(int, input().split()))) == 1:
print('Yes')
else:
print('No')
```
Yes
| 89,054 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
A, B, C = map(int, input().split())
msg = 'Yes' if A == B and B == C else 'No'
print(msg)
```
Yes
| 89,055 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
a,b,c=map(int,input().split())
if a==b and b==c and a==c:
print("Yes")
else:
print("No")
```
Yes
| 89,056 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
A,B,C= map(int,input().split())
f = 'No'
if (A==B)and(C==A):
f = 'Yes'
print(f)
```
Yes
| 89,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
a,b,c=map(int,input().split())
if a==b:
if b==c:
print("yes")
else:
print("No")
```
No
| 89,058 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
a,b,c = map(int, input().split())
if a== b and b == c:
print(Yes)
else:
print(No)
```
No
| 89,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
# coding: utf-8
a, b, c = map(int, input.split())
if a = b and b = c and c = a:
print('Yes')
else:
print('No')
```
No
| 89,060 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three integers A, B and C.
Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
Constraints
* All values in input are integers.
* 1 \leq A,B,C \leq 100
Input
Input is given from Standard Input in the following format:
A B C
Output
If there exists an equilateral triangle whose sides have lengths A, B and C, print `Yes`; otherwise, print `No`.
Examples
Input
2 2 2
Output
Yes
Input
3 4 5
Output
No
Submitted Solution:
```
abc = list(map(int, input().split()))
abc.sort()
if abc[2] >= abc[0] + abc[1]:
print("No")
else:
print("Yes")
```
No
| 89,061 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
H, W, K = map(int, input().split())
bit = []
for i in range(1 << (W - 1)):
flag = True
for j in range(W - 1):
if i & 1 << j and i & 1 << (j + 1):
flag = False
break
if flag:
bit.append(i)
MOD = 10 ** 9 + 7
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
for k in bit:
ne = j
if k & 1 << j:
ne = j + 1
elif j - 1 >= 0 and k & 1 << (j - 1):
ne = j - 1
dp[i + 1][ne] += dp[i][j]
dp[i + 1][ne] %= MOD
print(dp[H][K - 1])
```
| 89,062 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
h,w,k = map(int,input().split())
mod = 10**9+7
dp = [[0]*(w+2) for _ in range(h+1)]
dp[0][1] = 1
#左右の余白を埋める場合の数
ref = [1,2,3,5,8,13,21]
pat = lambda l,r:ref[max(l,0)]*ref[max(r,0)]
for i in range(h):
for j in range(1,w+1):
dp[i+1][j] = dp[i][j-1]*pat(j-3,w-j-1) + dp[i][j]*pat(j-2,w-j-1) + dp[i][j+1]*pat(j-2,w-j-2)
dp[i+1][j] %= mod
print(dp[-1][k])
```
| 89,063 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
h,w,k = (int(x) for x in input().split())
MOD = 1000000007
dp=[[0]*(w+2) for _ in range(h+2)]
fib = [0]*(w+1)
# 初期条件
fib[1] = 1
dp[0][1] = 1
# フィボナッチ
for i in range(2,w+1):
fib[i] = fib[i-1] + fib[i-2]
for i in range(1, h+1):
for j in range(1, w+1):
dp[i][j] = (dp[i - 1][j - 1]*fib[j - 1]*fib[w - j + 1]+dp[i - 1][j]*fib[j]*fib[w - j + 1]+dp[i - 1][j + 1]*fib[j]*fib[w - j])%MOD
print(dp[h][k])
```
| 89,064 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
H, W, K = map(int, input().split())
dp = [[0 for _ in range(W)] for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
for j in range(W):
for k in range(2 ** (W - 1)):
if bin(k).count("11") >= 1:
continue
if j + 1 <= W - 1 and (k >> j) & 1:
dp[i][j] += dp[i - 1][j + 1]
elif j - 1 >= 0 and (k >> (j - 1)) & 1:
dp[i][j] += dp[i - 1][j - 1]
else:
dp[i][j] += dp[i - 1][j]
print(dp[H][K - 1] % (10 ** 9 + 7))
```
| 89,065 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
MOD = 10**9 + 7
H, W, K = map(int, input().split())
fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
def getFib(i):
return fibs[i+2]
numLs, numCs, numRs = [0]*W, [0]*W, [0]*W
for j in range(W):
numCs[j] = getFib(j-1) * getFib(W-1-j-1)
numLs[j] = getFib(j-2) * getFib(W-1-j-1)
numRs[j] = getFib(j-1) * getFib(W-1-j-2)
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
for j in range(W):
dp[i+1][j] += dp[i][j] * numCs[j]
if j > 0:
dp[i+1][j-1] += dp[i][j] * numLs[j]
if j < W-1:
dp[i+1][j+1] += dp[i][j] * numRs[j]
for j in range(W):
dp[i+1][j] %= MOD
print(dp[H][K-1])
```
| 89,066 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
h,w,k = map(int,input().split())
if w == 1:
print(1)
exit()
a = [0]*(w+2)
a[1] = 1
f = [0]*(w-1)
p = 0
q = 1
for i in range(w-1):
f[i] = p+q
q = p + q
p = q - p
f.append(1)
b = []
mod = 10**9+7
for i in range(w):
if i == 0:
b.append([0,f[w-2],f[w-3]])
elif i == w-1:
b.append([f[w-3],f[w-2],0])
else:
b.append([f[i-2]*f[w-i-2],f[i-1]*f[w-i-2],f[i-1]*f[w-i-3]])
for _ in range(h):
newa = [0]*(w+2)
for i in range(1,w+1):
newa[i] = (a[i-1]*b[i-1][0]+a[i]*b[i-1][1]+a[i+1]*b[i-1][2])%mod
a = newa
print(a[k])
```
| 89,067 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 5 10:49:47 2019
@author: Yamazaki Kenichi
"""
H,W,K = map(int, input().split())
mod = 10**9 +7
a = [1,1,2,3,5,8,13,21]
T = [[-1 for i in range(9)] for i in range(H+1) ]
def n(h,k):
if T[h][k] != -1:
return T[h][k]
res = 0
if h == 1:
if k == 1 or k == 2:
T[h][k] = a[W-k]
return a[W-k]
else:
T[h][k] = 0
return 0
res += n(h-1,k)*(a[k-1] * a[W-k])
if k != 1:
res += n(h-1,k-1)*(a[k-1-1] * a[W-k])
if k != W:
res += n(h-1,k+1)*(a[k-1] * a[W-k-1])
T[h][k] = res
return res % mod
ans = n(H,K)
print(ans)
```
| 89,068 |
Provide a correct Python 3 solution for this coding contest problem.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
"Correct Solution:
```
H,W,K=map(int,input().split())
dp=[[0]*(W+1) for _ in range(H+1)]
dp[0][0]=1
mod=10**9+7
for h in range(H):
for b in range(1<<(W-1)):
if "11" in bin(b):continue
b<<=1
for w in range(W):
if b&(1<<w):
dp[h+1][w]+=dp[h][w-1]
elif b&(1<<(w+1)):
dp[h+1][w]+=dp[h][w+1]
else:
dp[h+1][w]+=dp[h][w]
dp[h+1][w]%=mod
print(dp[H][K-1]%mod)
```
| 89,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
h,w,k=map(int,input().split());p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)];d=[w*[0]for _ in[0]*-~h];d[0][0]=1
for i in range(h):
b=d[i]
for j in range(w):
t=u=D=0
if j:t=p[max(0,j-2)]*p[max(0,w-j-2)];D=b[j-1]*t
if j<w-1:u=p[max(0,j-1)]*p[max(0,w-j-3)];D+=b[j+1]*u
d[i+1][j]=(b[j]*(p[w-1]-t-u)+D)%(10**9+7)
print(d[-1][k-1])
```
Yes
| 89,070 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
import sys
input=sys.stdin.readline
h,w,k = map(int, input().split())
lis = [0]*(w-1)
n = 0
for i in range(2**(w-1)):
tmp = bin(i)[2:].zfill(w-1)
if '11' in tmp:continue
n += 1
for j in range(w-1):
lis[j] += int(tmp[j])
res = [1]+[0]*(w-1)
for i in range(h):
res2 = res.copy()
for j in range(w):
if j == 0:
a=0
x = 0
else:
a = lis[j-1]
x = res[j-1]
if j== w-1:
b = 0
y = 0
else:
b = lis[j]
y = res[j+1]
res2[j] = x*a + res[j]*(n - a - b) + y*b
res = res2
print(res[k-1] % (10**9+7))
```
Yes
| 89,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
H, W, K = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [[0] * W for i in range(H + 1)]
dp[0][0] = 1
fib = [1, 2, 3, 5, 8, 13, 21, 34]
def calc(w):
if w < 0:
return 1
return fib[w]
for h in range(H):
for w in range(W):
dp[h + 1][w] = (dp[h + 1][w] + dp[h][w] * calc(w - 1) * calc(W - w - 2)) % MOD
if w + 1 < W:
dp[h + 1][w + 1] = (dp[h + 1][w + 1] + dp[h][w] * calc(w - 1) * calc(W - w - 3) % MOD)
if w - 1 >= 0:
dp[h + 1][w - 1] = (dp[h + 1][w - 1] + dp[h][w] * calc(w - 2) * calc(W - w - 2) % MOD)
print(dp[H][K - 1] % MOD)
```
Yes
| 89,072 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
h,w,k = map(int,input().split())
dp = [[0]*w for i in range(h+1)]
mod = 1000000007
dp[0][k-1] = 1
a = [1,1,2,3,5,8,13,21]
for i in range(h):
for j in range(w):
if j != 0:
if j == w-1 or j == 1:
dp[i+1][j] += dp[i][j-1]*(a[w-2])%mod
else:
dp[i+1][j] += dp[i][j-1]*(a[j-1]*a[w-1-j])%mod
if j != w-1:
if j == 0 or j == w-2:
dp[i+1][j] += dp[i][j+1]*(a[w-2])%mod
else:
dp[i+1][j] += dp[i][j+1]*(a[j]*a[w-2-j])%mod
if j == 0 or j == w-1:
dp[i+1][j] += dp[i][j]*(a[w-1])%mod
else:
dp[i+1][j] += dp[i][j]*(a[j]*a[w-1-j])%mod
print(dp[h][0]%mod)
```
Yes
| 89,073 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
from functools import lru_cache
input_lst = list(map(int, input().split()))
h, w, k = input_lst[0], input_lst[1], input_lst[2]
def row_comb(w):
if w <= 0:
return 0
if w == 1:
return 1
if w == 2:
return 2
else:
return row_comb(w-2)+row_comb(w-1)
@lru_cache(maxsize=1000)
def trio(h,w):
if h == 0:
return [1] + [0 for i in range(10)]
else:
lst = []
for i in range(1, w+1):
if i == 1:
lst.append(trio(h-1,w)[0] * row_comb(w-1) + trio(h-1,w)[1] * row_comb(w-2))
elif i == w:
lst.append(trio(h-1,w)[w-1] * row_comb(w-1) + trio(h-1,w)[w-2] * row_comb(w-2))
elif i == 2:
lst.append(trio(h-1,w)[0] * row_comb(w-2) + trio(h-1,w)[2] * row_comb(w-3) + trio(h-1,w)[1] * row_comb(w-2))
elif i == w-1:
lst.append(trio(h-1,w)[w-1] * row_comb(w-2) + trio(h-1,w)[w-3] * row_comb(w-3) + trio(h-1,w)[w-2] * row_comb(w-2))
elif i > 2 and i < w-1:
a = row_comb(i-2) * row_comb(w-i)
b = row_comb(i-1) * row_comb(w-i-1)
c = row_comb(i-1) * row_comb(w-i)
lst.append(trio(h-1,w)[i-2] * a + trio(h-1,w)[i] * b + trio(h-1,w)[i-1] * c)
lst = lst + [0 for i in range(10)]
return lst
print(trio(h, w)[k-1] % 1000000007)
```
No
| 89,074 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")
#A
def A():
x, y = LI()
print(x+y//2)
return
#B
def B():
II()
t, a = LI()
h = LI()
ans = [0,inf]
for num, i in enumerate(h):
if ans[1] > abs(t - a - i * 0.006):
ans = [num, abs(t - a - i * 0.006)]
print(ans[0] + 1)
return
#C
def C():
n, m = LI()
py = LIR(m)
pya = py[::1]
py.sort(key=lambda x: x[1])
city = [1 for i in range(n)]
dicity = {}
for p, y in py:
dicity[(p,y)] = city[p-1]
city[p-1] += 1
for p, y in pya:
a = "00000" + str(p)
a = a[-6:]
b = "00000" + str(dicity[(p, y)])
b = b[-6:]
print(a+b)
return
#D
def D():
h, w, k = LI()
stick = [[0, 0] for i in range(w)]
stick[0] = [1, 0]
for i in range(1, w):
stick[i][0] += stick[i - 1][0] + stick[i - 1][1]
stick[i][1] += stick[i - 1][0]
dp1 = [0] * (w + 2)
dp1[1] = 1
for i in range(h):
dp2 = [0] * (w + 2)
for wi in range(1, w + 1):
dp2[wi] = dp1[wi - 1] * stick[wi - 1][1] + dp1[wi + 1] * stick[w - wi][1] + dp1[wi] * stick[wi - 1][0] * stick[w - wi][0]
dp2[wi] %= mod
dp1 = dp2
print(dp2[k])
return
#Solve
if __name__ == '__main__':
D()
```
No
| 89,075 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
H,W,K=map(int,input().split())
if W==1:
print(1)
quit()
INF=1e9+7
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1
d=W-1
a=max(0,d-1)
b=max(0,d-2)
dic={0:0,1:1,2:2,3:4,4:7,5:12,6:20}
a=dic[a]+1
b=dic[b]+1
def func(w):
c=dic[w-1]+1
e=dic[d-w-1]+1
return c*e
def func1(w):
c=dic[w-1-1]+1
e=dic[d-w-1]+1
return c*e
def func2(w):
c=dic[w-1]+1
e=dic[d-w-1-1]+1
return c*e
for i in range(H):
for w in range(W):
if w==0:
dp[i+1][w]=(dp[i][w]*a)+(dp[i][w+1]*b)
dp[i+1][w]%=INF
elif w==W-1:
dp[i+1][w]=(dp[i][w]*a)+(dp[i][w-1]*b)
dp[i+1][w]%=INF
elif w==1 :
dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*b)+(dp[i][w+1]*func2(w))
dp[i+1][w]%=INF
elif w==W-2:
dp[i+1][w]=(dp[i][w]*b)+(dp[i][w-1]*func1(w))+(dp[i][w+1]*b)
dp[i+1][w]%=INF
else:
dp[i+1][w]=(dp[i][w]*func(w))+(dp[i][w-1]*func1(w))+(dp[i][w+1]*func2(w))
dp[i+1][w]%=INF
print(int(dp[H][K-1]%INF))
```
No
| 89,076 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Amidakuji is a traditional method of lottery in Japan.
To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and the endpoints of the horizontal lines must be at 1, 2, 3, ..., or H [cm] from the top of a vertical line.
A valid amidakuji is an amidakuji that satisfies the following conditions:
* No two horizontal lines share an endpoint.
* The two endpoints of each horizontal lines must be at the same height.
* A horizontal line must connect adjacent vertical lines.
<image>
Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we trace the path from the top of the leftmost vertical line to the bottom, always following horizontal lines when we encounter them, we reach the bottom of the K-th vertical line from the left.
For example, in the following amidakuji, we will reach the bottom of the fourth vertical line from the left.
<image>
Constraints
* H is an integer between 1 and 100 (inclusive).
* W is an integer between 1 and 8 (inclusive).
* K is an integer between 1 and W (inclusive).
Input
Input is given from Standard Input in the following format:
H W K
Output
Print the number of the amidakuji that satisfy the condition, modulo 1\ 000\ 000\ 007.
Examples
Input
1 3 2
Output
1
Input
1 3 1
Output
2
Input
2 3 3
Output
1
Input
2 3 1
Output
5
Input
7 1 1
Output
1
Input
15 8 5
Output
437760187
Submitted Solution:
```
h,w,k=map(int,input().split())
ws=[0]*10
ws[0]=1
ws[1]=1
for i in range(2,10):
ws[i]=ws[i-1]+ws[i-2]
dp=[[0 for i in range(h+1)] for j in range(w)]
dp[0][0]=1
mod=10**9+7
if w==1:
print(1)
exit()
for i in range(h):
for j in range(w):
if j==0:
dp[0][i+1]=dp[0][i]*ws[w-1]+dp[1][i]*ws[max(0,w-2)]
dp[0][i+1]%=mod
elif j==w-1:
dp[w-1][i+1]=dp[w-1][i]*ws[w-1]+dp[w-2][i]*ws[max(0,w-2)]
dp[w-1][i+1]%=mod
else:
dp[j][i+1]=dp[j][i]*ws[max(0,j)]*ws[max(0,w-j-1)]+dp[j-1][i]*ws[max(0,j-2)]*ws[max(0,w-j-1)]+dp[j+1][i]*ws[max(0,j-1)]*ws[max(0,w-j-2)]
dp[j][i+1]%=mod
print(dp[k-1][h]%mod)
```
No
| 89,077 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
n,x = map(int, input().split())
a = [int(input()) for i in range(n)]
print((x-sum(a))//min(a) + n)
```
| 89,078 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
N,X=map(int,input().split())
m=[int(input()) for _ in range(N)]
#print(m)
print(N+(X-sum(m))//min(m))
```
| 89,079 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
N, X = map(int, input().split())
L = [int(input()) for i in range(N)]
print((X-sum(L))//min(L)+N)
```
| 89,080 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
import sys
N,X=map(int,input().split())
m=[int(input()) for i in range(N)]
X-=sum(m)
print(N+X//min(m))
```
| 89,081 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
n,x=map(int,input().split())
M=sorted([int(input()) for i in range(n)])
print(len(M)+(x-sum(M))//M[0])
```
| 89,082 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
n,x=map(int,input().split())
m=[int(input()) for i in range(n)]
print(int((x-sum(m))/min(m))+len(m))
```
| 89,083 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
n, x = map(int, input().split())
a = [int(input()) for i in range(n)]
print(n+(x-sum(a))//(min(a)))
```
| 89,084 |
Provide a correct Python 3 solution for this coding contest problem.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
"Correct Solution:
```
n,x = map(int,input().split())
M = [int(input()) for i in range(n)]
print(n+(x-sum(M))//min(M))
```
| 89,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
N,X=map(int,input().split())
donut=[int(input()) for i in range(N)]
print((X-sum(donut))//min(donut)+N)
```
Yes
| 89,086 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
n,x=map(int, input().split())
a=[int(input()) for i in range(n)]
x=x-sum(a)
print(x//min(a)+n)
```
Yes
| 89,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
n,x = map(int,input().split())
d = [int(input()) for i in range(n)]
x -= sum(d)
print(n + x//min(d))
```
Yes
| 89,088 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]
print(len(M) + (X-sum(M))//min(M))
```
Yes
| 89,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
N,X = map(int,input().split())
m = []
for i in range(N):
m.append(int(input()))
X-=sum(m)
cnt=len(m)
while X>min(m):
X-=min(m)
cnt+=1
print(cnt)
```
No
| 89,090 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]
ans = len(M)
X = X - sum(M)
while X >= min(M):
X = X - min(M)
ans += 1
print(ans, X)
```
No
| 89,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
n,maxg=map(int,input().split())
lista =[int(input()) for i in range(n)]
count=count+n
nokori=maxg-sum(lista)
print(count)
while nokori-min(lista)>=0:
nokori=nokori-min(lista)
count+=1
print(count)
```
No
| 89,092 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts.
Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition:
* For each of the N kinds of doughnuts, make at least one doughnut of that kind.
At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
Constraints
* 2 ≤ N ≤ 100
* 1 ≤ m_i ≤ 1000
* m_1 + m_2 + ... + m_N ≤ X ≤ 10^5
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N X
m_1
m_2
:
m_N
Output
Print the maximum number of doughnuts that can be made under the condition.
Examples
Input
3 1000
120
100
140
Output
9
Input
4 360
90
90
90
90
Output
4
Input
5 3000
150
130
150
130
110
Output
26
Submitted Solution:
```
# -*- coding: utf-8 -*-
def main():
N, X = map(int, input().split())
m = []
for i in range(N):
m.append(int(input()))
ans = 0
sumM = 0
flag = False
for i in m:
sumM += i
ans += 1
m.sort()
while sumM < X:
sumM += m[0]
if sumM < X:
ans += 1
print(ans)
if __name__ == "__main__":
main()
```
No
| 89,093 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
a=int("".join(list(input().split())))
print("YES" if a%4==0 else "NO")
```
| 89,094 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
print('NO' if int(input().replace(' ',''))%4 else 'YES')
```
| 89,095 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
n = list(input().split())
print("YES" if int("".join(n))%4==0 else "NO")
```
| 89,096 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
x = input().split()
print('YES' if int("".join(x)) % 4 == 0 else'NO')
```
| 89,097 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
print("YES" if int("".join(list(input().split()))) % 4 == 0 else "NO")
```
| 89,098 |
Provide a correct Python 3 solution for this coding contest problem.
AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
Constraints
* 1 ≤ r, g, b ≤ 9
Input
Input is given from Standard Input in the following format:
r g b
Output
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`.
Examples
Input
4 3 2
Output
YES
Input
2 3 4
Output
NO
"Correct Solution:
```
print('YNEOS'[(int(input()[::2]))%4>0::2])
```
| 89,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.