output_description
stringlengths 15
956
| submission_id
stringlengths 10
10
| status
stringclasses 3
values | problem_id
stringlengths 6
6
| input_description
stringlengths 9
2.55k
| attempt
stringlengths 1
13.7k
| problem_description
stringlengths 7
5.24k
| samples
stringlengths 2
2.72k
|
---|---|---|---|---|---|---|---|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s229790838
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
n = "Three"
for i in range(N):
S = input().split()
If S == "Y":
n = "Four"
break
print(n)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s490008777
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
ball_list = []
for i in range(N):
ball_list.append(int(input()))
print(len(list(set(ball_list)))
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s461063338
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
n = Three
for i in (N):
S = input().split()
If S == "Y":
n = "Four"
break
print(n)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s188844508
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n=int(input())
dic={}.fromkeys(map(str,input().split()))
if len(dic)==3:
print("Three")
if len(dic)==4::
print("Four")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s277672225
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
n = "three"
for i in (N):
S = input().split()
If S == "Y":
n = "four"
break
print(n)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s807531777
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
# ABC089B
n = int(input())
s = list(map(int, input().split)))
if len(set(s)) == 4:
print('Three')
else:
print('Four')
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s204109410
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
n = "three"
for i in (N):
S = input().split()
If S == Y:
n = "four"
break
print(n)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s764781526
|
Accepted
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
# Author: cr4zjh0bp
# Created: Thu Mar 12 19:40:42 UTC 2020
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
N = ni()
S = nas()
c = dict()
for i in range(N):
c[S[i]] = 1
print("Three" if len(c.items()) == 3 else "Four")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s404739951
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n = int(input())
s = list(input().split())
for i in range(n):
if s[i] == "Y":
print("four")
break
elif i == n-1:
print("Tree")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s152839344
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n = int(input())
lis = input().split()
for i in range(n):
if lis[i] == 'Y':
print('Four')
break
else:
if i == n-1
print('Three')
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s224670845
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
v = []
for i in range(N):
s = input()
if !(s in v):
v.append(s);
if len(v) == 3:
print("Three")
else:
print("Four")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s857169333
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n = int(input())
lis = input().split()
count = 0
for i in range(n):
if lis[i] == 'Y':
print('Four')
break
else:
if(count == n-1)
print('Three')
count++
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s791220591
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = input()
S = input()
char_list = list(S.split(" "))
result = "Three"
for i in range(N):
if char_list[i] == "Y":
result = "Four"
print(result)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s933781657
|
Accepted
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
i = open(0).read().split()[1:]
print(["Three", "Four"]["Y" in i])
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s146570131
|
Accepted
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
print("TFhoruere"["Y" in open(0).read() :: 2])
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s300640867
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
sl = [i for i in -input().split()]
print(["Three", "Four"][len(set(sl)) == 4])
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s710351336
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n=input()
a=input().split()
print(("Three","Four")[len(set(a))==4]
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s318835807
|
Wrong Answer
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n = int(input())
s = [map(int, input().split())]
s_s = set(s)
print(len(s_s))
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s275924057
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
i=open(0).read().split()[1:]
print(["Three","Four"][if "Y" in i])
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s518967950
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N=int(input())
NCount = 0
while N =>0:
NCount+= 1
N -=3
print(NCount-1)
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s020386090
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
a, b, c = map(int, input().split())
print("Yes" if a <= c <= b else "No")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s045926413
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
print("TFhoruere"[len(set(map(int, open(0).read().split()))) - 4 :: 2])
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s626770870
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
N = int(input())
s = list(map(int, input().split())
if "Y" in s:
print("Four")
else:
print("Three")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s235716224
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n=int(input())
s=list(map(int,input().split()))
print('Three' if len(list(set(s))))==3 else 'Four')
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s743381467
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
a = input()
b = list(map(int,input()split()))
if 'Y' in b:
print('Four')
else:
print('Three')
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s644421137
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n=iny(input())
a=set(list(input().split())
if len(a)==3:
print("Three")
else:
print("Four")
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
* * *
|
s117876680
|
Runtime Error
|
p03424
|
Input is given from Standard Input in the following format:
N
S_1 S_2 ... S_N
|
n = int(input())
sl = [i for i in input().split()]
print(["Three", "Four"][len(set(sl)) == 4]
|
Statement
In Japan, people make offerings called _hina arare_ , colorful crackers, on
March 3.
We have a bag that contains N hina arare. (From here, we call them arare.)
It is known that the bag either contains arare in three colors: pink, white
and green, or contains arare in four colors: pink, white, green and yellow.
We have taken out the arare in the bag one by one, and the color of the i-th
arare was S_i, where colors are represented as follows - pink: `P`, white:
`W`, green: `G`, yellow: `Y`.
If the number of colors of the arare in the bag was three, print `Three`; if
the number of colors was four, print `Four`.
|
[{"input": "6\n G W Y P Y W", "output": "Four\n \n\nThe bag contained arare in four colors, so you should print `Four`.\n\n* * *"}, {"input": "9\n G W W G P W P G G", "output": "Three\n \n\nThe bag contained arare in three colors, so you should print `Three`.\n\n* * *"}, {"input": "8\n P Y W G Y W Y Y", "output": "Four"}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s871287767
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
# create date: 2020-07-03 22:02
import sys
stdin = sys.stdin
from itertools import groupby, accumulate
def ns():
return stdin.readline().rstrip()
def ni():
return int(ns())
def na():
return list(map(int, stdin.readline().split()))
def main():
n, k = na()
s = ns()
a = list()
if s[0] == "0":
a.append(0)
gr = groupby(s)
for key, group in gr:
a.append(len(list(group)))
if s[-1] == "0":
a.append(0)
acum = list(accumulate(a))
m = len(acum)
l = 2 * k + 1
if m == 1:
print(acum[0])
quit()
if l > m:
print(acum[-1])
quit()
ans = acum[l - 1]
for i in range(0, m - l + 1, 2):
ans = max(ans, acum[i + l - 1] - acum[i - 1])
print(ans)
if __name__ == "__main__":
main()
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s164738150
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
t, s = open(0)
n, k = map(int, t.split())
l = 2 * k + 1
x = [0] * (2 + int(s[0])) + [i + 1 for i in range(n - 1) if s[i] != s[i + 1]] + [n] * l
print(max(x[i + l] - x[i] for i in range(0, len(x) - l, 2)))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s971052741
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
def main():
N, K = map(int, input().split())
S = input()
class LL:
def __init__(self, v, p, n):
self.v = v
self.p = p
self.n = n
T = []
m = 0
for s in S:
if s == "0":
if m >= 0:
T.append(m)
m = 0
m -= 1
else:
if m < 0:
T.append(-m)
m = 0
m += 1
T.append(abs(m))
if m < 0:
T.append(0)
m = t = sum(T[: K * 2 + 1])
L = K * 2 + 1
for i in range(0, len(T) - L, 2):
t = t + T[L + i] + T[L + i + 1] - T[i] - T[i + 1]
m = max(m, t)
print(m)
main()
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s942938693
|
Runtime Error
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = list(map(int, input().split()))
S = input()
ans = -1 # 十分に小さい値
if (S[0] == '0'):
stand = 1
else:
stand = 0
l = 0
r = 0
# 尺取り法
while (r < N):
# 右端を進めることが可能(進めたときの積がK以下)なら、右端を進める
if (stand <= K):
ans = max(ans, r - l + 1)
if (S[r] == '1' and S[r + 1] == '0'):
stand += 1
r += 1
# 進められない場合、左端と右端が同じなら両者を進める
# 左端が右端を追い越さないための処理
elif (l == r):
l += 1
r += 1
# それ以外は左端のみを進める
else:
if S[l] == '0' and if S[l + 1] == '1':
stand -= 1
l += 1
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s906169600
|
Runtime Error
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
n,k=list(map(int,input().split()))
t=input()
z=[]
p=t[0]
if t[0]=="0":
z.append(0)
z.append(0)
for i in t:
if i == p:
z[-1]+=1
eln,k=list(map(int,input().split()))
t=input()
z=[]
p=t[0]
if t[0]=="0":
z.append(0)
z.append(0)
for i in t:
if i == p:
z[-1]+=1
else:
p=i
z.append(1)
if k*2+1 >= len(z):
r=n
else:
p=sum(z[:2*k+1])
r=p
for i in range(0,len(z)-2*k-2,2):
e=z[i]+z[i+1]
p-=e
f=z[2*k+i+1]+z[2*k+i+2]
p+=f
r=max(r,p)
print(r)se:
p=i
z.append(1)
if k*2+1 >= len(z):
r=n
else:
p=sum(z[:2*k+1])
r=p
for i in range(0,len(z)-2*k-2,2):
e=z[i]+z[i+1]
p-=e
f=z[2*k+i+1]+z[2*k+i+2]
p+=f
r=max(r,p)
print(r)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s855653378
|
Runtime Error
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K= map(int, input().split())
S = input()
ones_list = S.split('0')
zeros_list = S.split('1')
ones = []
if S[0] == '0':
ones.append(0)
for k in range(len(ones_list)):
if ones_list[k] != '':
ones.append(len(ones_list[k]))
if S[-1] == '0':
ones.append(0)
zeros = []
for k in range(len(zeros_list)):
if zeros_list[k] != '':
zeros.append(len(zeros_list[k]))
if K >= len(zeros):
print(len(S))
else:
result = []
maximum = 0
for k in range(K):
maximum += ones[k]
maximum += zeros[k]
maximum += ones[K]
result.append(maximum)
for j in range(len(ones) - K - 1):
maximum += zeros[K+j] + ones[K+1+j] - ones[j] - zeros[j]
result.append(maximum)
print(max(result))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s657590210
|
Runtime Error
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = map(int, input().split())
S = list(map(int, input()))
Z = [j for j, s in enumerate(S) if (j > 0 and s == 0 and S[j] != S[j-1]) or (j == 0 and s == 0)] + [N]
Y = [j for j, s in enumerate(S) if (j > 0 and s == 1 and S[j] != S[j-1]) or (j == 0 and s == 1)]
result = 0
if len(Z) <= K:
print(N)
else:
for i in range(len(Z)-K):
if i == 0:
result = Z[i+K]
else:
result = max(result, Z[i+K] - Y[i if Y[0] < Z[0] else i-1])
print(result)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s005347499
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
n, k = map(int, input().split())
print(n)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s024575311
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
a, b = map(int, input().split())
print(max(a + b, a * 2 - 1, b * 2 - 1))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s775270864
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
22
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s758587587
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
while True:
N, k = map(int, input().split())
S = input()
lenth = 0
AllLen = []
preS0, preS1 = S.split("1"), S.split("0")
S0 = [i for i in preS0 if i != ""]
S1 = [i for i in preS1 if i != ""]
num0 = k
if len(S0) <= k:
print(len(S))
break
if S[0] == "0":
J = k
else:
J = k + 1
FirstLen = sum([len(S0[i]) for i in range(k)]) + sum([len(S1[j]) for j in range(J)])
AllLen.append(FirstLen)
CheckLen = FirstLen
if S[0] == "1" and S[-1] == "1":
for i in range(len(S0) - k):
CheckLen = (
CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
)
AllLen.append(CheckLen)
if S[0] == "0" and S[-1] == "1":
CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
AllLen.append(CheckLen)
for i in range(len(S0) - k - 1):
CheckLen = (
CheckLen
- len(S0[i + 1])
- len(S1[i + 1])
+ len(S0[i + k + 1])
+ len(S1[i + k + 1])
)
AllLen.append(CheckLen)
if S[0] == "1" and S[-1] == "0":
for i in range(len(S0) - k - 1):
CheckLen = (
CheckLen - len(S0[i]) - len(S1[i]) + len(S0[i + k]) + len(S1[i + k + 1])
)
AllLen.append(CheckLen)
CheckLen = (
CheckLen
- len(S0[len(S0) - k - 1])
- len(S1[len(S0) - k - 1])
+ len(S0[len(S0) - 1])
)
AllLen.append(CheckLen)
if S[0] == "0" and S[-1] == "0":
if len(S1) == 1:
print(len(max(S0)) + len(S1[0]))
exit()
CheckLen = CheckLen - len(S0[0]) + len(S0[k]) + len(S1[k])
AllLen.append(CheckLen)
for i in range(len(S0) - k - 2):
CheckLen = (
CheckLen
- len(S0[i + 1])
- len(S1[i + 1])
+ len(S0[i + k + 1])
+ len(S1[i + k + 1])
)
AllLen.append(CheckLen)
CheckLen = (
CheckLen
- len(S0[len(S0) - k - 1])
- len(S1[len(S0) - k - 1])
+ len(S0[len(S0) - 1])
)
AllLen.append(CheckLen)
print(max(AllLen))
break
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s738885392
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = [int(_c) for _c in input().split(" ")]
S = input()
def cal(_S):
cum = [0]
flg = False
cur_zero = 0
cur_one = 0
for i, s in enumerate(_S):
if s == "0":
if flg:
cum.append(cum[-1] + cur_zero + cur_one)
flg = False
cur_zero = 0
cur_one = 0
cur_zero += 1
else:
if cur_zero != 0:
flg = True
cur_one += 1
cum.append(cum[-1] + cur_zero + cur_one)
return cum
def main():
cum_l = cal(S)
cum_r = cal(S[::-1])
if K - 1 > len(cum_l):
print(len(S))
else:
longest = 0
for i in range(len(cum_l) - K):
total = cum_l[i + K] - cum_l[i]
if total > longest:
longest = total
for i in range(len(cum_r) - K):
total = cum_r[i + K] - cum_r[i]
if total > longest:
longest = total
print(longest)
main()
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s735167782
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
# AtCoder Beginner Contest 124
# https://atcoder.jp/contests/abc124
import sys
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nnn = lambda n: ss2nnn(ii2ss(n))
def grouping(N, S):
group = []
s = S[0]
c = 1
for i in range(1, N):
if S[i] == s:
c += 1
else:
group.append((s, c))
s = S[i]
c = 1
group.append((s, c))
return group
def main(N, K, S):
g = grouping(N, S)
glen = len(g)
# 累積和(cumsum)
cs = [0] * (glen + 1)
for i in range(glen):
cs[i + 1] = cs[i] + g[i][1]
nm = 0
for i in range(glen):
if g[i][0] == "0":
n = cs[min(i + 2 * K, glen)] - cs[i]
else:
n = cs[min(i + 2 * K + 1, glen)] - cs[i]
if n > nm:
nm = n
print(nm)
N, K = i2nn()
S = i2s()
main(N, K, S)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s448329413
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = map(int, input().split())
S = str(input())
# count sequence man and memo the cnt in group
man_groups = []
same_cnt = 0
last_man = ""
for i in range(N):
cur_man = S[i]
if cur_man != last_man:
if same_cnt > 0:
if last_man == "0":
same_cnt *= -1
man_groups.append(same_cnt)
same_cnt = 1
else:
same_cnt += 1
last_man = cur_man
if same_cnt > 0:
if last_man == "0":
same_cnt *= -1
man_groups.append(same_cnt)
# count max from evey
sum_list = []
end_pos = 2 * K if man_groups[0] > 0 else 2 * K - 1
end_pos = min(end_pos, len(man_groups) - 1)
last_max = sum(map(abs, man_groups[0 : end_pos + 1]))
sum_list.append(last_max)
for i in range(1, len(man_groups)):
if end_pos >= len(man_groups) - 1:
break
last_max -= abs(man_groups[i - 1])
if man_groups[i] > 0:
next_end_pos = min(end_pos + 2, len(man_groups) - 1)
man_groups_to_add = man_groups[end_pos + 1 : next_end_pos + 1]
last_max += sum(map(abs, man_groups_to_add))
end_pos = next_end_pos
sum_list.append(last_max)
# print(sum_list)
# print(sum_list)
print(max(sum_list))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s205176505
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = map(int, input().split())
S = input()
S = "0" + S + "0"
lis = []
for i in range(1, N + 2):
if S[i - 1] == "0" and S[i] == "1":
lis.append([i])
if S[i - 1] == "1" and S[i] == "0":
lis[-1].append(i - 1)
leng = len(lis)
ans = 0
if S[1] == "1" and S[N] == "1":
if K >= leng - 1:
ans = N
else:
for i in range(leng):
if i + K < leng:
newan = lis[i + K][1] - lis[i][0] + 1
ans = max(ans, newan)
print(ans)
elif S[1] == "1" and S[N] == "0":
if K >= leng:
ans = N
else:
for i in range(leng):
if i + K < leng:
newan = lis[i + K][1] - lis[i][0] + 1
ans = max(ans, newan)
print(ans)
elif S[1] == "0" and S[N] == "1":
if K >= leng:
ans = N
else:
for i in range(leng):
if i + K < leng:
newan = lis[i + K][1] - lis[i][0] + 1
ans = max(ans, newan)
ans = max(ans, lis[K - 1][1])
print(ans)
elif S[1] == "0" and S[N] == "0":
if K - 1 >= leng:
ans = N
else:
for i in range(leng):
if i + K < leng:
newan = lis[i + K][1] - lis[i][0] + 1
ans = max(ans, newan)
ans = max(ans, lis[K - 1][1])
ans = max(ans, N - lis[leng - K][0] + 1)
print(ans)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s997982847
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
n, k = map(int, input().split())
s = list(map(int, str(input())))
if s[0] == 1:
one_st = [0] + [i + 1 for i in range(n - 1) if s[i] == 0 and s[i + 1] == 1]
zero_st = [i + 1 for i in range(n - 1) if s[i] == 1 and s[i + 1] == 0]
else:
one_st = [i + 1 for i in range(n - 1) if s[i] == 0 and s[i + 1] == 1]
zero_st = [0] + [i + 1 for i in range(n - 1) if s[i] == 1 and s[i + 1] == 0]
if s[n - 1] == 1:
one_en = [i for i in range(n - 1) if s[i] == 1 and s[i + 1] == 0] + [n - 1]
zero_en = [i for i in range(n - 1) if s[i] == 0 and s[i + 1] == 1]
else:
one_en = [i for i in range(n - 1) if s[i] == 1 and s[i + 1] == 0]
zero_en = [i for i in range(n - 1) if s[i] == 0 and s[i + 1] == 1] + [n - 1]
if len(zero_st) <= k:
x = n
else:
y = [
one_en[i + k] - one_st[i] + 1
for i in range(len(zero_st) - k + 1)
if i + k + 1 <= len(one_en)
]
y = y + [one_en[k - 1] + 1, n - one_st[len(one_st) - k]]
x = max(y)
print(x)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s004212312
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
n, k = map(int, input().split())
s = input()
s_list = []
first = s[0]
last = s[n - 1]
state = first
length = 1
for i in range(1, n):
if (state == "0" and s[i] == "0") or (state == "1" and s[i] == "1"):
state = s[i]
length = length + 1
else:
state = s[i]
s_list.append(length)
length = 1
s_list.append(length)
m = len(s_list)
if first == "0" and last == "0":
if (len(s_list) + 1) / 2 <= k:
Max = n
else:
p_list = s_list[0 : 2 * k]
Sum = sum(p_list)
Max = Sum
i = 1
p_list = s_list[i : i + 2 * k + 1]
Sum = sum(p_list)
if Sum > Max:
Max = Sum
i = i + 2
while i + 2 * k < m - 1:
Sum = (
Sum
- s_list[i - 2]
- s_list[i - 1]
+ s_list[i + 2 * k - 1]
+ s_list[i + 2 * k]
)
if Sum > Max:
Max = Sum
i = i + 2
p_list = s_list[m - 2 * k :]
if sum(p_list) > Max:
Max = sum(p_list)
elif first == "0" and last == "1":
if len(s_list) / 2 <= k:
Max = n
else:
p_list = s_list[0 : 2 * k]
Sum = sum(p_list)
Max = Sum
i = 1
p_list = s_list[i : i + 2 * k + 1]
Sum = sum(p_list)
if Sum > Max:
Max = Sum
i = i + 2
while i + 2 * k <= m - 1:
Sum = (
Sum
- s_list[i - 2]
- s_list[i - 1]
+ s_list[i + 2 * k - 1]
+ s_list[i + 2 * k]
)
if Sum > Max:
Max = Sum
i = i + 2
elif first == "1" and last == "0":
if len(s_list) / 2 <= k:
Max = n
else:
p_list = s_list[0 : 2 * k + 1]
Sum = sum(p_list)
Max = Sum
i = 2
while i + 2 * k < m - 1:
Sum = (
Sum
- s_list[i - 2]
- s_list[i - 1]
+ s_list[i + 2 * k - 1]
+ s_list[i + 2 * k]
)
if Sum > Max:
Max = Sum
i = i + 2
p_list = s_list[m - 2 * k :]
if sum(p_list) > Max:
Max = sum(p_list)
elif first == "1" and last == "1":
if (len(s_list) - 1) / 2 <= k:
Max = n
else:
p_list = s_list[0 : 2 * k + 1]
Sum = sum(p_list)
Max = Sum
i = 2
while i + 2 * k <= m - 1:
Sum = (
Sum
- s_list[i - 2]
- s_list[i - 1]
+ s_list[i + 2 * k - 1]
+ s_list[i + 2 * k]
)
if Sum > Max:
Max = Sum
i = i + 2
print(Max)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s359250086
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, input().split())
# 01文字列の入力
s = str(input())
# 01文字列を配列に一文字ずつ格納
hito = list(s)
irekaeCnt = 0
listSakadachiCnt = []
sakadachiCnt = 0
tmpMaxCnt = 0
# 初期状態での連続逆立ち人数
for i in range(len(hito)):
if hito[i] == "1":
sakadachiCnt += 1
else:
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
sakadachiCnt = 0
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
listSakadachiCnt.append(tmpMaxCnt)
sakadachiCnt = 0
tmpMaxCnt = 0
# 0の出現箇所
listZeroFrom = []
listZeroTO = []
prevIsZero = False
# 0の開始終了位置
for i in range(len(hito)):
if hito[i] == "0" and prevIsZero == False:
listZeroFrom.append(i)
prevIsZero = True
elif hito[i] == "1" and prevIsZero == True:
listZeroTO.append(i)
prevIsZero = False
if prevIsZero == True:
listZeroTO.append(len(hito) - 1)
prevIsZero = False
# n回まで入れ替え可能
for j in range(n):
# 01文字列を配列に一文字ずつ格納
hito = list(s)
irekaeCnt = 0
# if len(listZeroFrom) < j :
# for f in range(listZeroFrom[j],listZeroTO[j]):
# hito[f] = "1"
# irekaeCnt += 1
# j += 1
for k in range(len(listZeroFrom)):
# print("len(listZeroFrom):{},len(listZeroFrom):{},k:{}".format(len(listZeroFrom),len(listZeroTO),str(k)))
for l in range(listZeroFrom[k], listZeroTO[k]):
# print("hito[{}]:{}".format(l,hito[l]))
hito[l] = "1"
# print("hito[{}]:{}".format(l,hito[l]))
irekaeCnt += 1
# 連続逆立ち人数
sakadachiCnt = 0
tmpMaxCnt = 0
for m in range(len(hito)):
# print("hito[{}]:{}".format(m,hito[m]))
if hito[m] == "1":
sakadachiCnt += 1
else:
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
sakadachiCnt = 0
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
listSakadachiCnt.append(tmpMaxCnt)
if irekaeCnt == j:
sakadachiCnt = 0
tmpMaxCnt = 0
# 連続逆立ち人数
for m in range(len(hito)):
# print("hito[{}]:{}".format(m,hito[m]))
if hito[m] == "1":
sakadachiCnt += 1
else:
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
sakadachiCnt = 0
if tmpMaxCnt < sakadachiCnt:
tmpMaxCnt = sakadachiCnt
listSakadachiCnt.append(tmpMaxCnt)
# 01文字列を配列に一文字ずつ格納
hito = list(s)
irekaeCnt = 0
# for p in range(len(listSakadachiCnt)):
# print(str(listSakadachiCnt[p]))
listSakadachiCnt.sort(reverse=True)
# 出力
print(str(listSakadachiCnt[0]))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s950626504
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = [int(i) for i in input().split()]
S = list(map(int, list(input())))
start = S[0]
row = []
state = [0, start]
for i in S:
if i == start:
state[0] += 1
else:
row.append(state)
start = i
state = [1, i]
row.append(state)
ans1 = 0
for i in range(max(len(row) - K * 2, 1)):
if row[i][1] == 1:
t = sum([row[i][0] for i in range(i, min(K * 2 + i + 1, len(row)))])
if t > ans1:
ans1 = t
else:
t = sum([row[i][0] for i in range(i, min(K * 2 + i, len(row)))])
if t > ans1:
ans1 = t
print(ans1)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s324632584
|
Accepted
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
import queue
def read_input():
n, k = map(int, input().split())
s = list(map(int, list(str(input()))))
return n, k, s
# 0, 1, ....を(0, n1), (1, n2)みたいな形にする
def convert_01(s):
result = []
result.append([s[0], 1])
for ss in s[1:]:
if result[-1][0] == ss:
result[-1][1] += 1
else:
result.append([ss, 1])
return result
# index以降の要素、かつ0の数がKを下回るサブリストにある要素をカウントする
def get_count(r, k):
count = 0
max_count = 0
zeros = 0
q = queue.Queue()
for e in r:
if e[0] == 0 and zeros >= k:
# すでにk回0を操作した
while True:
t = q.get()
count -= t[1]
if t[0] == 0:
zeros -= 1
break
q.put(e)
count += e[1]
if e[0] == 0:
zeros += 1
if max_count < count:
max_count = count
return max_count
if __name__ == "__main__":
n, k, s = read_input()
r = convert_01(s)
print(get_count(r, k))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s607065632
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
import numpy
n, k = map(int, input().split(" "))
tmp = [int(i) for i in list(input())]
person = numpy.array(tmp, dtype=int)
if person[0] == 0:
first = 0
else:
first = 1
length_list = []
length = 1
pre = first
for i in person[1:]:
if i == pre:
length += 1
else:
pre = i
length_list.append(length)
length = 1
length_list.append(length)
length_list_len = len(length_list)
if first == 0:
zero_num = int(length_list_len / 2) + length_list_len % 2
else:
zero_num = int(length_list_len / 2)
if k > zero_num:
print(person.shape[0])
else:
result = []
if first == 0:
result.append(sum(length_list[0 : 2 * k]))
for i in range(1, zero_num):
result.append(sum(length_list[2 * i + 1 : 2 * k + 2 * i + 2]))
else:
for i in range(zero_num):
result.append(sum(length_list[2 * i : 2 * k + 2 * i + 1]))
print(max(result))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s151499489
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = map(int, input().split())
S = str(input())
list_0 = []
list_1 = []
c_0 = 0
c_1 = 0
for i in range(N):
if S[i] == "0":
c_0 += 1
if c_1 != 0:
list_1 += [c_1]
c_1 = 0
elif S[i] == "1":
c_1 += 1
if c_0 != 0:
list_0 += [c_0]
c_0 = 0
if i == N - 1:
if c_0 != 0:
list_0 += [c_0]
elif c_1 != 0:
list_1 += [c_1]
result = 0
if len(list_0) <= K:
result = N
else:
if S[0] == "1" and S[-1] == "1":
for i in range(len(list_1) - K):
result = max(result, sum(list_1[i : i + K + 1]) + sum(list_0[i : i + K]))
elif S[0] == "1" and S[-1] == "0":
result = sum(list_1[-K:]) + sum(list_0[-K:])
for i in range(len(list_1) - K):
result = max(result, sum(list_1[i : i + K + 1]) + sum(list_0[i : i + K]))
elif S[0] == "0" and S[-1] == "0":
result = max(
sum(list_0[:K]) + sum(list_1[:K]), sum(list_0[-K:]) + sum(list_1[-K:])
)
for i in range(len(list_1) - K - 1):
result = max(
result, sum(list_1[i : i + K + 2]) + sum(list_0[i + 1 : i + K + 2])
)
elif S[0] == "0" and S[-1] == "1":
result = sum(list_0[:K]) + sum(list_1[:K])
for i in range(len(list_1) - K - 1):
result = max(
result, sum(list_1[i : i + K + 2]) + sum(list_0[i + 1 : i + K + 2])
)
print(result)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s745896514
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
N, K = map(int, input().split())
S = input()
# print(N,K,S)
# print(type(S[0]))
def LINE_CHANGER(TIME, LENGTH, LINE):
while True:
if TIME == 0:
return MAX_ONE
break
else:
# print(TIME)
LINE_LIST = list(LINE)
# print(LINE_LIST)
NOW = 0
MAX_ONE = 0
COUNTER = 0
BEFORE = 0
POINTER = 0
LINE_ONE = 1
if NOW < LENGTH:
while NOW < LENGTH - 1:
# print("LINECHECK",NOW,LINE_ONE)
# 初めの数が0の時の補正
if LINE[0] == "0" and NOW == 0 or COUNTER == 1:
# print("COUNTER = 1")
COUNTER = 1
else:
# print("COUNTER = 0")
COUNTER = 0
if COUNTER == 1 and LINE[NOW] == "0" and LINE[NOW + 1] == "1":
# print("BEFORECHECK")
BEFORE = NOW
# print("BEFORE=",BEFORE)
NOW += 1
LINE_ONE += 1
elif LINE[NOW] == "1" and LINE[NOW + 1] == "0":
COUNTER += 1
# print("COUNTER +1",COUNTER)
if COUNTER == 2:
# print("COUNTER = 2")
if LINE_ONE > MAX_ONE:
POINTER = NOW - LINE_ONE + 1
MAX_ONE = LINE_ONE
# print("CHANGE MAX_ONE",MAX_ONE,POINTER)
NOW = BEFORE + 1
LINE_ONE = 1
else:
NOW += 1
LINE_ONE += 1
else:
NOW += 1
LINE_ONE += 1
if LINE_ONE > MAX_ONE:
POINTER = NOW - LINE_ONE + 1
MAX_ONE = LINE_ONE
# print("CHANGE MAX_ONE",MAX_ONE,POINTER)
# LINECHANGE
# print("POINTER,MAX_ONE",POINTER,MAX_ONE)
for i in range(POINTER, POINTER + MAX_ONE):
LINE_LIST[i] = "1"
LINE = "".join(LINE_LIST)
# print("LINECHANGE",LINE)
TIME -= 1
print(LINE_CHANGER(K, N, S))
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s729825366
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
nums = input().rstrip().split(" ")
N = int(nums[0])
K = int(nums[1])
next_s = list(input())
f_max_score = 0
for x in range(K):
if next_s.count("0") == 0:
max_score = next_s.count("1")
break
for r in range(1, N):
for l in range(r):
s = next_s
max_score = 0
for i in range(l, r):
if s[i] == "0":
s[i] = "1"
elif s[i] == "1":
s[i] = "0"
score = 0
for y in range(N):
if s[y] == "1":
score = score + 1
if score > max_score:
max_score = score
else:
score = 0
if max_score > f_max_score:
f_max_score = max_score
next_s = s
print(max_score)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s977418420
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
n, k = [int(i) for i in input().split()]
s = input() + "2"
top = int(s[0])
targetIdx = 1 if top % 2 == 0 else 0
target = top
ret = 0
tmpSum = 0
lst = [0] * (k * 2 + 1)
for v in s:
if int(v) == target:
tmpSum += 1
else:
lst.append(tmpSum)
lst = lst[1:]
if int(v) == 0:
ret = max(sum(lst), ret)
if int(v) == 2 and int(s[-2]) == 1:
ret = max(sum(lst), ret)
tmpSum = 1
target = int(v)
print(ret)
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the maximum possible number of consecutive people standing on hands
after at most K directions.
* * *
|
s395866380
|
Wrong Answer
|
p03074
|
Input is given from Standard Input in the following format:
N K
S
|
import sys
N, K = [int(x) for x in input().split()] # N:Sの長さ K:操作を行える回数の最大値
S = [int(x) for x in list(input())] # S:0と1から成る列
index = [0] # index:Sにおいて0と1が切り替わる部分の添字を集めたリスト
length = [0] # length:1が連続して並んでいる長さの最大値の候補を集めたリスト
zeros = 0 # zeros:Sにおいて0が連続して並んでいる箇所がいくつあるか
for i in range(0, len(S) - 1): # indexの要素を取得
if S[i] != S[i + 1]: # 0と1の変わり目を探索
index.append(i + 1)
if S[0] == 0: # Sが0から始まる場合
for i in range(len(index)): # zerosの値を取得
if len(index) % 2 == 0: # indexの長さが偶数である場合
zeros = int(len(index) / 2)
else: # indexの長さが奇数である場合
zeros = int((len(index) + 1) / 2)
for i in range(len(index)): # max(length)の初期値を取得
if S[len(S) - 1] == 0: # Sが0で終わっている場合
if i % 2 == 1:
length.append(index[i + 1] - index[i])
else: # Sが1で終わっている場合
if i % 2 == 1 and (i + 1) < len(index):
length.append(index[i + 1] - index[i])
elif i % 2 == 1 and (i + 1) == len(index): # 最後の1の連続を処理
length.append((len(S) - 1) - index[i] + 1)
for i in range(
len(index)
): # Sのindex[i]番目を左端としたときの1の連続回数の最大値をそれぞれ求める
if K >= zeros: # Kがzeros以上なら0の連続を全て1に置き換えて終了
print(len(S))
sys.exit()
elif i + (2 * K) <= (
len(index) - 1
): # 添字が飛び出ないように注意(飛び出るようなやつはそもそも最大値の候補にならない)
if i % 2 == 0: # 左端が0の場合
length.append(index[(i + (2 * K) - 1) + 1] - index[i])
else: # 左端が1の場合
if i + (2 * K) < (len(index) - 1):
length.append(index[i + (2 * K) + 1] - index[i])
elif i + (2 * K) == (len(index) - 1):
length.append((len(S) - 1) - index[i] + 1)
print(max(length))
sys.exit()
else: # Sが1から始まる場合
for i in range(len(index)): # zerosの値を取得
if len(index) % 2 == 0: # indexの長さが偶数である場合
zeros = int(len(index) / 2)
else: # indexの長さが奇数である場合
zeros = int((len(index) - 1) / 2)
for i in range(len(index)): # max(length)の初期値を取得
if S[len(S) - 1] == 0: # Sが0で終わっている場合
if i % 2 == 0:
length.append(index[i + 1] - index[i])
else: # Sが1で終わっている場合
if i % 2 == 0 and (i + 1) < len(index):
length.append(index[i + 1] - index[i])
elif i % 2 == 0 and (i + 1) == len(index): # 最後の1の連続を処理
length.append((len(S) - 1) - index[i] + 1)
for i in range(
len(index)
): # Sのindex[i]番目を左端としたときの1の連続回数の最大値をそれぞれ求める
if K >= zeros: # Kがzeros以上なら0の連続を全て1に置き換えて終了
print(len(S))
sys.exit()
elif i + (2 * K) <= (
len(index) - 1
): # 添字が飛び出ないように注意(飛び出るようなやつはそもそも最大値の候補にならない)
if i % 2 == 0: # 左端が1の場合
if i + (2 * K) < (len(index) - 1):
length.append(index[i + (2 * K) + 1] - index[i])
elif i + (2 * K) == (len(index) - 1):
length.append((len(S) - 1) - index[i] + 1)
else: # 左端が0の場合
length.append(index[(i + (2 * K) - 1) + 1] - index[i])
print(max(length))
sys.exit()
|
Statement
N people are arranged in a row from left to right.
You are given a string S of length N consisting of `0` and `1`, and a positive
integer K.
The i-th person from the left is standing on feet if the i-th character of S
is `0`, and standing on hands if that character is `1`.
You will give the following direction at most K times (possibly zero):
**Direction** : Choose integers l and r satisfying 1 \leq l \leq r \leq N, and
flip the l-th, (l+1)-th, ..., and r-th persons. That is, for each i = l, l+1,
..., r, the i-th person from the left now stands on hands if he/she was
standing on feet, and stands on feet if he/she was standing on hands.
Find the maximum possible number of **consecutive** people standing on hands
after at most K directions.
|
[{"input": "5 1\n 00010", "output": "4\n \n\nWe can have four consecutive people standing on hands, which is the maximum\nresult, by giving the following direction:\n\n * Give the direction with l = 1, r = 3, which flips the first, second and third persons from the left.\n\n* * *"}, {"input": "14 2\n 11101010110011", "output": "8\n \n\n* * *"}, {"input": "1 1\n 1", "output": "1\n \n\nNo directions are necessary."}]
|
Print the value of
 modulo 10^9+7.
* * *
|
s762314167
|
Runtime Error
|
p04027
|
The input is given from Standard Input in the following format:
N C
A_1 A_2 ... A_N
B_1 B_2 ... B_N
|
for _ in range(test_case):
import sys
from itertools import accumulate
readline = sys.stdin.readline
MOD = 10**9+7
N, C = map(int, readline().split())
A = [0] + list(map(int, readline().split()))
B = [0] + list(map(int, readline().split()))
acsq = [list(accumulate([pow(i, j, MOD) for i in range(max(B)+1)])) for j in range(C+1)]
dp = [[0]*(C+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
a, b = A[i], B[i]
for c in range(C+1):
res = 0
for j in range(c+1):
res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD
dp[i][c] = res
print(dp[N][C])
|
Statement
**12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed.
We are very sorry for your inconvenience.**
There are N children in AtCoder Kindergarten, conveniently numbered 1 through
N. Mr. Evi will distribute C indistinguishable candies to the children.
If child i is given a candies, the child's _happiness_ will become x_i^a,
where x_i is the child's _excitement level_. The _activity level_ of the
kindergarten is the **product** of the happiness of all the N children.
For each possible way to distribute C candies to the children by giving zero
or more candies to each child, calculate the activity level of the
kindergarten. Then, calculate the sum over all possible way to distribute C
candies. This sum can be seen as a function of the children's excitement
levels x_1,..,x_N, thus we call it f(x_1,..,x_N).
You are given integers A_i,B_i (1≦i≦N). Find
 modulo 10^9+7.
|
[{"input": "2 3\n 1 1\n 1 1", "output": "4\n \n\nThis case is included in the test set for the partial score, since A_i=B_i. We\nonly have to consider the sum of the activity level of the kindergarten where\nthe excitement level of both child 1 and child 2 are 1 (f(1,1)).\n\n * If child 1 is given 0 candy, and child 2 is given 3 candies, the activity level of the kindergarten is 1^0*1^3=1.\n * If child 1 is given 1 candy, and child 2 is given 2 candies, the activity level of the kindergarten is 1^1*1^2=1.\n * If child 1 is given 2 candies, and child 2 is given 1 candy, the activity level of the kindergarten is 1^2*1^1=1.\n * If child 1 is given 3 candies, and child 2 is given 0 candy, the activity level of the kindergarten is 1^3*1^0=1.\n\nThus, f(1,1)=1+1+1+1=4, and the sum over all f is also 4.\n\n* * *"}, {"input": "1 2\n 1\n 3", "output": "14\n \n\nSince there is only one child, child 1's happiness itself will be the activity\nlevel of the kindergarten. Since the only possible way to distribute 2 candies\nis to give both candies to child 1, the activity level in this case will\nbecome the value of f.\n\n * When the excitement level of child 1 is 1, f(1)=1^2=1.\n * When the excitement level of child 1 is 2, f(2)=2^2=4.\n * When the excitement level of child 1 is 3, f(3)=3^2=9.\n\nThus, the answer is 1+4+9=14.\n\n* * *"}, {"input": "2 3\n 1 1\n 2 2", "output": "66\n \n\nSince it can be seen that f(1,1)=4 , f(1,2)=15 , f(2,1)=15 , f(2,2)=32, the\nanswer is 4+15+15+32=66.\n\n* * *"}, {"input": "4 8\n 3 1 4 1\n 3 1 4 1", "output": "421749\n \n\nThis case is included in the test set for the partial score.\n\n* * *"}, {"input": "3 100\n 7 6 5\n 9 9 9", "output": "139123417"}]
|
Print the answer.
* * *
|
s362899429
|
Wrong Answer
|
p03218
|
Input is given from Standard Input in the following format:
\(N\)
\(a_1\) \(a_2\) \(\ldots\) \(a_N\)
|
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
n = int(input())
a = list(map(int, input().split()))
ans = min(a)
print(ans)
|
Statement
Niwango-kun has \\(N\\) chickens as his pets. The chickens are identified by
numbers \\(1\\) to \\(N\\), and the size of the \\(i\\)-th chicken is a
positive integer \\(a_i\\).
\\(N\\) chickens decided to take each other's hand (wing) and form some
cycles. The way to make cycles is represented by a permutation \\(p\\) of
\\(1, \ldots , N\\). Chicken \\(i\\) takes chicken \\(p_i\\)'s left hand by
its right hand. Chickens may take their own hand.
Let us define the _cycle_ containing chicken \\(i\\) as the set consisting of
chickens \\(p_i, p_{p_i}, \ldots, p_{\ddots_i} = i\\). It can be proven that
after each chicken takes some chicken's hand, the \\(N\\) chickens can be
decomposed into cycles.
The _beauty_ \\(f(p)\\) of a way of forming cycles is defined as the product
of the size of the smallest chicken in each cycle. Let \\(b_i \ (1 \leq i \leq
N)\\) be the sum of \\(f(p)\\) among all possible permutations \\(p\\) for
which \\(i\\) cycles are formed in the procedure above.
Find the greatest common divisor of \\(b_1, b_2, \ldots, b_N\\) and print it
\\({\rm mod} \ 998244353\\).
|
[{"input": "2\n 4 3", "output": "3\n \n\nIn this case, \\\\(N = 2, a = [ 4, 3 ]\\\\).\n\nFor the permutation \\\\(p = [ 1, 2 ]\\\\), a cycle of an only chicken \\\\(1\\\\) and\na cycle of an only chicken \\\\(2\\\\) are made, thus \\\\(f([1, 2]) = a_1 \\times\na_2 = 12\\\\).\n\nFor the permutation \\\\(p = [ 2, 1 ]\\\\), a cycle of two chickens \\\\(1\\\\) and\n\\\\(2\\\\) is made, and the size of the smallest chicken is \\\\(a_2 = 3\\\\), thus\n\\\\(f([2, 1]) = a_2 = 3\\\\).\n\nNow we know \\\\(b_1 = f([2, 1]) = 3, b_2 = f([1, 2]) = 12\\\\), and the greatest\ncommon divisor of \\\\(b_1\\\\) and \\\\(b_2\\\\) is \\\\(3\\\\).\n\n* * *"}, {"input": "4\n 2 5 2 5", "output": "2\n \n\nThere are always \\\\(N!\\\\) permutations because chickens of the same size can\nbe distinguished from each other.\n\nThe following picture illustrates the cycles formed and their beauties when\n\\\\(p = (2, 1, 4, 3)\\\\) and \\\\(p = (3, 4, 1, 2)\\\\), respectively.\n\n"}]
|
Print the answer.
* * *
|
s011729766
|
Wrong Answer
|
p03218
|
Input is given from Standard Input in the following format:
\(N\)
\(a_1\) \(a_2\) \(\ldots\) \(a_N\)
|
print("3")
|
Statement
Niwango-kun has \\(N\\) chickens as his pets. The chickens are identified by
numbers \\(1\\) to \\(N\\), and the size of the \\(i\\)-th chicken is a
positive integer \\(a_i\\).
\\(N\\) chickens decided to take each other's hand (wing) and form some
cycles. The way to make cycles is represented by a permutation \\(p\\) of
\\(1, \ldots , N\\). Chicken \\(i\\) takes chicken \\(p_i\\)'s left hand by
its right hand. Chickens may take their own hand.
Let us define the _cycle_ containing chicken \\(i\\) as the set consisting of
chickens \\(p_i, p_{p_i}, \ldots, p_{\ddots_i} = i\\). It can be proven that
after each chicken takes some chicken's hand, the \\(N\\) chickens can be
decomposed into cycles.
The _beauty_ \\(f(p)\\) of a way of forming cycles is defined as the product
of the size of the smallest chicken in each cycle. Let \\(b_i \ (1 \leq i \leq
N)\\) be the sum of \\(f(p)\\) among all possible permutations \\(p\\) for
which \\(i\\) cycles are formed in the procedure above.
Find the greatest common divisor of \\(b_1, b_2, \ldots, b_N\\) and print it
\\({\rm mod} \ 998244353\\).
|
[{"input": "2\n 4 3", "output": "3\n \n\nIn this case, \\\\(N = 2, a = [ 4, 3 ]\\\\).\n\nFor the permutation \\\\(p = [ 1, 2 ]\\\\), a cycle of an only chicken \\\\(1\\\\) and\na cycle of an only chicken \\\\(2\\\\) are made, thus \\\\(f([1, 2]) = a_1 \\times\na_2 = 12\\\\).\n\nFor the permutation \\\\(p = [ 2, 1 ]\\\\), a cycle of two chickens \\\\(1\\\\) and\n\\\\(2\\\\) is made, and the size of the smallest chicken is \\\\(a_2 = 3\\\\), thus\n\\\\(f([2, 1]) = a_2 = 3\\\\).\n\nNow we know \\\\(b_1 = f([2, 1]) = 3, b_2 = f([1, 2]) = 12\\\\), and the greatest\ncommon divisor of \\\\(b_1\\\\) and \\\\(b_2\\\\) is \\\\(3\\\\).\n\n* * *"}, {"input": "4\n 2 5 2 5", "output": "2\n \n\nThere are always \\\\(N!\\\\) permutations because chickens of the same size can\nbe distinguished from each other.\n\nThe following picture illustrates the cycles formed and their beauties when\n\\\\(p = (2, 1, 4, 3)\\\\) and \\\\(p = (3, 4, 1, 2)\\\\), respectively.\n\n"}]
|
Print a solution in the following format:
N
a_1 a_2 ... a_N
Here, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.
* * *
|
s697954371
|
Accepted
|
p03648
|
Input is given from Standard Input in the following format:
K
|
k = int(input())
print(50)
print(
" ".join(
map(
str,
[k // 50 + 49 - k % 50] * (50 - k % 50)
+ [k // 50 + 100 - k % 50] * (k % 50),
)
)
)
|
Statement
We have a sequence of length N consisting of non-negative integers. Consider
performing the following operation on this sequence until the largest element
in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.
It can be proved that the largest element in the sequence becomes N-1 or
smaller after a finite number of operations.
You are given an integer K. Find an integer sequence a_i such that the number
of times we will perform the above operation is exactly K. It can be shown
that there is always such a sequence under the constraints on input and output
in this problem.
|
[{"input": "0", "output": "4\n 3 3 3 3\n \n\n* * *"}, {"input": "1", "output": "3\n 1 0 3\n \n\n* * *"}, {"input": "2", "output": "2\n 2 2\n \n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\n* * *"}, {"input": "3", "output": "7\n 27 0 0 0 0 0 0\n \n\n* * *"}, {"input": "1234567894848", "output": "10\n 1000 193 256 777 0 1 1192 1234567891011 48 425"}]
|
Print a solution in the following format:
N
a_1 a_2 ... a_N
Here, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.
* * *
|
s500281790
|
Runtime Error
|
p03648
|
Input is given from Standard Input in the following format:
K
|
K = int(input())
b = int(K % 50)
a = int((K - b) / 50)
list = [0] * 50
j = print(' '.join(list))0
while (j <= 49 - b) :
list[j] = 49 + a - b
j += 1
while (j >49 - b and j <= 49):
list[j] = 2 * 50 + a - b
j += 1
list = map(str, list)
print('50')
|
Statement
We have a sequence of length N consisting of non-negative integers. Consider
performing the following operation on this sequence until the largest element
in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.
It can be proved that the largest element in the sequence becomes N-1 or
smaller after a finite number of operations.
You are given an integer K. Find an integer sequence a_i such that the number
of times we will perform the above operation is exactly K. It can be shown
that there is always such a sequence under the constraints on input and output
in this problem.
|
[{"input": "0", "output": "4\n 3 3 3 3\n \n\n* * *"}, {"input": "1", "output": "3\n 1 0 3\n \n\n* * *"}, {"input": "2", "output": "2\n 2 2\n \n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\n* * *"}, {"input": "3", "output": "7\n 27 0 0 0 0 0 0\n \n\n* * *"}, {"input": "1234567894848", "output": "10\n 1000 193 256 777 0 1 1192 1234567891011 48 425"}]
|
Print a solution in the following format:
N
a_1 a_2 ... a_N
Here, 2 ≤ N ≤ 50 and 0 ≤ a_i ≤ 10^{16} + 1000 must hold.
* * *
|
s304973088
|
Wrong Answer
|
p03648
|
Input is given from Standard Input in the following format:
K
|
n = int(input())
print(1)
print(n)
|
Statement
We have a sequence of length N consisting of non-negative integers. Consider
performing the following operation on this sequence until the largest element
in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.
It can be proved that the largest element in the sequence becomes N-1 or
smaller after a finite number of operations.
You are given an integer K. Find an integer sequence a_i such that the number
of times we will perform the above operation is exactly K. It can be shown
that there is always such a sequence under the constraints on input and output
in this problem.
|
[{"input": "0", "output": "4\n 3 3 3 3\n \n\n* * *"}, {"input": "1", "output": "3\n 1 0 3\n \n\n* * *"}, {"input": "2", "output": "2\n 2 2\n \n\nThe operation will be performed twice: [2, 2] -> [0, 3] -> [1, 1].\n\n* * *"}, {"input": "3", "output": "7\n 27 0 0 0 0 0 0\n \n\n* * *"}, {"input": "1234567894848", "output": "10\n 1000 193 256 777 0 1 1192 1234567891011 48 425"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s363675084
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
A = [[[0] * 10 for i in range(3)] for j in range(4)]
i = 1
# 情報数
numbers = []
info = []
u = ""
number_str = input("")
number = int(number_str)
while i <= number:
x = input()
numbers = x.split()
numbers = list(map(int, numbers))
info.append(numbers)
i = i + 1
for j in info:
A[j[0] - 1][j[1] - 1][j[2] - 1] = A[j[0] - 1][j[1] - 1][j[2] - 1] + j[3]
for h in range(0, 4):
for i in range(0, 3):
for j in range(0, 10):
u = u + " " + str(A[h][i][j])
print(u)
u = ""
if h < 3:
print("#" * 20)
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s950911751
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
# 初期値の準備
fidge_number = 4
floor_number = 3
room_number = 10
residents_data = list()
# リストの初期化
for x in range(fidge_number):
residents_data_temp = list()
for y in range(floor_number):
residents_data_temp.append([0] * 10)
residents_data.append(residents_data_temp)
# インプットdataの反映
data_number = int(input())
for i in range(data_number):
# 入力データの格納
input_data = list(map(int, input().split()))
fidge_input = input_data[0]
floor_input = input_data[1]
room_input = input_data[2]
number_input = input_data[3]
# 入力データのエラーチェック
if (
0 <= fidge_input <= fidge_number
and 0 <= floor_input <= floor_number
and 0 <= room_input <= room_number
):
if (
residents_data[fidge_input - 1][floor_input - 1][room_input - 1]
+ number_input
>= 0
):
# 入力データの反映
residents_data[fidge_input - 1][floor_input - 1][
room_input - 1
] += number_input
# 結果の表示
for x in range(fidge_number):
for y in range(floor_number):
print(" " + " ".join(map(str, residents_data[x][y])))
if x != fidge_number - 1:
print("####################")
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s423500140
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
t_num = 4
f_num = 3
r_num = 10
m_dict = dict()
for i in range(t_num):
m_dict.setdefault(i + 1, list())
for j in range(f_num):
m_dict[i + 1].append([0] * r_num)
n = input()
for i in range(int(n)):
a = input()
IOinfo = a.split()
b, f, r, v = IOinfo
tou = int(b)
flo = int(f)
rnm = int(r)
vis = int(v)
m_dict[tou][flo - 1][rnm - 1] = m_dict[tou][flo - 1][rnm - 1] + vis
else:
for t in range(t_num):
for f in range(f_num):
out_c = ""
for r in range(r_num):
v = m_dict[t + 1][f][r]
out_c = "{} {}".format(out_c, v)
else:
print(out_c)
else:
if t < t_num - 1:
out_m = "#" * 20
print(out_m)
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s484331938
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
HOUSE_CNT = 4
FLOOR_CNT = 3
ROOM_CNT = 10
def init(houses):
for h in range(0, HOUSE_CNT):
floors = []
for f in range(0, FLOOR_CNT):
rooms = []
for r in range(0, ROOM_CNT):
rooms.append(0)
floors.append(rooms)
houses.append(floors)
def in_out(houses):
n = int(input())
for i in range(0, n):
b, f, r, v = tuple(map(int, input().split(" ")))
houses[b - 1][f - 1][r - 1] += v
def output(houses):
line = False
for house in houses:
if line:
print("####################")
else:
line = True
for floor in house:
for room in floor:
print(" %d" % room, end="")
print()
houses = []
init(houses)
in_out(houses)
output(houses)
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s116187300
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
N, *B = map(int, open(0).read().split())
buildings = [[[0] * 10 for _ in range(3)] for _ in range(4)]
for i in range(0, len(B), 4):
b = B[i]
h = B[i + 1]
w = B[i + 2]
v = B[i + 3]
buildings[b - 1][h - 1][w - 1] += v
for i, b in enumerate(buildings):
for r in b:
print(" " + " ".join(map(str, r)))
if i != 3:
print("####################")
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s090857807
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
# ??¬????????±
room = [[[0 for a in range(10)] for b in range(3)] for c in range(4)]
n = int(input())
for cnt0 in range(n):
# ?????°??????????????????
a, b, c, d = map(int, input().split())
room[a - 1][b - 1][c - 1] += d
# ???????????±??????
for cnt1 in range(4):
for cnt2 in range(3):
for cnt3 in range(10):
# OutputPrit
print(" " + str(room[cnt1][cnt2][cnt3]), end="")
# ??????
print()
if cnt1 < 3:
# ????£???????####################(20??????#)?????????
print("#" * 20)
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s856255201
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
def aaa(strArg):
str = ""
for c in strArg:
str += " " + c
return str
n = [int(input())]
house = ["0" * 30, "0" * 30, "0" * 30, "0" * 30]
hr = "#" * 20
for nn in range(n[0]):
bfrv = [int(x) for x in input().split()]
b = bfrv[0] - 1
f = bfrv[1] - 1
r = bfrv[2] - 1
v = bfrv[3]
pos = (f * 10) + r
humal = int(house[b][pos]) + v
house[b] = house[b][:pos] + str(humal) + house[b][pos + 1 :]
for ii in range(4):
print(aaa(house[ii][:10]))
print(aaa(house[ii][10:20]))
print(aaa(house[ii][20:]))
if ii != 3:
print(hr)
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
For each building, print the information of 1st, 2nd and 3rd floor in this
order. For each floor information, print the number of tenants of 1st, 2nd, ..
and 10th room in this order. Print a single space character before the number
of tenants. Print "####################" (20 '#') between buildings.
|
s058155482
|
Accepted
|
p02409
|
In the first line, the number of notices n is given. In the following n lines,
a set of four integers b, f, r and v which represents ith notice is given in a
line.
|
n = int(input())
a = [" 0", " 0", " 0", " 0", " 0", " 0", " 0", " 0", " 0", " 0"]
A_1 = a.copy()
A_2 = a.copy()
A_3 = a.copy()
B_1 = a.copy()
B_2 = a.copy()
B_3 = a.copy()
C_1 = a.copy()
C_2 = a.copy()
C_3 = a.copy()
D_1 = a.copy()
D_2 = a.copy()
D_3 = a.copy()
ren1 = [A_1, A_2, A_3]
ren2 = [B_1, B_2, B_3]
ren3 = [C_1, C_2, C_3]
ren4 = [D_1, D_2, D_3]
for i in range(n):
b = input()
c = b.split(" ")
ren = int(c[0])
kai = int(c[1])
banme = int(c[2])
nin = int(c[3])
if nin < 0:
if ren == 1:
ren1[kai - 1][banme - 1] = " %s" % (int(ren1[kai - 1][banme - 1]) + nin)
elif ren == 2:
ren2[kai - 1][banme - 1] = " %s" % (int(ren2[kai - 1][banme - 1]) + nin)
elif ren == 3:
ren3[kai - 1][banme - 1] = " %s" % (int(ren3[kai - 1][banme - 1]) + nin)
elif ren == 4:
ren4[kai - 1][banme - 1] = " %s" % (int(ren4[kai - 1][banme - 1]) + nin)
elif ren == 1:
ren1[kai - 1][banme - 1] = " %s" % (int(ren1[kai - 1][banme - 1]) + nin)
elif ren == 2:
ren2[kai - 1][banme - 1] = " %s" % (int(ren2[kai - 1][banme - 1]) + nin)
elif ren == 3:
ren3[kai - 1][banme - 1] = " %s" % (int(ren3[kai - 1][banme - 1]) + nin)
elif ren == 4:
ren4[kai - 1][banme - 1] = " %s" % (int(ren4[kai - 1][banme - 1]) + nin)
print("".join(A_1))
print("".join(A_2))
print("".join(A_3))
print("####################")
print("".join(B_1))
print("".join(B_2))
print("".join(B_3))
print("####################")
print("".join(C_1))
print("".join(C_2))
print("".join(C_3))
print("####################")
print("".join(D_1))
print("".join(D_2))
print("".join(D_3))
|
Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of
10 rooms. Write a program which reads a sequence of tenant/leaver notices, and
reports the number of tenants for each room.
For each notice, you are given four integers b, f, r and v which represent
that v persons entered to room r of fth floor at building b. If v is negative,
it means that −v persons left.
Assume that initially no person lives in the building.
|
[{"input": "1 1 3 8\n 3 2 2 7\n 4 3 8 1", "output": "0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n ####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 1 0 0"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s564867468
|
Accepted
|
p03865
|
The input is given from Standard Input in the following format:
s
|
S = input()
A = len(S) % 2
B = 0 if S[0] == S[-1] else 1
print("Second" if A ^ B else "First")
|
Statement
There is a string s of length 3 or greater. No two neighboring characters in s
are equal.
Takahashi and Aoki will play a game against each other. The two players
alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game.
Determine which player will win when the two play optimally.
|
[{"input": "aba", "output": "Second\n \n\nTakahashi, who goes first, cannot perform the operation, since removal of the\n`b`, which is the only character not at either ends of s, would result in s\nbecoming `aa`, with two `a`s neighboring.\n\n* * *"}, {"input": "abc", "output": "First\n \n\nWhen Takahashi removes `b` from s, it becomes `ac`. Then, Aoki cannot perform\nthe operation, since there is no character in s, excluding both ends.\n\n* * *"}, {"input": "abcab", "output": "First"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s463139639
|
Accepted
|
p03865
|
The input is given from Standard Input in the following format:
s
|
ar = list(input())
b = 0
while True:
count = 0
for i in range(1, len(ar) - 1):
if ar[i - 1] != ar[i + 1]:
count += 1
del ar[i]
b += 1
break
if count == 0:
if b % 2 == 1:
print("First")
else:
print("Second")
break
|
Statement
There is a string s of length 3 or greater. No two neighboring characters in s
are equal.
Takahashi and Aoki will play a game against each other. The two players
alternately performs the following operation, Takahashi going first:
* Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game.
Determine which player will win when the two play optimally.
|
[{"input": "aba", "output": "Second\n \n\nTakahashi, who goes first, cannot perform the operation, since removal of the\n`b`, which is the only character not at either ends of s, would result in s\nbecoming `aa`, with two `a`s neighboring.\n\n* * *"}, {"input": "abc", "output": "First\n \n\nWhen Takahashi removes `b` from s, it becomes `ac`. Then, Aoki cannot perform\nthe operation, since there is no character in s, excluding both ends.\n\n* * *"}, {"input": "abcab", "output": "First"}]
|
Print the answer, with space in between.
* * *
|
s965223285
|
Accepted
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s, r = input().split()
x, y = map(int, input().split())
t = input()
if t == s:
x = x - 1
if t == r:
y -= 1
print(x, y)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s511467429
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
[H, A] = [int(i) for i in input().split()]
t = 0
if H / A != int(H / A):
t = 1
print(int(H / A) + t)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s575852064
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
print("x" * len(input()))
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s412827185
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
A = input().split()
B = list(map(int, input().split()))
B = list(map(lambda x: x - 1, B))
print(B[0], B[1])
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s782560827
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
p, q, r = map(int, input().split())
if p >= q and p > r:
print(q + r)
if q >= r and q > p:
print(p + r)
if r >= p and r > q:
print(q + p)
if r == p and p == q:
print(q + p)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s470111884
|
Accepted
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
S, T = input().split() # 文字列のの複数一行入力
A, B = map(int, input().split()) # 数値の複数一行入力(形は覚える)
U = input() # 文字列の入力
if U == S: # もしUとSが同じだった場合
print(A - 1, B) # (問題文より、)Aから1引いてAとBを出力
else: # そうでなかった場合(UとTが同じだった場合)
print(A, B - 1) # Bから1引いてAとBを出力
"""例
入力
S = red , T = blue
A = 3 , B = 4
U = red
UはSと同じだから,Sに対応するAから1引いてA(2)とB(4)を出力する
出力
2 4
"""
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s961239579
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
N_dict = {i: 0 for i in list(map(str, input().split()))}
N_List = list(map(int, input().split()))
ct = 0
for i in N_dict.keys():
N_dict[i] = N_List[0]
ct += 1
N_dict[str(input())] -= 1
" ".join(list(map(str, N_dict.values())))
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s284248858
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
n, k = [int(i) for i in input().split(" ")]
input_list = [int(i) for i in input().split(" ")]
maximum = sum(input_list[:k])
s = sum(input_list[:k])
for i in range(1, n - k + 1):
s = s - input_list[i - 1] + input_list[i + k - 1]
maximum = max(maximum, s)
print((maximum + k) / 2)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s917801600
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
import copy
n = input()
k = int(input())
n_list = []
for a in n:
n_list.append(int(a))
n_num = len(n_list)
dp = [[0] * 2 for _ in range(n_num)]
dp[0][0] = 1
for i in range(n_num):
nxt = [[0] * 2 for _ in range(n_num + 1)]
for j in range(n_num):
for l in range(2):
lim = 9 if l else n_list[i]
for x in range(lim + 1):
if x != 0:
ns = j + 1
else:
ns = j
nlt = l | (x < n_list[i])
nxt[ns][nlt] += dp[j][l]
dp = copy.deepcopy(nxt)
ans = dp[k][0] + dp[k][1]
print(ans)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s069790861
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
mod = 10**9 + 7
rng = 2000100
fctr = [1] + [0] * (rng - 1)
finv = [1] + [0] * (rng - 1)
for i in range(1, rng):
fctr[i] = fctr[i - 1] * i % mod
for i in range(1, rng):
finv[i] = 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
x1, y1, x2, y2 = map(int, input().split())
print(
(
cmb(x2 + y2 + 2, x2 + 1)
- cmb(x2 + y1 + 1, y1)
- cmb(x1 + y2 + 1, x1)
+ cmb(x1 + y1, x1)
)
% mod
)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s090837798
|
Accepted
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s, t = input().split()
sx, tx = map(int, input().split())
a = input()
if a == s:
sx -= 1
else:
tx -= 1
print(sx, tx)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s152295140
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
def dyn(n, d00, d01, d02, d03, d10, d11, d12, d13):
D00 = d00 + d10 * int(n != 0)
D10 = d10 * int(n == 0)
D01 = d00 * 9 + d10 * (n - 1 + int(n == 0)) + d01 + d11 * int(n != 0)
D11 = d10 * (int(n != 0)) + d11 * (int(n == 0))
D02 = d01 * 9 + d11 * (n - 1 + int(n == 0)) + d02 + d12 * int(n != 0)
D12 = d11 * (int(n != 0)) + d12 * (int(n == 0))
D03 = d02 * 9 + d12 * (n - 1 + int(n == 0)) + d03 + d13 * int(n != 0)
D13 = d12 * (int(n != 0)) + d13 * (int(n == 0))
return D00, D01, D02, D03, D10, D11, D12, D13
N = str(input())
K = int(input())
S = len(N)
D00 = 0
D01 = 0
D02 = 0
D03 = 0
D10 = 1
D11 = 0
D12 = 0
D13 = 0
for i in range(S):
[D00, D01, D02, D03, D10, D11, D12, D13] = dyn(
int(N[i]), D00, D01, D02, D03, D10, D11, D12, D13
)
print(int(N[i]), D00, D01, D02, D03, D10, D11, D12, D13)
if K == 1:
print(D01 + D11)
elif K == 2:
print(D02 + D12)
else:
print(D03 + D13)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s215411700
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
list = list(input())
for s in list:
s = "x"
print("".join(list))
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s095158228
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s, a, u = open(0)
i = s.find(u) < 1
print(int(a[0]) - i, int(a[2]) - 1 + i)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s885497335
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
str_list = input().split()
str_dic = {str_list[0]: int(input()), str_list[1]: int(input())}
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s811273878
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s,t=input().split(" ")
a,b.=map(int,input().split(" "))
u=input()
if s==u:
print(a-1,b)
else:
print(a,b-1)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s389824803
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
N, K = input().split()
P = input().split()
P.sort(reverse=True)
sum = 0
for k in range(int(K)):
p = int(P[k])
sum += (p / 2) + 0.5
print(sum)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s769432542
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
n = [input().split() for i in range(2)]
a = n[1]
A = int(n[0])
b = n[1]
B = int(n[1])
S = n[0]
if S[0] == n[2]:
print("A-1","B")
else:
print("A","B-1")
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s882776445
|
Accepted
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
input1 = input().split(" ")
input2 = input().split(" ")
input3 = input()
if input1[0] == input3:
print(str(int(input2[0]) - 1) + " " + input2[1])
elif input1[1] == input3:
print(input2[0] + " " + str(int(input2[1]) - 1))
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s356192169
|
Accepted
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
import sys
Ball = list(map(str, input().split()))
Quantity = list(map(int, input().split()))
U = str(input())
S = Ball[0]
T = Ball[1]
A = Quantity[0]
B = Quantity[1]
if not 1 <= len(S) or not len(S) <= 10:
print("error:S_length")
sys.exit()
if not 1 <= len(T) or not len(T) <= 10:
print("error:T_length")
sys.exit()
if S == T:
print("error:S==T")
sys.exit()
if S != U and T != U:
print("error:S=U or S=T")
sys.exit()
if not 1 <= A or not B <= 10:
print("error:A,B")
sys.exit()
if U == S:
A -= 1
if U == T:
B -= 1
print(A, B)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s848083920
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
dic_lst = {}
lst_a = input().split()
lst_b = list(map(int, input().split()))
wd = input()
for i in range(2):
dic_lst[lst_a[i]] = lst_b[i]
if wd in dic_lst.keys():
dic_lst[wd] -= 1
print(*dic_lst.values())
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s838586167
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
S, T = input().split())
A, B = map(int,input().split())
U = input()
if S == U:
print(A - 1, B)
else:
print(A, B - 1)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s577087908
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
n = int(input())
a = set(map(int, input().split()))
print("YES") if len(a) == n else print("NO")
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s794726636
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s = input(S)
t = input(T)
a = input(A)
b = input(B)
u = input(U)
if (u == s):
s--
elif(u == t):
t--
print(s,t)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s082960192
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
word = str(input())
for i in range(len(word)):
word[i] = "x"
print(word)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s049852686
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
S, a = input(), ""
for x in range(len(S)):
a += "x"
print(a)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s048788528
|
Wrong Answer
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
s, t = input().split()
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s829409847
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
S, T = input().split()
A, B= map(int, input().split())
U = input()
if S == U:
print(A - 1, B)
elif T==U:
print(A, B - 1)
else:
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s827206489
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
array = list(input())
colr1 = array[0]
colr2 = array[1]
array2 = list(int(input()))
colr = input()
if colr == colr1:
array2[0] -= 1
if colr == colr2:
array2[1] -= 1
print(array2)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s940276378
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
stra = eval(input())
strb = eval(input())
num1 = eval(input())
num2 = eval(input())
chosen = eval(input())
if chosen == stra:
num1 -= 1
elif chosen == strb:
num2 -= 1
print(num1, num2)
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Print the answer, with space in between.
* * *
|
s419268501
|
Runtime Error
|
p02777
|
Input is given from Standard Input in the following format:
S T
A B
U
|
import sys
TEST_INPUT = [
"""
red blue
3 4
red
""",
"""
red blue
5 5
blue
""",
]
ANSWER = ["2 4", "5 4"]
class InputHandler:
def __init__(self, text_lines="", is_test=False):
self.data = list(text_lines.split("\n"))
self.index = 0
self.is_test = is_test
def input(self):
if self.is_test:
self.index += 1
return self.data[self.index].strip()
else:
return sys.stdin.readline().rstrip()
def solve(s, t, a, b, u):
if s == u:
return f"{a - 1} {b}"
else:
return f"{a} {b - 1}"
def main():
ih = InputHandler()
s, t = ih.input().split()
a, b = map(int, ih.input().split())
u = ih.input()
res = solve(s, t, a, b, u)
print(res)
def test():
for test_input, ans in zip(TEST_INPUT, ANSWER):
ih = InputHandler(test_input, True)
s, t = ih.input().split()
a, b = map(int, ih.input().split())
u = ih.input()
res = solve(s, t, a, b, u)
assert str(res) == str(ans)
if __name__ == "__main__":
test()
main()
|
Statement
We have A balls with the string S written on each of them and B balls with the
string T written on each of them.
From these balls, Takahashi chooses one with the string U written on it and
throws it away.
Find the number of balls with the string S and balls with the string T that we
have now.
|
[{"input": "red blue\n 3 4\n red", "output": "2 4\n \n\nTakahashi chose a ball with `red` written on it and threw it away. Now we have\ntwo balls with the string S and four balls with the string T.\n\n* * *"}, {"input": "red blue\n 5 5\n blue", "output": "5 4\n \n\nTakahashi chose a ball with `blue` written on it and threw it away. Now we\nhave five balls with the string S and four balls with the string T."}]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.