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
|
---|---|---|---|---|---|---|---|
Print the minimum total price of two different bells.
* * *
|
s813523380
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
n = list[input().split()]
m = sorted(n)
print(m[0] + m[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s299223268
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a=gets.split.map &:to_i
print(a.sum-a.max)
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s553742572
|
Wrong Answer
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
print(sum(sorted(list(map(int, input().split()))[:2])))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s238288844
|
Wrong Answer
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
array = sorted(input().split())
print(array[0] + array[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s858715677
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a = gets.split.map(&:to_i).sort!
puts a[0] + a[1]
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s715958035
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
arr = list(map(int, input().split()))
print(sum(arr) - max(arr))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s805811145
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
H = sorted(list(map(int, input().split())))
print(H[0] + H[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s359099041
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a = list(map(int,input()split())
a.sort()
print(a[0] + a[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s548303201
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
abc = sorted(list(map(int, input().split())))
print(sum[:2])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s698835558
|
Wrong Answer
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
print(sum(sorted(list(map(int, input().split())))[::-1][0:2]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s096975855
|
Wrong Answer
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
lis = input().split()
lis.sort()
print(int(lis[0]) + int(lis[1]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s517807481
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
bell = [int(n) for n in input().split()]
sort = sorted(bell)
print(sort[0] + sort[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s965781436
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
n = int(input())
A = list(map(int, input().split()))
mod = int(1e9 + 7)
def powermod(a, n, mod):
r = 1
while n >= 1:
if n % 2:
r = r * a % mod
a = a * a % mod
n = n // 2
return r
memo = {}
for i, a in enumerate(A):
if a in memo:
L = memo[a]
C = i - memo[a] - 1
R = len(A) - i - 1
break
else:
memo[a] = i
# print(L,C,R)
_LR = [0] * (n + 3)
_LCR = [0] * (n + 3) # _LCR[k] = (L+C+R)C(k)
_k = [0] * (n + 3)
_LR[0] = _LCR[0] = _k[0] = 1
LR = [0] * (n + 2) # LR[k] = (L+R)C(k)
LR[0] = 1
# LDR = [0]*(n+2)
# LDDR = [0]*(n+2)
LCR = [0] * (n + 2) # LCR[k] = _LCR[k] - LR[k]
# LDCR = [0] * (n+2) #最後に*2を忘れないこと
# LDCDR = [0] * (n+2)
for k in range(1, n + 2):
_LR[k] = (_LR[k - 1] * (L + R + 1 - k)) % mod
_LCR[k] = (_LCR[k - 1] * (L + C + R + 1 - k)) % mod
_k[k] = (_k[k - 1] * powermod(k, mod - 2, mod)) % mod
LR[k] = (_LR[k] * _k[k]) % mod
# LDR[k] = LR[k-1]
# LDDR[k] = LDR[k-1]
LCR[k] = (_LCR[k] * _k[k]) % mod - LR[k]
# LDCR[k] = LCR[k-1]
# LDCDR[k] = LDCR[k-1]
# print(LR, LCR)
print((LR[k] + LR[k - 1] + LR[k - 2] + LCR[k] + 2 * LCR[k - 1] + LCR[k - 2]) % mod)
# print(LR)
# print(LDR)
# print(LDDR)
# print(_LCR)
# print(LCR)
# print(LDCR)
# print(LDCDR)
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s096839285
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a=list(map(int,input().split())
print(sum(a)-max(a))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s223236134
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
list = list(map(int, input().split()))
print(min(sum(list) - list[0], sum(list) - list[1], sum(list) - list[2]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s250305089
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a,b,c = map(int,input().split())
min = a+b
if min >= a+c:
min = a+c
elif min >= b+c:
min = b+c
print(str(min)
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s900255467
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
l = list(map(int, input().split()))
l.remove(max(l))
print(sum(l))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s683616643
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
x, y, z = map(int, input().split(" "))
X = x + y
Y = y + z
Z = x + z
print(min(X, Y, Z))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s898644153
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
S = list(map(int, input().split()))
S = sorted(S)
print(S[0] + S[1])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s652400603
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
al = list(map(int, input().split()))
al = sorted(al)
print(sum(al[:2]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s056710278
|
Wrong Answer
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
print(sum(sorted(list(map(int, input().split())), reverse=True)[:2]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s040888797
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
c = sorted(map(int, input().split()))
print(sum(c) - max(c))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s518447161
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a = map(int, input(), split())
print((a.sort())[0:2])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s084661058
|
Accepted
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
print(str(sum(sorted(list(map(int, input().split(" "))))[0:2])))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s126511758
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
l = [int(n) for n in input().split()]
print(sum(l.sort()[:2]))
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print the minimum total price of two different bells.
* * *
|
s282102911
|
Runtime Error
|
p03671
|
Input is given from Standard Input in the following format:
a b c
|
a, b, c = map(int, input().split())
print(min([a+b, b+c, c+a])
|
Statement
Snuke is buying a bicycle. The bicycle of his choice does not come with a
bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for
each hand.
The store sells three kinds of bells for the price of a, b and c yen (the
currency of Japan), respectively. Find the minimum total price of two
different bells.
|
[{"input": "700 600 780", "output": "1300\n \n\n * Buying a 700-yen bell and a 600-yen bell costs 1300 yen.\n * Buying a 700-yen bell and a 780-yen bell costs 1480 yen.\n * Buying a 600-yen bell and a 780-yen bell costs 1380 yen.\n\nThe minimum among these is 1300 yen.\n\n* * *"}, {"input": "10000 10000 10000", "output": "20000\n \n\nBuying any two bells costs 20000 yen."}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s695304547
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
import sys
input_methods = ["clipboard", "file", "key"]
using_method = 0
input_method = input_methods[using_method]
tin = lambda: map(int, input().split())
lin = lambda: list(tin())
mod = 1000000007
# +++++
def cc(s):
if s <= 10**9:
r = [0, 0, s, 0, 0, 1]
return r
ok = 10**9
ng = 1
while ok - ng > 1:
mid = (ok + ng) // 2
if mid * mid >= s:
ok = mid
else:
ng = mid
if ok * ok == s:
r = [0, 0, ok, 0, 0, ok]
return r
mx = ok
ok = mx
ng = 1
while ok - ng > 1:
mid = (ok + ng) // 2
if mx * mid >= s:
ok = mid
else:
ng = mid
if mx * ok == s:
return [0, 0, mx, 0, 0, ok]
else:
diff = s - ((mx - 1) * ok)
# dd=s-(mx*ok)
# pa(dd)
return [0, 0, mx, 1, diff, ok]
def main():
s = int(input())
# b , c = tin()
# s = input()
ret = cc(s)
print(*ret)
# +++++
isTest = False
def pa(v):
if isTest:
print(v)
def input_clipboard():
import clipboard
input_text = clipboard.get()
input_l = input_text.splitlines()
for l in input_l:
yield l
if __name__ == "__main__":
if sys.platform == "ios":
if input_method == input_methods[0]:
ic = input_clipboard()
input = lambda: ic.__next__()
elif input_method == input_methods[1]:
sys.stdin = open("inputFile.txt")
else:
pass
isTest = True
else:
pass
# input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s020944296
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
# cf. #6489625
s = int(input())
a = 10**9
c = (a - s % a) % a
b = (s + c) // a
print(0, 0, a, 1, c, b)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s769350598
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
print(0, 0, 1, 0, 0, input())
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s220012841
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
S = int(input())
Y3 = (S // 10**9) + 1
X3 = ((10**9)) - S % 10**9
print(0, 0, 10**9, 1, X3, Y3)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s386771128
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
a = int(input())
print(
"0 0 1 1000000000",
str(int(-1 * ((-1 * a) // (10**9)))),
str(int(10**9 - a % (10**9))),
)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s771352574
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
sosu = [2]
now = 3
while now**2 <= 10**9:
for i in sosu:
flag = True
if now % i == 0:
flag = False
break
if flag:
sosu.append(now)
now += 1
# print (sosu)
sosu.insert(0, 1)
S = int(input())
lis = []
r = int(S**0.5)
st1 = r
st2 = r
mode = 0
while True:
if st1 * st2 - S >= 0:
cd = (st1 * st2) - S
for i in sosu:
flag = False
if cd % i == 0 and cd // i <= 10**9 and st1 <= 10**9 and st2 <= 10**9:
print(0, 0, st1, cd // i, i, st2)
flag = True
break
if flag:
break
if st2 == 10**9 and st1 == 10**9:
mode = 1
st1 = 10**9
st2 = r
if mode == 1 and st1 * st2 < S:
st1 -= 1
st2 = r
elif mode == 1:
st2 -= 1
elif st1 >= 10**9:
st2 += 1
st1 = r
else:
st1 += 1
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s881126773
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
n = int(input())
x, y = 0, 0
for i in range(2, n + 1):
if n % i == 0:
x = i
y = n // i
print(0, 0, x, 0, 0, y)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s376928285
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
S = int(input())
flg = True
for i in range(2 * S + 1):
if (2 * S) % (i + 1) == 0:
if flg:
for x1 in range(i + 2):
if flg:
for y1 in range(i + 2):
if flg:
if not x1 == y1:
print(
"0 0 {} {} {} {}".format(
x1, y1, i + 1, int((2 * S) / (i + 1))
)
)
flg = False
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s903445537
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = int(input())
xylist = [0] * 4
for i in range(s):
for j in range(s):
for k in range(s):
for l in range(s):
ss = abs((i * j) - (k * l))
if s == ss:
xylist = [i, l, k, j]
break
xylist.append(0)
xylist.append(0)
print(" ".join(map(str, xylist)))
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s032720003
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = int(input())
a1 = int(s**0.5)
a2 = a1 + 1
if s - a1**2 > a2**2 - s:
a = a2
b = abs(s - a**2)
print(0, end=" ")
print(0, end=" ")
print(a, end=" ")
print(1, end=" ")
print(b, end=" ")
print(a)
elif s != 10**18:
a = a1
b = abs(s - a**2)
print(1, end=" ")
print(0, end=" ")
print(a + 1, end=" ")
print(b, end=" ")
print(0, end=" ")
print(a)
else:
print(0, end=" ")
print(0, end=" ")
print(10**9, end=" ")
print(0, end=" ")
print(0, end=" ")
print(10**9)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s338240992
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
S = int(input())
dig = len(str(S))
if dig < 10:
b = str(1000000000 - S)
print("0 0 1000000000 1 " + b + " 1")
elif dig < 19:
a = dig + 1
a2 = str(a)
b = 1000000000 * a - S
b2 = str(b)
print("0 0 1000000000 1 " + b2 + " " + a2)
else:
print("0 0 1000000000 0 0 1000000000")
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s513123397
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = int(input())
A = [0, 0, 10**9, 1]
A.append(s // (10**9))
if s % (10**9) == 0:
A.append(0)
else:
A[-1] += 1
A.append(10**9 - s % (10**9))
print(*A)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s359727342
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
S = int(input())
x = 10**9
b = S // x
if S % x != 0:
b += 1
c = (x * b) - S
print(0, 0, 10**9, c, 1, b)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s858447522
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = int(input())
n = 1000000000
x = (n - s % n) % n
y = (s + x) // n
print(*[1, n, y, x, 0, 0])
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s769024103
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
print(0, 0, 1, 0, 0, int(input()))
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s266935871
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = input()
print("0 0 0 1", s, "0")
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s019684659
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
print("0 0 1 0 0 " + input())
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s533345213
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
print(0, 0, input(), 1, 1, 1)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s291665234
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
print(0, 0, 0, 1, int(input()), 0)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s856475615
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10**7)
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()
s = ni()
v = 10**9
x = (v - s % v) % v
y = (s + x) // v
print(0, 0, v, 1, x, y)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s216256489
|
Accepted
|
p02963
|
Input is given from Standard Input in the following format:
S
|
s = int(input())
ans_list = [0 for _ in range(6)]
num = s
count = 0
while num > 1000000000:
num //= 2
count += 1
ans_list[0] = num
ans_list[3] = 2**count
while s >= ans_list[0] * ans_list[3] and ans_list[3] < 1000000000:
ans_list[3] += 1
if ans_list[3] > 1000000000:
ans_list[3] = 1000000000
ans_list[0] = s // 1000000000 + 1
if ans_list[0] > 1000000000:
ans_list[0] = 1000000000
ans_list[1] = 1
sum_ = ans_list[0] * ans_list[3]
ans_list[2] = sum_ - s
print(
"{} {} {} {} {} {}".format(
ans_list[0], ans_list[1], ans_list[2], ans_list[3], ans_list[4], ans_list[5]
)
)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s093185920
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
a = int(input())
i = 0
if a <= 1000000000:
print("1 0 0 0 0 " + str(a))
elif a % 2000000000 != 0 and a % 2 == 0:
print(
"0 0 1000000000 1 "
+ str(1000000000 - ((a // 2) % 1000000000) * 2)
+ " "
+ str((a // 1000000000) + 1)
)
elif a % 2000000000 != 0 and a % 2 != 0:
print(
"0 0 1000000000 1 "
+ str(1000000000 - (((a - 1) // 2) % 1000000000) * 2 - 1)
+ " "
+ str((a // 1000000000) + 1)
)
else:
print("0 0 1000000000 0 0 " + str(a // 2000000000))
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfy the conditions,
in this order, with spaces in between. If multiple solutions exist, any of
them will be accepted.
* * *
|
s647266693
|
Wrong Answer
|
p02963
|
Input is given from Standard Input in the following format:
S
|
# -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST():
return list(map(int, input().split()))
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = float("inf")
MOD = 10**9 + 7
S = INT()
MAX = 1000000000
x1, y1 = 0, 0
x2, y2 = MAX, 1
x3, y3 = MAX - S % MAX, ceil(S, MAX)
print(x1, y1, x2, y2, x3, y3)
|
Statement
Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3,
and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that there always exist six integers that satisfy the conditions
under the constraints of this problem.
|
[{"input": "3", "output": "1 0 2 2 0 1\n \n\nThe area of the triangle in a two-dimensional plane whose vertices are\n(1,0),(2,2), and (0,1) is 3/2. Printing `3 0 3 1 0 1` or `1 0 0 1 2 2` will\nalso be accepted.\n\n* * *"}, {"input": "100", "output": "0 0 10 0 0 10\n \n\n* * *"}, {"input": "311114770564041497", "output": "314159265 358979323 846264338 327950288 419716939 937510582"}]
|
Print the number of people sitting at the theater.
* * *
|
s116522359
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
print(sum(1 - eval(s.replace(" ", "-")) for s in open(0).readlines()[1:]))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s147779020
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
with open(0) as f:
N, *lr = map(int, f.read().split())
print(sum(lr[1::2]) - sum(lr[::2]) + N)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s408933128
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
a=int(input())
b=[int(input()) for i range(a)]
c=0
for i range(a):
c=c+(b[i][1]-b[i][2])
print(c+a)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s814629622
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
2
6 8
3 3
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s798028230
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
print(sum([(lambda x:b+1-a)(map(int,input().split())for _ in int(input())]))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s260693534
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N = int(input())
x_set = set()
x = [[int(i) for i in input().split()] for j in range(N)]
for i, j in enumerate(x):
for k in range(j[0], j[1] + 1):
x_set.add(k)
print(len(x_set))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s406817335
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
Num = 0
for T in range(int(input())):
L, R = (int(X) for X in input().split())
Num += R - L + 1
print(Num)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s371008672
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
_, *t = open(0)
print(sum(1 - eval(s.replace(" ", "-")) for s in t))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s354767486
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
n = int(input())
s = [list(map(int, input().split())) for i in range(0, n)]
hunman = 0
for group in s:
hunman = hunman + group[1] - group[0] + 1
print(hunman)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s660160484
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
import math
import sys
def getinputdata():
# 配列初期化
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if data != "":
array_result.append(data.split(" "))
flg = 1
else:
flg = 0
finally:
return array_result
arr_data = getinputdata()
n = int(arr_data[0][0])
mysum = 0
for v in range(1, 1 + n):
mysum += int(arr_data[v][1]) - int(arr_data[v][0]) + 1
# print("Yes" if "9" in n else "No")
print(mysum)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s237020855
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N=int(input())
for i in range(N)
l,n=map(int,input().split())
ans=l-n+1
print(ans)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s603957671
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N=int(input())
sum=0
for i range(N):
l, r =map(int,input().split())
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s260387449
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
1
24 30
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s307488811
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N=int(input())
sum=0
for i range(N):
l, r =map(int, input().split())
sum+=(r-l+1)
print(sum)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s064290076
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N=int(input())
ans=0
for i in range(N):
l,r=map(int,input().split())
ans+=r-l+1
print(ans)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s063410787
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
n=int(input())
ans=0
for i in range(n):
r,l=int(i) for i in input().split()
ans+=l-r+1
print(ans)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s596511004
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
print(sum(1-eval(input().replace(' ','-')), for _ in range(int(input())))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s657523400
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
def aaa(seat_list):
return seat_list[len(seat_list)-1] - seat_list[0]
value = int(input())
people = 0
while True:
try:
seat = input()
if seat:
string_seat = seat.split()
seat_list = []
seat_list = [int(x) for x in (string_seat)]
people += aaa(seat_list)
except EOFError:
break
print(people)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s013477315
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
int main(){
int n;
cin >> n;
llong ans=0;
int l,r;
REP(i,n){
cin >> l >> r;
ans+=r-l+1;
}
cout << ans << endl;
}
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s180156645
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
if __name__ == '__main__':
N = int(input())
ans = 0
for i in range(N):
l = list(map(int, input().split()))
ans += abs(l[1]-l[0])
print(ans
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s572251602
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
n=INT()
ans=0
for i n range(n):
l,r=INTM()
ans+=r-l+1
print(ans)
if __name__ == '__main__':
do()
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s206054310
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
china = int(input())
kazu = 0
for i in range(china):
a, b = [int(i) for i in input().split()]
kazu = kazu + (b - a + 1)
print(kazu)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s358417936
|
Wrong Answer
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
T = int(input())
a, b = map(int, input().split())
A = 0
for i in range(0, T):
A = abs(a - b)
print(A + T)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s273152417
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N = int(input())
res = 0
for _ in range(N)
r, l = map(int, input().split())
res += l - r + 1
print(res)
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s966515287
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
_, *l = map(int, open(0).read().split())
print(sum(j - i + 1 for i, j in zip(l[::2], l[1::2])))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s784138451
|
Accepted
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
N = input()
ni = lambda: int(N)
nm = lambda: map(int, input().split())
li = lambda: [nl() for _ in range(ni())]
nl = lambda: list(nm())
lx = lambda: [x[1] - x[0] + 1 for x in li()]
print(sum(lx()))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s012034811
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
# 075B
h, w = map(int, input().split())
ss = [list(map(str, str(input()))) for _ in range(h)]
# print(ss)
def count_bombs(ss, i, j):
count = 0
if ss[i][j] == "#":
return "#"
for y in [-1, 0, 1]:
for x in [-1, 0, 1]:
# print(i+y, x+j, count)
if 0 <= i + y < h and 0 <= j + x < w and ss[i + y][j + x] == "#":
count += 1
return str(count)
for i in range(h):
for j in range(w):
ss[i][j] = count_bombs(ss, i, j)
# print('## ',i,j,ss[i][j])
for s in ss:
print("".join(s))
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the number of people sitting at the theater.
* * *
|
s850260490
|
Runtime Error
|
p03606
|
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
|
h, w = map(int, input().split())
a = [[0 if s == "." else "#" for s in list(input())] for i in range(h)]
for _ in range(h):
for s in range(w):
if a[_][s] == "#":
try:
a[_ - 1][s] += 1
except:
continue
try:
a[_ + 1][s] += 1
except:
continue
try:
a[_][s - 1] += 1
except:
continue
try:
a[_][s + 1] += 1
except:
continue
try:
a[_ + 1][s + 1] += 1
except:
continue
try:
a[_ + 1][s - 1] += 1
except:
continue
try:
a[_ - 1][s + 1] += 1
except:
continue
try:
a[_ - 1][s - 1] += 1
except:
continue
print(a)
for s in range(h):
print(a[s])
|
Statement
Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th
group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
|
[{"input": "1\n 24 30", "output": "7\n \n\nThere are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.\n\n* * *"}, {"input": "2\n 6 8\n 3 3", "output": "4"}]
|
Print the maximum possible beauty of the painting.
* * *
|
s271388038
|
Accepted
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
# input
N = int(input())
A = list(map(int, input().split()))
# output
# Python program to find
# maximum XOR subset
# Number of bits to
# represent int
INT_BITS = 64
# Function to return
# maximum XOR subset
# in set[]
def maxSubarrayXOR(set, n):
# Initialize index of
# chosen elements
index = 0
# Traverse through all
# bits of integer
# starting from the most
# significant bit (MSB)
for i in range(INT_BITS - 1, -1, -1):
# Initialize index of
# maximum element and
# the maximum element
maxInd = index
maxEle = -9223372036854775808
for j in range(index, n):
# If i'th bit of set[j]
# is set and set[j] is
# greater than max so far.
if (set[j] & (1 << i)) != 0 and set[j] > maxEle:
maxEle = set[j]
maxInd = j
# If there was no
# element with i'th
# bit set, move to
# smaller i
if maxEle == -9223372036854775808:
continue
# Put maximum element
# with i'th bit set
# at index 'index'
temp = set[index]
set[index] = set[maxInd]
set[maxInd] = temp
# Update maxInd and
# increment index
maxInd = index
# Do XOR of set[maxIndex]
# with all numbers having
# i'th bit as set.
for j in range(n):
# XOR set[maxInd] those
# numbers which have the
# i'th bit set
if j != maxInd and (set[j] & (1 << i)) != 0:
set[j] ^= set[maxInd]
# Increment index of
# chosen elements
index += 1
# Final result is
# XOR of all elements
res = 0
for i in range(n):
res ^= set[i]
return res
B = 0
for a in A:
B ^= a
A2 = [a & (~B) for a in A]
d = maxSubarrayXOR(A2, N)
print(int(d) + int(B ^ d))
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
Print the maximum possible beauty of the painting.
* * *
|
s168974783
|
Runtime Error
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
# coding: utf-8
def solve(*args: str) -> str:
n = int(args[0])
A = tuple(map(int, args[1].split()))
ret = 0
xor = [0] * (2**n)
xor[1] = A[0]
for i in range(1, n):
for j in range(2**i):
xor[2**i + j] = A[i] ^ xor[j]
for i in range(1, 2 ** (n - 1)):
ret = max(ret, xor[i] + xor[-1 - i])
return str(ret)
if __name__ == "__main__":
print(solve(*(open(0).read().splitlines())))
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
Print the maximum possible beauty of the painting.
* * *
|
s577815986
|
Accepted
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
N = int(input())
xs = list(map(int, input().split()))
osum = 0
for x in xs:
osum = osum ^ x
for i in range(N):
xs[i] = xs[i] & ~osum
vs = set()
for i in range(60):
i = 59 - i
base = -1
for j, x in enumerate(xs):
if j in vs:
continue
if (x >> i) % 2:
vs.add(j)
base = j
break
if base < 0:
continue
for j, x in enumerate(xs):
if j == base:
continue
if (x >> i) % 2:
xs[j] = xs[j] ^ xs[base]
ksum = 0
for x in xs:
ksum = ksum ^ x
print(osum + ksum * 2)
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
Print the maximum possible beauty of the painting.
* * *
|
s639519152
|
Wrong Answer
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
def find_max(f):
for i in range(1, N):
# f[1]をredにした場合
val_red = (f[i - 1][0] ^ A[i]) + f[i - 1][1]
# f[1]をblueにした場合
val_blue = f[i - 1][0] + (f[i - 1][1] ^ A[i])
if val_red > val_blue:
f[i][0] = f[i - 1][0] ^ A[i]
f[i][1] = f[i - 1][1]
else:
f[i][0] = f[i - 1][0]
f[i][1] = f[i - 1][1] ^ A[i]
return f[-1][0] + f[-1][1]
N = int(input())
A = list(map(int, input().split()))
f = [[0, 0] for i in range(N)]
f[0][0] = A[0]
# print('------')
print(find_max(f))
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
Print the maximum possible beauty of the painting.
* * *
|
s083475111
|
Wrong Answer
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
N = int(input())
A = list(map(int, input().split()))
T = 0
for i in range(N):
T ^= A[i]
def rec(A, R, B): # 初期値R = T, B = 0
x = -1
score = R + B
for i in range(len(A)):
if score <= (R ^ A[i]) + (B ^ A[i]):
score = (R ^ A[i]) + (B ^ A[i])
x = i
if x == -1:
return score
R = R ^ A[x]
B = B ^ A[x]
A.pop(x)
return rec(A, R, B)
print(rec(A, T, 0))
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
Print the maximum possible beauty of the painting.
* * *
|
s370918007
|
Wrong Answer
|
p02914
|
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
|
n = int(input())
a = [int(i) for i in input().split()]
b = 0
c = 1
for _ in range(62):
d = 0
for j in a:
d += 1 if c & j > 0 else 0
if d > 0:
b += c
if d & 1 == 0:
b += c
c *= 2
print(b)
|
Statement
We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and
painting the rest in blue.
Let the _beauty_ of the painting be the \mbox{XOR} of the integers painted in
red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possible beauty of the painting.
What is \mbox{XOR}?
The bitwise \mbox{XOR} x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-
negative integers x_1, x_2, \ldots, x_n is defined as follows:
* When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \oplus 5 = 6.
|
[{"input": "3\n 3 6 5", "output": "12\n \n\nIf we paint 3, 6, 5 in blue, red, blue, respectively, the beauty will be (6) +\n(3 \\oplus 5) = 12.\n\nThere is no way to paint the integers resulting in greater beauty than 12, so\nthe answer is 12.\n\n* * *"}, {"input": "4\n 23 36 66 65", "output": "188\n \n\n* * *"}, {"input": "20\n 1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 611451291444233983 647509226592964607 251832107792119421 827811265410084479 864032478037725181", "output": "2012721721873704572\n \n\nA_i and the answer may not fit into a 32-bit integer type."}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s691762688
|
Wrong Answer
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
print("No")
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s129653821
|
Accepted
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
def examC():
N, M = LI()
S = SI()
V = [[] for _ in range(N)]
ok = [1] * N
acnt = [0] * N
bcnt = [0] * N
for _ in range(M):
a, b = LI()
V[a - 1].append(b - 1)
V[b - 1].append(a - 1)
if S[a - 1] == "A":
acnt[b - 1] += 1
else:
bcnt[b - 1] += 1
if S[b - 1] == "A":
acnt[a - 1] += 1
else:
bcnt[a - 1] += 1
NGque = deque()
for i in range(N):
if acnt[i] == 0 or bcnt[i] == 0:
ok[i] = 0
NGque.append(i)
# print(ok,acnt,bcnt)
# print(NGque)
while NGque:
cur = NGque.pop()
for i in V[cur]:
if ok[i] == 1:
if S[cur] == "A":
acnt[i] -= 1
else:
bcnt[i] -= 1
if acnt[i] == 0 or bcnt[i] == 0:
ok[i] = 0
NGque.append(i)
if max(ok) == 1:
ans = "Yes"
else:
ans = "No"
print(ans)
import sys, copy, bisect, itertools, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
def I():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float("inf")
examC()
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s827326133
|
Runtime Error
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
n,m = map(int,input().split())
s = list(input())
ali = [0 for i in range(n)]
bli = [0 for i in range(n)]
for i in range(m):
u,v=map(int,input().split())
graphAB[u].append(v)
graphAB[v].append(u)
from collections import defaultdict
graphAB = defaultdict(list)
def incrementAB(node,adj):
if s[adj-1] == 'A':
ali[node-1]+=1
if s[adj-1] == 'B':
bli[node-1]+=1
def decrementAB(node,adj):
if s[adj-1] == 'A':
ali[node-1]-=1
if s[adj-1] == 'B':
bli[node-1]-=1
def adjAB(node):
if ali[node-1]!=0 and bli[node-1]!=0:
return(True)
else:
return(False)
graphvers = set(graphAB.keys())
visitset = set()
for i in range(1,n+1):
if not i in graphvers:
s[i-1] = 'C'
else:
for j in graphAB[i]:
incrementAB(i,j)
if not adjAB(i):
visitset.add(i)
while bool(visitset):
#print(graphAB)
#print(graphABopp)
#print(abli)
i = visitset.pop()
gen = (j for j in graphAB[i] if s[j-1]!='C')
for j in gen
decrementAB(j,i)
if not adjAB(j):
visitset.add(j)
s[i-1] = 'C'
#print(graphAB)
#print(graphABopp)
sset= set(s)
sset.add('C')
sset.remove('C')
if bool(sset):
print('Yes')
else:
print('No')
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s022638404
|
Runtime Error
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
import sys
sys.setrecursionlimit(1000000).
def have_loop(G, V):
#Gに閉路があるかを判定 Gは隣接グラフによる表現. 0-based Vは頂点数
status = [0] * V #0 = 未訪問 1 = 訪問中 2 = 訪問済
def visit(n):
if status[n] == 1:
print('Yes')
exit()
elif status[n] == 0:
status[n] = 1
for v in G[n]:
visit(v)
status[n] = 2
return None
for v in range(V):
visit(v)
print('No')
return None
N, M = map(int, input().split())
s = input()
G = [[] for _ in range(2 * N)]
for _ in range(M):
a, b = map(lambda x: int(x) - 1, input().split())
if s[a] == s[b]:
G[a].append(b + N)
G[b].append(a + N)
else:
G[a + N].append(b)
G[b + N].append(a)
have_loop(G, 2 * N)
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s706529842
|
Accepted
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
"""
https://beta.atcoder.jp/contests/agc027/submissions/3201641
"""
n, m = map(int, input().split())
s = list(input())
deg = [{"A": 0, "B": 0} for _ in range(n)] # deg[0 - (n - 1)][0 - 1] = 0
g = [list() for _ in range(n)] # g[0 - (n - 1)] = []
for i in range(m): # クエリを配列に代入
x, y = map(int, input().split())
x, y = x - 1, y - 1 # 1-indexed -> 0-indexed
deg[x][
s[y]
] += 1 # 頂点 x に隣接する頂点の個数を管理 : A か B かに応じて, その文字のカウントを 1 増やす
deg[y][
s[x]
] += 1 # 頂点 y に隣接する頂点の個数を管理 : A か B かに応じて, その文字のカウントを 1 増やす
g[x].append(y) # 頂点 x に隣接する頂点のリストに y を追加
g[y].append(x) # 頂点 y に隣接する頂点のリストに x を追加
was = [False for _ in range(n)] # was[j] = True なら 頂点 j は que に追加済み
que = [] # A か B が隣接しないため, 連結リストから除外する頂点
for i in range(n): # 全頂点をループ
if deg[i]["A"] == 0 or deg[i]["B"] == 0: # A か B が隣接しないなら
que.append(i) # 除外頂点リスト que に追加
was[i] = True # was[j] = True は, 除外頂点リスト que に追加済を意味する
for (
q
) in (
que
): # A か B が隣接していない, 除外頂点リストの各頂点をループ( que はループ中に追加されうる)
for j in g[q]: # 除外頂点に隣接する頂点をループ
deg[j][
s[q]
] -= 1 # "除外頂点に隣接する頂点" に隣接する頂点の個数を管理 : 除外頂点の文字のカウントを減らす
if (
deg[j]["A"] == 0 or deg[j]["B"] == 0
): # "除外頂点に隣接する頂点" に A か B が隣接しないなら
if not was[
j
]: # 頂点 j が que に追加済みの頂点でないなら, que に追加する / 追加済みなら, 隣接する頂点の個数管理は, 終了済み
was[j] = True
que.append(j) # 除外頂点リスト que に追加, ループ回数増える
# 除外頂点を取り除いた後に, 頂点が残っていれば, AABB... を作成できる
# 頂点が残っていなければ, つまり, que に全ての頂点が入っていれば, AABB...を作成できない
print("No" if len(que) == n else "Yes")
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s655798147
|
Wrong Answer
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
N, M = map(int, input().split())
s = input()
class Node:
def __init__(self, node_id, label):
self.node_id = node_id
self.label = label
self.from_links = set()
self.to_links = set()
def from_link(self, l):
self.from_links.add(l)
def to_link(self, l):
self.to_links.add(l)
def remove_from_link(self, l):
self.from_links.remove(l)
def remove_to_link(self, l):
self.to_links.remove(l)
def is_orphen(self):
return not (self.to_links or self.from_links)
def __repr__(self):
return "Node<%d, %s>" % (self.node_id, label)
class Link:
def __init__(self, frm, to):
self.frm = frm
self.to = to
self.to_node = None
self.frm_node = None
def __repr__(self):
return "Link<%s, %s>" % (self.frm_node, self.to_node)
class Graph:
def __init__(self):
self.nodes = dict()
self.links = set()
def add_node(self, node):
self.nodes[node.node_id] = node
def add_link(self, l):
self.links.add(l)
l.to_node = self.nodes[l.to]
l.frm_node = self.nodes[l.frm]
self.nodes[l.frm].from_link(l)
self.nodes[l.to].to_link(l)
def remove_link(self, l):
self.links.remove(l)
fn = self.nodes[l.frm]
tn = self.nodes[l.to]
fn.remove_from_link(l)
tn.remove_to_link(l)
def remove_node(self, n):
del self.nodes[n.node_id]
g = Graph()
for i, label in enumerate(s, 1):
g.add_node(Node(i, label))
for _ in range(M):
a, b = map(int, input().split())
g.add_link(Link(a, b))
g.add_link(Link(b, a))
while True:
flag = False
touched = set()
for n in g.nodes.values():
if not n.to_links:
continue
lbl = set(m.to_node.label for m in n.from_links)
if "A" not in lbl or "B" not in lbl:
touched.add(n)
for l in n.to_links.copy():
g.remove_link(l)
touched.add(l.frm_node)
touched.add(l.to_node)
if touched:
for n in touched:
if n.is_orphen():
g.remove_node(n)
else:
break
print("Yes" if g.nodes else "No")
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
If Nusook can make all strings consisting of `A` and `B`, print `Yes`;
otherwise, print `No`.
* * *
|
s776775091
|
Wrong Answer
|
p03256
|
Input is given from Standard Input in the following format:
N M
s
a_1 b_1
:
a_{M} b_{M}
|
import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
N, M = list(map(int, sys.stdin.buffer.readline().split()))
S = sys.stdin.buffer.readline().decode().rstrip()
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]
diffs = [set() for _ in range(N)]
sames = [set() for _ in range(N)]
for a, b in AB:
a -= 1
b -= 1
if S[a] == S[b]:
sames[a].add(b)
sames[b].add(a)
else:
diffs[a].add(b)
diffs[b].add(a)
diffs = [list(s) for s in diffs]
sames = [list(s) for s in sames]
checked = [[False] * N for _ in range(2)]
# @debug
def dfs(v, pc=None, seen=None):
seen = seen or set()
if v in seen:
return True
seen.add(v)
if pc is not None:
checked[int(pc == "A")][v] = True
if pc is None or pc == S[v]:
ok = False
for u in diffs[v]:
if not checked[int(S[v] == "A")][u] and dfs(u, S[v], seen):
ok = True
break
if not ok:
seen.remove(v)
return False
if pc is None or pc != S[v]:
ok = False
for u in sames[v]:
if not checked[int(S[v] == "A")][u] and dfs(u, S[v], seen):
ok = True
break
if not ok:
seen.remove(v)
return False
return True
ok = False
for v in range(N):
if dfs(v):
ok = True
break
if ok:
print("Yes")
else:
print("No")
|
Statement
You are given an undirected graph consisting of N vertices and M edges. The
vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition,
each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i
bidirectionally connects vertex a_i and b_i.
The phantom thief Nusook likes to choose some vertex as the startpoint and
traverse an edge zero or more times. Today, he will make a string after
traveling as above, by placing the labels of the visited vertices in the order
visited, beginning from the startpoint.
For example, in a graph where Vertex 1 has the label `A` and Vertex 2 has the
label `B`, if Nusook travels along the path 1 \rightarrow 2 \rightarrow 1
\rightarrow 2 \rightarrow 2, the resulting string is `ABABB`.
Determine if Nusook can make all strings consisting of `A` and `B`.
|
[{"input": "2 3\n AB\n 1 1\n 1 2\n 2 2", "output": "Yes\n \n\n * Since Nusook can visit Vertex 1 and Vertex 2 in any way he likes, he can make all strings consisting of `A` and `B`.\n\n\n\n* * *"}, {"input": "4 3\n ABAB\n 1 2\n 2 3\n 3 1", "output": "No\n \n\n * For example, Nusook cannot make `BB`.\n * The given graph may not be connected.\n\n\n\n* * *"}, {"input": "13 23\n ABAAAABBBBAAB\n 7 1\n 10 6\n 1 11\n 2 10\n 2 8\n 2 11\n 11 12\n 8 3\n 7 12\n 11 2\n 13 13\n 11 9\n 4 1\n 9 7\n 9 6\n 8 13\n 8 6\n 4 10\n 8 7\n 4 3\n 2 1\n 8 12\n 6 9", "output": "Yes\n \n\n* * *"}, {"input": "13 17\n BBABBBAABABBA\n 7 1\n 7 9\n 11 12\n 3 9\n 11 9\n 2 1\n 11 5\n 12 11\n 10 8\n 1 11\n 1 8\n 7 7\n 9 10\n 8 8\n 8 12\n 6 2\n 13 11", "output": "No"}]
|
Print coordinate of given points in order.
|
s474849378
|
Accepted
|
p02447
|
The input is given in the following format.
$n$
$x_0 \; y_0$
$x_1 \; y_1$
:
$x_{n-1} \; y_{n-1}$
In the first line, the number of points $n$ is given. In the following $n$
lines, coordinates of each point are given.
|
from typing import List, Tuple
if __name__ == "__main__":
n = int(input())
coordinates: List[Tuple[int, int]] = []
for _ in range(n):
(x, y) = tuple(map(lambda x: int(x), input().split()))
coordinates.append((x, y))
coordinates = sorted(coordinates, key=lambda x: (x[0], x[1]))
for elem in coordinates:
print(f"{elem[0]} {elem[1]}")
|
Sorting Pairs
Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on
the plane by the following criteria.
1. first by $x$-coordinate
2. in case of a tie, by $y$-coordinate
|
[{"input": "5\n 4 7\n 5 5\n 2 3\n 6 8\n 2 1", "output": "2 1\n 2 3\n 4 7\n 5 5\n 6 8"}]
|
Print coordinate of given points in order.
|
s863491875
|
Accepted
|
p02447
|
The input is given in the following format.
$n$
$x_0 \; y_0$
$x_1 \; y_1$
:
$x_{n-1} \; y_{n-1}$
In the first line, the number of points $n$ is given. In the following $n$
lines, coordinates of each point are given.
|
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]
P.sort()
for p in P:
print(*p)
|
Sorting Pairs
Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on
the plane by the following criteria.
1. first by $x$-coordinate
2. in case of a tie, by $y$-coordinate
|
[{"input": "5\n 4 7\n 5 5\n 2 3\n 6 8\n 2 1", "output": "2 1\n 2 3\n 4 7\n 5 5\n 6 8"}]
|
Print Q lines. The i-th line should contain `YES` if the i-th plan is
feasible, and `NO` otherwise.
* * *
|
s198745283
|
Runtime Error
|
p03743
|
Input is given from Standard Input in the following format:
N D
d_1 d_2 ... d_N
Q
q_1 q_2 ... q_Q
|
x = 1
for i, d in zip(reversed(range(len(D))), reversed(D)):
if Q[-1][0] == i:
result[Q[-1][1]] = P[i] >= x
Q.pop()
if not Q:
break
if abs(x - d) < x:
x += d
for r in result:
print("YES" if r else "NO")
|
Statement
Alice lives on a line. Today, she will travel to some place in a mysterious
vehicle. Initially, the distance between Alice and her destination is D. When
she input a number x to the vehicle, it will travel in the direction of the
destination by a distance of x if this move would shorten the distance between
the vehicle and the destination, and it will stay at its position otherwise.
Note that the vehicle may go past the destination when the distance between
the vehicle and the destination is less than x.
Alice made a list of N numbers. The i-th number in this list is d_i. She will
insert these numbers to the vehicle one by one.
However, a mischievous witch appeared. She is thinking of rewriting one number
in the list so that Alice will not reach the destination after N moves.
She has Q plans to do this, as follows:
* Rewrite only the q_i-th number in the list with some integer so that Alice will not reach the destination.
Write a program to determine whether each plan is feasible.
|
[{"input": "4 10\n 3 4 3 3\n 2\n 4 3", "output": "NO\n YES\n \n\nFor the first plan, Alice will already arrive at the destination by the first\nthree moves, and therefore the answer is `NO`. For the second plan, rewriting\nthe third number in the list with 5 will prevent Alice from reaching the\ndestination as shown in the following figure, and thus the answer is `YES`.\n\n\n\n* * *"}, {"input": "5 9\n 4 4 2 3 2\n 5\n 1 4 2 3 5", "output": "YES\n YES\n YES\n YES\n YES\n \n\nAlice will not reach the destination as it is, and therefore all the plans are\nfeasible.\n\n* * *"}, {"input": "6 15\n 4 3 5 4 2 1\n 6\n 1 2 3 4 5 6", "output": "NO\n NO\n YES\n NO\n NO\n YES"}]
|
Print the number of subsequences that satisfy the condition.
* * *
|
s705636481
|
Runtime Error
|
p02851
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
|
# 変数名の付け方の注意! 配列や集合は大文字!(なぜなら数がたくさんあるから)
# 要素は小文字(なぜなら1個しかないから)
A = [1, 5, 7, 15, 26, 45, 60, 256]
x = int(input())
li = 0
ri = len(A) - 1
while li != ri:
print(li, ri)
print("", A[li], A[ri])
mi = (li + ri) // 2
if A[mi] < x:
li = mi + 1
elif A[mi] > x:
ri = mi - 1
else:
li = mi
ri = mi
print("HIT")
if A[li] == x:
print("発見!", li)
else:
print("ないよ!")
|
Statement
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
positive integer K.
Find the number of non-empty contiguous subsequences in A such that the
remainder when dividing the sum of its elements by K is equal to the number of
its elements. We consider two subsequences different if they are taken from
different positions, even if they are equal sequences.
|
[{"input": "5 4\n 1 4 2 3 5", "output": "4\n \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n 4 2 4 2 4 2 4 2", "output": "7\n \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n 14 15 92 65 35 89 79 32 38 46", "output": "8"}]
|
Print the number of subsequences that satisfy the condition.
* * *
|
s245401119
|
Runtime Error
|
p02851
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
|
# 標準入力からKを求めるまで
N = int(input())
node = [0] * N
AB = []
for i in range(N - 1):
ab = list(map(int, input().split()))
node[ab[0] - 1] += 1
node[ab[1] - 1] += 1
AB.append(ab)
K = max(node)
print(K)
# 各辺の色を求めていく
color = [[i for i in range(1, K + 1)] for i in range(N)]
for i in range(N - 1):
now = list(set(color[AB[i][0] - 1]) & set(color[AB[i][1] - 1]))
tmp = now[0]
color[AB[i][0] - 1].remove(tmp)
color[AB[i][1] - 1].remove(tmp)
print(tmp)
|
Statement
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
positive integer K.
Find the number of non-empty contiguous subsequences in A such that the
remainder when dividing the sum of its elements by K is equal to the number of
its elements. We consider two subsequences different if they are taken from
different positions, even if they are equal sequences.
|
[{"input": "5 4\n 1 4 2 3 5", "output": "4\n \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n 4 2 4 2 4 2 4 2", "output": "7\n \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n 14 15 92 65 35 89 79 32 38 46", "output": "8"}]
|
Print the number of subsequences that satisfy the condition.
* * *
|
s356639227
|
Wrong Answer
|
p02851
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
|
n, m = map(int, input().split())
s = input()[::-1]
ans = []
now = 0
while n > m - 1:
x = s[now + 1 : now + m + 1][::-1]
x = m - x.find("0")
if x < 0:
print(-1)
quit()
n -= x
now += x
ans.append(x)
if n > 0:
ans.append(n)
print(*ans[::-1])
|
Statement
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
positive integer K.
Find the number of non-empty contiguous subsequences in A such that the
remainder when dividing the sum of its elements by K is equal to the number of
its elements. We consider two subsequences different if they are taken from
different positions, even if they are equal sequences.
|
[{"input": "5 4\n 1 4 2 3 5", "output": "4\n \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n 4 2 4 2 4 2 4 2", "output": "7\n \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n 14 15 92 65 35 89 79 32 38 46", "output": "8"}]
|
Print the number of subsequences that satisfy the condition.
* * *
|
s394202003
|
Wrong Answer
|
p02851
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
|
n, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
dp = [[0 for _ in range(k + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, k + 1):
if i >= 2:
dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1]
else:
dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] - dp[i - 2][j - 1]
print(dp[n][k])
|
Statement
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
positive integer K.
Find the number of non-empty contiguous subsequences in A such that the
remainder when dividing the sum of its elements by K is equal to the number of
its elements. We consider two subsequences different if they are taken from
different positions, even if they are equal sequences.
|
[{"input": "5 4\n 1 4 2 3 5", "output": "4\n \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n 4 2 4 2 4 2 4 2", "output": "7\n \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n 14 15 92 65 35 89 79 32 38 46", "output": "8"}]
|
Print the number of subsequences that satisfy the condition.
* * *
|
s561193742
|
Wrong Answer
|
p02851
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
|
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = [0 for _ in range(N)]
D = {0: [-1]}
E = {0: 1}
X[0] = (A[0] - 1) % K
if X[0] in D:
D[X[0]].append(0)
E[X[0]] += 1
else:
D[X[0]] = [0]
E[X[0]] = 1
for i in range(1, N):
X[i] = (X[i - 1] + A[i] - 1) % K
if X[i] in D:
D[X[i]].append(i)
E[X[i]] += 1
else:
D[X[i]] = [i]
E[X[i]] = 1
S = 0
for i in D:
n = E[i]
if n > 1:
L = D[i][:]
m = L[-1]
for j in range(n - 1):
x = L[j]
if m - x < K:
S += n - 1 - j
else:
l, r = j, n
d = (l + r) // 2
tmp = 2 * n
while tmp != 0:
if L[d] - x <= K - 1:
l = d
d = (l + r) // 2
else:
r = d
d = (l + r) // 2
tmp //= 2
print(L[j], L[d], l, d, r)
S += d - j
print(S)
|
Statement
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
positive integer K.
Find the number of non-empty contiguous subsequences in A such that the
remainder when dividing the sum of its elements by K is equal to the number of
its elements. We consider two subsequences different if they are taken from
different positions, even if they are equal sequences.
|
[{"input": "5 4\n 1 4 2 3 5", "output": "4\n \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n 4 2 4 2 4 2 4 2", "output": "7\n \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n 14 15 92 65 35 89 79 32 38 46", "output": "8"}]
|
Print 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s191743848
|
Runtime Error
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
N = input('')
N=int(N)
tmp=2**N-1
tmpK = list(map(int,input().split()))
#K=input('')
#tmpK=K.split(' ')
#tmpK = [int(s) for s in tmpK]
#print(tmpK[0:1])
#tmpK=int(tmpK)
#print(tmpK)
for i in range(1,tmp+1):
#print("i=",i)
if i==2:
max1=tmpK[0]+tmpK[1]
max2=tmpK[0]+tmpK[2]
if max1<max2:
print(max2)
else:
print(max1)
else:
test=tmpK[0:i+1]
#print(test)
ld = sorted(test, reverse=True)
#print("ld=",ld)
print(ld[0]+ld[1])
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Print 2^N-1 lines. In the i-th line, print the answer of the problem above for
K=i.
* * *
|
s340899593
|
Wrong Answer
|
p03313
|
Input is given from Standard Input in the following format:
N
A_0 A_1 ... A_{2^N-1}
|
#!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
N = int(input())
A = list(map(int, input().split()))
for i in range(2**N):
print(0)
|
Statement
There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note
that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following
problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.
|
[{"input": "2\n 1 2 3 1", "output": "3\n 4\n 5\n \n\nFor K=1, the only possible pair of i and j is (i,j)=(0,1), so the answer is\nA_0+A_1=1+2=3.\n\nFor K=2, the possible pairs of i and j are (i,j)=(0,1),(0,2). When\n(i,j)=(0,2), A_i+A_j=1+3=4. This is the maximum value, so the answer is 4.\n\nFor K=3, the possible pairs of i and j are\n(i,j)=(0,1),(0,2),(0,3),(1,2),(1,3),(2,3) . When (i,j)=(1,2), A_i+A_j=2+3=5.\nThis is the maximum value, so the answer is 5.\n\n* * *"}, {"input": "3\n 10 71 84 33 6 47 23 25", "output": "81\n 94\n 155\n 155\n 155\n 155\n 155\n \n\n* * *"}, {"input": "4\n 75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32", "output": "101\n 120\n 147\n 156\n 156\n 178\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194\n 194"}]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.