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 circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s248619409 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | R = int.input()
print(2 * 3.14159 * R)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s595191047 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 6.3)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s031625850 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(3.14159265 * float(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s941295292 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(float(input()) * 3.14)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s683235598 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | 3.1415
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s363691242 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | print(int(input) * 22 / 7)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s610557306 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(2 * int(input()) * 3.141592653589)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s779620561 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | # -*- coding: utf-8 -*-
import sys
from math import pi
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 list4d(a, b, c, d, e):
return [[[[e] * d for j in range(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(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
R = INT()
ans = R * 2 * pi
print(ans)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s498754897 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | n, m = list(map(int, input().rstrip().split()))
total = sum([int(i) for i in input().rstrip().split()])
result = -1 if n < total else n - total
print(result)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s987419525 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | n, k = map(int, input().split())
m = 1000000007
ans = []
for i in range(1, n + 2):
ans_min = (0 + (i - 1)) * i * 0.5
ans_max = ((n + 1 - i) + n) * i * 0.5
ans.append(ans_max - ans_min + 1)
ans_wa = [ans[0]]
for i in range(1, n + 1):
ans_wa.append(ans_wa[i - 1] + ans[i])
print(int((ans_wa[n] - ans_wa[k - 2]) % m))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s770555454 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(2 * 3.141592653589793238462643383279 + int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s748937360 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(2 * (22 / 7) * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s640628475 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(6.28 * int(input()))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s417236311 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | float(input()) * 2 * 3.14
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s884955850 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 6, 2)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s735637438 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | N = input()
A = list(input().split(" "))
for n in range(1, int(N)):
print(A.count(n))
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s141902998 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(float(input()) * 3.14 * 2.0)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s946605696 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | print(float(input()) * 2 * 3.14)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s501774845 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | a, b = map(int, input().split())
c = list(map(int, input().split()))
d = sum(c)
print(a - d)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s573265329 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.141592653589793238462643383279502884197169399375105820974944)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s863527387 | Accepted | p02705 | Input is given from Standard Input in the following format:
R | H = int(input())
S = 3.14
print(H * 2 * S)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s010312903 | Wrong Answer | p02705 | Input is given from Standard Input in the following format:
R | print(int(input()) * 3.1416)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the circumference of the circle. Your output is considered correct if
and only if its absolute or relative error from our answer is at most 10^{-2}.
* * * | s189398444 | Runtime Error | p02705 | Input is given from Standard Input in the following format:
R | print(input() * 2 * 3.14)
| Statement
Print the circumference of a circle of radius R. | [{"input": "1", "output": "6.28318530717958623200\n \n\nSince we accept an absolute or relative error of at most 10^{-2}, 6.28 is also\nan acceptable output, but 6 is not.\n\n* * *"}, {"input": "73", "output": "458.67252742410977361942"}] |
Print the answer.
* * * | s921600174 | Accepted | p03817 | The input is given from Standard Input in the following format:
x | 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 main():
x = int(input())
# b , c = tin()
# s = input()
na = x // 11
nb = x % 11
nc = 0 if nb == 0 else 1 if nb <= 6 else 2
return na * 2 + nc
# +++++
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
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s504313503 | Accepted | p03817 | The input is given from Standard Input in the following format:
x | import sys
from sys import exit
from collections import deque
from bisect import (
bisect_left,
bisect_right,
insort_left,
insort_right,
) # func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan
sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9 + 7
def lcm(x, y):
return x * y // gcd(x, y)
def lgcd(l):
return reduce(gcd, l)
def llcm(l):
return reduce(lcm, l)
def powmod(n, i, mod):
return pow(n, mod - 1 + i, mod) if i < 0 else pow(n, i, mod)
def div2(x):
return x.bit_length()
def div10(x):
return len(str(x)) - (x == 0)
def perm(n, mod=None):
ans = 1
for i in range(1, n + 1):
ans *= i
if mod != None:
ans %= mod
return ans
def intput():
return int(input())
def mint():
return map(int, input().split())
def lint():
return list(map(int, input().split()))
def ilint():
return int(input()), list(map(int, input().split()))
def judge(x, l=["Yes", "No"]):
print(l[0] if x else l[1])
def lprint(l, sep="\n"):
for x in l:
print(x, end=sep)
def ston(c, c0="a"):
return ord(c) - ord(c0)
def ntos(x, c0="a"):
return chr(x + ord(c0))
class counter(dict):
def __init__(self, *args):
super().__init__(args)
def add(self, x):
self.setdefault(x, 0)
self[x] += 1
class comb:
def __init__(self, n, mod=None):
self.l = [1]
self.n = n
self.mod = mod
def get(self, k):
l, n, mod = self.l, self.n, self.mod
k = n - k if k > n // 2 else k
while len(l) <= k:
i = len(l)
l.append(
l[i - 1] * (n + 1 - i) // i
if mod == None
else (l[i - 1] * (n + 1 - i) * powmod(i, -1, mod)) % mod
)
return l[k]
x = intput()
print(2 * (x // 11) + ((x % 11) != 0) + ((x % 11) > 6))
| Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s995170597 | Wrong Answer | p03817 | The input is given from Standard Input in the following format:
x | # -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache
class cin:
def int():
return int(sys.stdin.readline().rstrip())
def string():
return sys.stdin.readline().rstrip()
def mapInt():
return [int(x) for x in cin.string().split()]
def stringList(n):
return [input() for i in range(n)]
def intListList(n):
return [cin.mapInt() for i in range(n)]
def intColsList(n):
return [int(input()) for i in range(n)]
class Math:
def gcd(a, b):
if b == 0:
return a
return Math.gcd(b, a % b)
def lcm(a, b):
return (a * b) // Math.gcd(a, b)
def roundUp(a, b):
return -(-a // b)
def toUpperMultiple(a, x):
return Math.roundUp(a, x) * x
def toLowerMultiple(a, x):
return (a // x) * x
def nearPow2(n):
if n <= 0:
return 0
if n & (n - 1) == 0:
return n
ret = 1
while n > 0:
ret <<= 1
n >>= 1
return ret
def isPrime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
d = int(n**0.5) + 1
for i in range(3, d + 1, 2):
if n % i == 0:
return False
return True
MOD = int(1e09) + 7
def main():
N = cin.int()
ans = (N // 11) * 2
if N % 11 <= 5:
ans += 1
else:
ans += 2
print(ans)
return
if __name__ == "__main__":
main()
| Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s591890364 | Runtime Error | p03817 | The input is given from Standard Input in the following format:
x | import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque
# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")
##### stdin ####
def LM(t, r):
return list(map(t, r))
def R():
return stdin.readline()
def RS():
return R().split()
def I():
return int(R())
def F():
return float(R())
def LI():
return LM(int, RS())
def LF():
return LM(float, RS())
def ONE_SL():
return list(input())
def ONE_IL():
return LM(int, ONE_SL())
def ALL_I():
return map(int, stdin)
def ALL_IL():
return LM(int, stdin)
##### tools #####
def ap(f):
return f.append
def pll(li):
print("\n".join(LM(str, li)))
def pljoin(li, s):
print(s.join(li))
##### main #####
class BIT(object):
def __init__(self, l):
self.size = l
self.bit = [0] * (self.size + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i, x):
while i < self.size:
self.bit[i] += x
i += i & -i
def __str__(self):
return str(self.bit)
def main():
N, M = LI()
bit = BIT(M + 2)
L = []
R = []
b = [[] for i in range(M + 1)]
for i in range(N):
l, r = LI()
L.append(l)
R.append(r)
b[r - l + 1].append(i)
b = []
gone = 0
for d in range(1, M + 1):
for i in b[d]:
gone += 1
bit.add(L[i], 1)
bit.add(R[i] + 1, -1)
ans = N - gone
for m in range(d, M + 1, d):
ans += bit.sum(m)
print(ans)
if __name__ == "__main__":
main()
| Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s284601581 | Runtime Error | p03817 | The input is given from Standard Input in the following format:
x | n=int(input())
ans=(n//11)*2
ans+=2 if n-n//11>6 else 1
ans-=1 if n-n//11=0 else 0
print(ans) | Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s117209664 | Accepted | p03817 | The input is given from Standard Input in the following format:
x | dim, mod = divmod(int(input()), 11)
print(dim * 2 + (1 if 7 > mod else 2) * (mod > 0))
| Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s966808566 | Runtime Error | p03817 | The input is given from Standard Input in the following format:
x | x = int(input())
count = 0
q, mod = divmod(x, 11)
count += q*2
if mod > 0:
if(mod <= 6):
count += 1
else:
count += 2
print(count) | Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s232864176 | Runtime Error | p03817 | The input is given from Standard Input in the following format:
x | x = int(input())
t = x // 11
x -= 11 * t
ans = t * 2
if x <= 5:
ans += 1
elif 5 < x < 11:
ans += 2
print(ans)za | Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
Print the answer.
* * * | s584526110 | Accepted | p03817 | The input is given from Standard Input in the following format:
x | n = int(input())
num1 = (n // 11) * 2
num2 = n % 11
if num2 == 0:
print(num1)
elif num2 >= 1 and num2 <= 6:
print(num1 + 1)
else:
print(num1 + 2)
| Statement
Snuke has decided to play with a six-sided die. Each of its six sides shows an
integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing
upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces
upward, the near side shows 5 and the right side shows 4, as illustrated in
the figure. If the die is rotated toward the right as shown in the figure, the
side showing 3 will face upward. Besides, the side showing 4 will face upward
if the die is rotated toward the left, the side showing 2 will face upward if
the die is rotated toward the front, and the side showing 5 will face upward
if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score
at least x points in total. | [{"input": "7", "output": "2\n \n\n* * *"}, {"input": "149696127901", "output": "27217477801"}] |
If there is a combination of numbers of cranes and turtles in which the
statement is correct, print `Yes`; otherwise, print `No`.
* * * | s202701631 | Wrong Answer | p02640 | Input is given from Standard Input in the following format:
X Y | a, b = [int(x) for x in input().split(" ")]
x = (b - 2 * a) / 2
y = (4 * a - b) / 2
print("Yes" if x > 0 and y > 0 and x % 1 == 0.0 and y % 1 == 0.0 else "No")
| Statement
There are some animals in a garden. Each of them is a crane with two legs or a
turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y
legs in total." Determine whether there is a combination of numbers of cranes
and turtles in which this statement is correct. | [{"input": "3 8", "output": "Yes\n \n\nThe statement \"there are 3 animals in total in the garden, and they have 8\nlegs in total\" is correct if there are two cranes and one turtle. Thus, there\nis a combination of numbers of cranes and turtles in which the statement is\ncorrect.\n\n* * *"}, {"input": "2 100", "output": "No\n \n\nThere is no combination of numbers of cranes and turtles in which this\nstatement is correct.\n\n* * *"}, {"input": "1 2", "output": "Yes\n \n\nWe also consider the case in which there are only cranes or only turtles."}] |
If there is a combination of numbers of cranes and turtles in which the
statement is correct, print `Yes`; otherwise, print `No`.
* * * | s426949754 | Runtime Error | p02640 | Input is given from Standard Input in the following format:
X Y | x, n = map(int, input().split())
s = []
if n == 0:
print(x)
else:
a = sorted([i for i in list(map(int, input().split())) if i != x])
for i in range(n):
s.append(abs(a[i] - x))
b = a[s.index(min(s))]
print(b)
| Statement
There are some animals in a garden. Each of them is a crane with two legs or a
turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y
legs in total." Determine whether there is a combination of numbers of cranes
and turtles in which this statement is correct. | [{"input": "3 8", "output": "Yes\n \n\nThe statement \"there are 3 animals in total in the garden, and they have 8\nlegs in total\" is correct if there are two cranes and one turtle. Thus, there\nis a combination of numbers of cranes and turtles in which the statement is\ncorrect.\n\n* * *"}, {"input": "2 100", "output": "No\n \n\nThere is no combination of numbers of cranes and turtles in which this\nstatement is correct.\n\n* * *"}, {"input": "1 2", "output": "Yes\n \n\nWe also consider the case in which there are only cranes or only turtles."}] |
If there is a combination of numbers of cranes and turtles in which the
statement is correct, print `Yes`; otherwise, print `No`.
* * * | s414900898 | Wrong Answer | p02640 | Input is given from Standard Input in the following format:
X Y | #!/usr/bin/env python3
| Statement
There are some animals in a garden. Each of them is a crane with two legs or a
turtle with four legs.
Takahashi says: "there are X animals in total in the garden, and they have Y
legs in total." Determine whether there is a combination of numbers of cranes
and turtles in which this statement is correct. | [{"input": "3 8", "output": "Yes\n \n\nThe statement \"there are 3 animals in total in the garden, and they have 8\nlegs in total\" is correct if there are two cranes and one turtle. Thus, there\nis a combination of numbers of cranes and turtles in which the statement is\ncorrect.\n\n* * *"}, {"input": "2 100", "output": "No\n \n\nThere is no combination of numbers of cranes and turtles in which this\nstatement is correct.\n\n* * *"}, {"input": "1 2", "output": "Yes\n \n\nWe also consider the case in which there are only cranes or only turtles."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s843643204 | Wrong Answer | p03952 | The input is given from Standard Input in the following format:
N x | print("No")
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s585073206 | Wrong Answer | p03952 | The input is given from Standard Input in the following format:
N x | N, K = map(int, input().split())
print("No" if K < N else "Yes\n" + "\n".join(map(str, range(1, K * 2))))
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s616087436 | Accepted | p03952 | The input is given from Standard Input in the following format:
N x | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from itertools import *
def bf(n):
variations = set()
for comb in permutations(list(range(1, n + 1))):
top = sim(comb)
if top not in variations:
print(top, comb)
variations.add(top)
# if top != comb[ len(comb) // 2 ]:
# print("exception!")
# print("comb, result = ", comb, top)
print(variations)
def sim(comb):
comb = list(comb)
while len(comb) != 1:
n_comb = []
for i in range(len(comb) - 2):
arr = comb[i : i + 3]
arr.sort()
n_comb.append(arr[1])
comb = n_comb
# print(comb[0])
return comb[0]
# bf(3)
# bf(5)
# bf(7)
# bf(9)
# bf(11)
def main():
N, x = map(int, input().split())
if N == 1:
if x == 1:
print("Yes")
print(1)
else:
print("No")
else:
length = N * 2 - 1
if 2 <= x <= length - 1:
print("Yes")
mid = (length + 1) // 2
if x > mid:
flip = True
x = length + 1 - x
else:
flip = False
ans = (
list(range(1, x - 1))
+ list(range(x + 1, mid + 1))
+ list(range(x - 1, x + 1))
+ list(range(mid + 1, length + 1))
)
if flip:
ans2 = [length + 1 - x for x in ans]
ans = ans2
for e in ans:
print(e)
else:
print("No")
main()
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s139175359 | Wrong Answer | p03952 | The input is given from Standard Input in the following format:
N x | import math
import fractions
# import sys
# input = sys.stdin.readline
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
return divisors
def ValueToBits(x, digit):
res = [0 for i in range(digit)]
now = x
for i in range(digit):
res[i] = now % 2
now = now >> 1
return res
def BitsToValue(arr):
n = len(arr)
ans = 0
for i in range(n):
ans += arr[i] * 2**i
return ans
def ZipArray(a):
aa = [[a[i], i] for i in range(n)]
aa.sort(key=lambda x: x[0])
for i in range(n):
aa[i][0] = i + 1
aa.sort(key=lambda x: x[1])
b = [aa[i][0] for i in range(len(a))]
return b
def ValueToArray10(x, digit):
ans = [0 for i in range(digit)]
now = x
for i in range(digit):
ans[digit - i - 1] = now % 10
now = now // 10
return ans
def Zeros(a, b):
if b <= -1:
return [0 for i in range(a)]
else:
return [[0 for i in range(b)] for i in range(a)]
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
"""
def cmb(n, r, p):
if (r < 0) or (n < r):
return 0
r = min(r, n - r)
return fact[n] * factinv[r] * factinv[n-r] % p
p = 2
N = 10 ** 6 + 2
fact = [1, 1] # fact[n] = (n! mod p)
factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1] # factinv 計算用
for i in range(2, N + 1):
fact.append((fact[-1] * i) % p)
inv.append((-inv[p % i] * (p // i)) % p)
factinv.append((factinv[-1] * inv[-1]) % p)
"""
# a = list(map(int, input().split()))
#################################################
#################################################
#################################################
#################################################
n, x = list(map(int, input().split()))
if x == 1 or x == n * 2 - 1:
print("No")
exit()
if x == n:
for i in range(2 * n - 1):
print(i + 1)
exit()
elif x < n:
nums = [-1 for i in range(2 * n - 1)]
used = [0 for i in range(2 * n)]
used[0] = 1
nums[n - 1] = x
nums[n] = x - 1
nums[n - 2] = x + 1
nums[n - 3] = x + 2
used[x] = used[x - 1] = used[x + 1] = used[x + 2] = 1
# print(nums,used)
now = 0
pos = 0
while pos < 2 * n - 1:
if used[now] == 1:
now += 1
continue
if nums[pos] != -1:
pos += 1
continue
nums[pos] = now
used[now] = 1
pos += 1
now += 1
else:
nums = [-1 for i in range(2 * n - 1)]
used = [0 for i in range(2 * n)]
used[0] = 1
nums[n - 1] = x
nums[n] = x + 1
nums[n - 2] = x - 1
nums[n - 3] = x - 2
used[x] = used[x + 1] = used[x - 1] = used[x - 2] = 1
# print(nums,used)
now = 0
pos = 0
while pos < 2 * n - 1:
if used[now] == 1:
now += 1
continue
if nums[pos] != -1:
pos += 1
continue
nums[pos] = now
used[now] = 1
pos += 1
now += 1
print("Yes")
for i in nums:
print(i)
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s793043150 | Runtime Error | p03952 | The input is given from Standard Input in the following format:
N x | import sys,bisect as bs,collections as cl,heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return map(int,input().split())
def onem(): #Nとかの取得
return int(input())
def s(x): #圧縮
a = []
aa = x[0]
su = 1
for i in range(len(x)-1):
if aa != x[i+1]:
a.append([aa,su])
aa = x[i+1]
su = 1
else:
su += 1
a.append([aa,su])
return a
def jo(x): #listをスペースごとに分ける
return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
return max(map(max,x))
def In(x,a): #aがリスト(sorted)
k = bs.bisect_left(a,x)
if k != len(a) and a[k] == x:
return True
else:
return False
n,m = m()
if m == 1 or 2*n-1 == m:
print("No")
else:
print("Yes")
if n == 2:
ans = [1,2,3]
print(jo(ans))
else:
if m == 2:
a = [3,2,1,4]
ans = [i + 5 for i in range(n-2)] + a + [i + n+3 for i in range(n-3)]
else:
a = [m-1,m,m+1,m-2]
i = 0
ans = []
for j in range(2*n-4):
i += 1
if j == n-1:
ans += a
i -= 1
else:
if i == m-2:
i += 4
ans.append(i)
print(jo(ans))
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s344666272 | Accepted | p03952 | The input is given from Standard Input in the following format:
N x | # 愚直解
# from itertools import permutations
# # n = int(input())
# # kumiawase = list(permutations(range(1, 2 * n), 2 * n - 1))
# ans_set = set()
# kumiawase = [(3, 4, 5, 6, 1, 2, 7, 8, 9, 10, 11)]
# for kumi in kumiawase:
# kouho = kumi
# while kouho:
# nex = []
# for i in range(len(kouho) - 2):
# temp = [kouho[i], kouho[i + 1], kouho[i + 2]]
# temp.sort()
# nex.append(temp[1])
# if len(nex) == 1:
# break
# kouho = nex[::]
# print(kouho)
# ans_set.add(nex[0])
# if nex[0] == 2:
# print(kumi)
# exit()
# print(ans_set)
n, x = map(int, input().split())
if x <= 1 or x >= 2 * n - 1:
print("No")
exit()
if n == 2:
print("Yes")
for i in range(3):
print(i + 1)
exit()
ans = [0] * (2 * n - 1)
used = [False] * (2 * n)
if x <= n:
ans[n - 1] = x
ans[n - 2] = x - 1
ans[n] = x + 1
ans[n - 3] = x + 2
used[x] = True
used[x - 1] = True
used[x + 1] = True
used[x + 2] = True
num = 1
for i in range(2 * n - 1):
if ans[i] == 0:
while used[num]:
num += 1
ans[i] = num
num += 1
print("Yes")
print(*ans, sep="\n")
else:
ans[n - 1] = x
ans[n - 2] = x + 1
ans[n] = x - 1
ans[n - 3] = x - 2
used[x] = True
used[x + 1] = True
used[x - 1] = True
used[x - 2] = True
num = 1
for i in range(2 * n - 1):
if ans[i] == 0:
while used[num]:
num += 1
ans[i] = num
num += 1
print("Yes")
print(*ans, sep="\n")
| Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s175911929 | Runtime Error | p03952 | The input is given from Standard Input in the following format:
N x | n, x = map(int, input().split())
if abs(n-x)<=1 :
print('Yes')
else:
print('No')
exit()
if n == x:
for i in range(2*(n-1)):
print(i+1)
elif x == n-1:
print(n)
for i in range(2*(n-1)):
if i != n:
print(i)
else x == n-1:
for i in range(2*(n-1)):
if i != n:
print(i)
print(n) | Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks
of step N, print `No`.
Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.
The i-th of these 2N-1 lines should contain the i-th element of a possible
permutation.
* * * | s337882816 | Runtime Error | p03952 | The input is given from Standard Input in the following format:
N x | n,x=map(int,input().split())
if n==2:
if x==2:
print("Yes",1,2,3,sep="\n")
exit()
else:
print("No")
exit()
if x==1 or x==n*2-1:
print("No")
exit()
ans=[i for i in range(1,2n)]
for i in range(len(ans)):
ans[i]=(ans[i]-(n-x+1))%(2*n-1)+1
print("Yes",ans,sep="\n") | Statement
We have a pyramid with N steps, built with blocks. The steps are numbered 1
through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks
aligned horizontally. The pyramid is built so that the blocks at the centers
of the steps are aligned vertically.

A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N.
Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only
remembers that the integer written into the block of step 1 was x.
Construct a permutation of (1, 2, ..., 2N-1) that could have been written into
the blocks of step N, or declare that Snuke's memory is incorrect and such a
permutation does not exist. | [{"input": "4 4", "output": "Yes\n 1\n 6\n 3\n 7\n 4\n 5\n 2\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "2 1", "output": "No\n \n\nNo matter what permutation was written into the blocks of step N, the integer\nwritten into the block of step 1 would be 2."}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s385219578 | Runtime Error | p03401 | 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()]
tmp = a[0]
for i in range(1,n):
tmp += abs(a[i] - a[i-1])
a = [0] + a + [0]
for i in range(1,n+1):
print(tmp - (abs(a[i] - a[i - 1])) - (abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]))
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s789781156 | Wrong Answer | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N = int(input())
A = [0] + [int(X) for X in input().split()] + [0]
Cost = [abs(A[T + 1] - A[T]) for T in range(N + 1)]
Total = sum(Cost)
for T in range(0, N):
if A[T] < A[T + 2] < A[T + 1] or A[T + 1] < A[T + 2] < A[T]:
print(Total - 2 * Cost[T + 1])
elif A[T + 1] < A[T] < A[T + 2] or A[T + 2] < A[T] < A[T + 1]:
print(Total - 2 * Cost[T])
else:
print(Total)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s902550700 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N = int(input())
a = [0] + list(map(int,input().split()) + [0]
A = [abs(a[i]-a[i+1]) for i in range(N+1)]
total = sum(A)
for i in range(N):
print(total + abs(a[i+2]-a[i])-A[i]-A[i+1])
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s942029344 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import copy
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
for i in range(n):
my_sum = 0
l = copy.copy(a)
del l[i+1]
for j in range(n):
my_sum += abs(l[j] - l[j+1])
print(my_sum) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s716397416 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | a = int(input())
x = list(map(str, input().split()))
x = [0] + x + [0]
s = 0
for i in range(1, a + 2):
s += abs(x[i - 1] - x[i])
for i in range(1, a + 1):
print(s + abs(x[i - 1] - x[i + 1]) - (abs(x[i - 1] - x[i]) + abs(x[i] - x[i + 1])))
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s521062173 | Runtime Error | p03401 | 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())
i = 0
for i in range(N):
A.pop(i)
A.insert(0,0)
print(sum(abs(A[i+1]-A[i]))
i+=1 | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s305601649 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N = int(input())
a = [0]+list(map(int,input().split())+[0]
A =[abs(a[i]-a[i+1]) for i in range(N+1)]
total = sum(A)
for i in range(N):
print(total+abs(a[i+2]-a[i])-A[i]-A[i+1]) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s341834990 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | 6
-679 -2409 -3258 3095 -3291 -4462 | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s937037421 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | _,a=open(0)
a=[0]+list(map(int,a.split()))+[0]
A=abs
c=sum(A(j-i)for i,j in zip(a,a[1:]));for i,j,k in zip(a,a[1:],a[2:]):print(c-A(j-i)-A(k-j)+A(k-i)) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s878692241 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | n = (int)(input())
l = (list)(map(int, input().split()))
max_l = max(l) if max(l) >= 0 else 0
min_l = min(l) if min(l) <= 0 else 0
l_sort = sorted(l)
for i in range(n):
if l[i] == min(l):
cost = max(l)*2 + (lambda -x*2: x if x <= 0 else 0)(l_sort[1])
elif l[i] == max(l):
cost = -min(l)*2 + (lambda x*2: x if x >= 0 else 0)(l_sort[n-2])
else:
cost = -min_l*2 + max_l*2
print(cost)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s557970095 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | (n,) = map(int, input().split())
a = list(map(int, input().split()))
ans = []
h = a[0]
i = a[1]
s = h + abs(h - i)
if i < h:
ans.append(-1 * abs(h - i))
else:
ans.append(0)
for x in range(2, n + 1):
j = a[x]
s += abs(i - j)
if j < i:
ans.append(-1 * abs(i - j))
else:
ans.append(0)
h = i
i = j
for x in ans:
print(s + x)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s662659208 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | = int(input())
A = list(map(int,input().split()))
j = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
j += abs(A[i]-A[i+1])
for i in range(N):
if i == 0:
ans = j-abs(A[0])-abs(A[0]-A[1])+abs(A[1])
elif i == N-1:
ans = j-abs(A[N-2]-A[N-1])-abs(A[N-1])+abs(A[N-2])
else:
ans = j - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])
print(ans) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s424124982 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | # -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem C
if __name__ == '__main__':
spot_count = int(input())
mod_spots = [0] + list(map(int, input().split())) + [0]
# FIXME: TLE
for i in range(spot_count):
tmp = mod_spots[i + 1]
# # mod_spots[i + 1] = 0
# # min_value = min(mod_spots[1:-1])
# # max_value = max(mod_spots[1:-1])
# min_value = min(mod_spots[1:len(mod_spots) - 1])
# max_value = max(mod_spots[1:len(mod_spots) - 1])
# # cost = 0
# # if min_value * max_value > 0:
# if (min_value > 0 and max_value > 0) or (min_value < 0 and max_value < 0):
# # cost = max(abs(max_value), abs(min_value)) * 2
# print(max(abs(max_value), abs(min_value)) * 2)
# # elif min_value * max_value < 0:
# elif (min_value < 0 and max_value > 0) or (min_value > 0 and max_value < 0):
# # cost = abs(max_value) + abs(min_value)
# print((abs(max_value) + abs(min_value)) * 2)
# elif (min_value == 0 and max_value != 0) or (max_value == 0 and min_value != 0):
# print(max(abs(max_value), abs(min_value)) * 2)
# else:
# # cost = 0
# print(0)
if mod_spots[i] <= mod_spots[i + 2]:
mod_spots[i + 1] = mod_spots[i]
elif (mod_spots[i] > 0) and mod_spots[i + 2] > 0:
mod_spots[i + 1] = 0
else:
mod_spots[i + 1] = mod_spots[i]
# cost = sum([abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)])
# hoge = [abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)]
hoge = {j: abs(mod_spots[j + 1] - mod_spots[j]) for j in range(spot_count + 1)}
print(sum(hoge.values())
mod_spots[i + 1] = tmp
# print(cost)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s200037455 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向
int n;
int a[100010];
void input(){
cin >> n;
for(int i=0;i<n;i++) cin >> a[i];
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
input();
int sum = abs(a[0]) + abs(a[n-1]);
for(int i=1;i<n;i++) sum += abs(a[i] - a[i-1]);
cout << (sum + abs(a[1]) - (abs(a[0])+abs(a[1]-a[0]))) << endl;
for(int i=1;i<n-1;i++){
cout << (sum + abs(a[i+1]-a[i-1]) - (abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))) << endl;
}
cout << (sum + abs(a[n-2]) - (abs(a[n-1]-a[n-2])+abs(a[n-1]))) << endl;
} | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s423822875 | Runtime Error | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | n = int(input())
lis = [0] + list(map(int,input().split())) + [0]
b = 0
for i in range(n+1):
b += abs(lis[i+1]-lis[i])
for i in range(1,n+1):
if lis[i-1] <= lis[i] <= lis[i+1] or lis[i-1] => lis[i] => lis[i+1]:
print(b)
else:
print(b-abs(lis[i-1] - lis[i]) - abs(lis[i+1] - lis[i]) + abs(lis[i+1] - lis[i-1])) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s343182610 | Runtime Error | p03401 | 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()))
for i in N:
abs=abs(A-)
D,X = map(int, input().split())
N_chocolate=0
for i in range (N):
A= int(input())
if A == 1:
N_chocolate=N_chocolate+D-1
else:
N_chocolate=N_chocolate+int(D/A)
output=N_chocolate+X+N
print (output) | Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s525312614 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/21
Solved on 2019/3/
@author: shinjisu
"""
# ABC 0xx C xxx
# import math
# import numpy as np
def getInt():
return int(input())
def getIntList():
return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)
def zeros(n):
return [0] * n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def getIntLines(n):
return [int(input()) for i in range(n)]
"""
def getIntLines(n):
data = zeros(n)
for i in range(n):
data[i] = getInt()
return data
"""
def zeros2(n, m):
return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替
def getIntMat(n, m): # n行に渡って、1行にm個の整数
# mat = zeros((n, m))
mat = zeros2(n, m)
for i in range(n):
mat[i] = getIntList()
return mat
ALPHABET = [chr(i + ord("a")) for i in range(26)]
DIGIT = [chr(i + ord("0")) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18
class Debug:
def __init__(self):
self.debug = True
def off(self):
self.debug = False
def dmp(self, x, cmt=""):
if self.debug:
if cmt != "":
print(cmt, ": ", end="")
print(x)
return x
def prob():
d = Debug()
d.off()
N = getInt()
d.dmp((N), "N")
A = zeros(N + 2)
A[1 : N + 1] = getIntList()
d.dmp((A), "A")
yenAll = 0
for i in range(1, N + 2):
yenAll += abs(A[i] - A[i - 1])
d.dmp((yenAll), "A")
yenOmit = yenAll
for i in range(1, N + 1):
yenOmit = yenAll - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i])
yenOmit += abs(A[i + 1] - A[i - 1])
print(yenOmit)
return None
ans = prob()
if ans is None:
pass
elif type(ans) == tuple and ans[0] == 1: # 1,ans
for elm in ans[1]:
print(elm)
else:
print(ans)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s670436853 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | n = int(input())
(*a,) = map(int, input().split())
if n != 2:
b = [abs(a[0])] + [abs(i - j) for i, j in zip(a, a[1:])] + [abs(a[-1])]
c = [abs(a[1])] + [abs(i - j) for i, j in zip(a, a[2:])] + [abs(a[-2])]
s = sum(b)
for i, j, k in zip(b, b[1:], c):
print(s - i - j + k)
else:
print(2 * abs(a[1]), 2 * abs(a[0]))
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s716125404 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import math
import numpy as np
from operator import mul
# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]
# 入力が文字のリスト
# S = list(input().split())
# 入力が数字のリスト
# A = list(map(int, input().split()))
# 入力がリストのリスト
# S = [list(input()) for i in range(H)]
# リストliから重複を削除したリストli_uniqを作成
# li_uniq = []
# for i in li:
# if x not in li_uniq:
# li_uniq.append(x)
# 複数行のinput - list版
# list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
# for i in range(N):
# a, b = map(int, input().split())
# dict[a] = b
N = int(input())
A = list(map(int, input().split()))
value = abs(A[0])
for i in range(1, N):
value += abs(A[i] - A[i - 1])
value += abs(A[N - 1])
print(value - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))
for i in range(1, N - 1):
print(
value - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1])
)
print(value - abs(A[N - 1] - A[N - 2]) - abs(A[N - 1]) + abs(A[N - 2]))
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s304792899 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
# from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def I():
return int(input().strip())
def S():
return input().strip()
def IL():
return list(map(int, input().split()))
def SL():
return list(map(str, input().split()))
def ILs(n):
return list(int(input()) for _ in range(n))
def SLs(n):
return list(input().strip() for _ in range(n))
def ILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def SLL(n):
return [list(map(str, input().split())) for _ in range(n)]
######OUTPUT######
def P(arg):
print(arg)
return
def Y():
print("Yes")
return
def N():
print("No")
return
def E():
exit()
def PE(arg):
print(arg)
exit()
def YE():
print("Yes")
exit()
def NE():
print("No")
exit()
#####Shorten#####
def DD(arg):
return defaultdict(arg)
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####MakeDivisors######
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
#####GCD#####
def gcd(a, b):
while b:
a, b = b, a % b
return a
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def count_bit(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#####ChangeBase#####
def base_10_to_n(X, n):
if X // n:
return base_10_to_n(X // n, n) + [X % n]
return [X % n]
def base_n_to_10(X, n):
return sum(int(str(X)[-i]) * n**i for i in range(len(str(X))))
#####IntLog#####
def int_log(n, a):
count = 0
while n >= a:
n = n // a
count += 1
if a**count == n:
return count
else:
return count + 1
#############
# Main Code #
#############
N = I()
A = IL()
D = [abs(A[0])] + [abs(A[i + 1] - A[i]) for i in range(N - 1)] + [abs(A[-1])]
C = [abs(A[1])] + [abs(A[i + 1] - A[i - 1]) for i in range(1, N - 1)] + [abs(A[-2])]
S = sum(D)
for i in range(N):
P(S - D[i] - D[i + 1] + C[i])
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s861311802 | Wrong Answer | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | import sys
if sys.platform == "ios":
sys.stdin = open("Untitled.txt")
input = sys.stdin.readline
def INT():
return int(input())
def MAP():
return [int(s) for s in input().split()]
N = INT()
A = MAP()
total = 0
total += abs(A[0]) + abs(A[-1])
# print(total)
for i in range(1, N):
# print(abs(A[i]-A[i-1]))
total += abs(A[i] - A[i - 1])
# print(total)
for i in range(N):
# 終端
if i == N - 1:
# 終端がi-1と反対側
if A[i - 1] * A[i] <= 0:
print(total - abs(A[i]) * 2)
# 終端がi-1の向こう側
elif (A[i] > 0 and A[i] - 1 <= A[i]) or (A[i] < 0 and A[i - 1] >= A[i]):
print(total - abs(A[i] - A[i - 1]) * 2)
# 終端がi-1の手前
else:
print(total)
# 始端 i==0
elif i == 0:
# A[0]とA[1]の正負が反対
if A[0] * A[1] <= 0:
print(total - abs(A[0]) * 2)
# A[1]がA[0]の向こう側にあるケース
elif abs(A[1]) >= abs(A[0]):
print(total)
# A[1]がA[0]より手前にあるケース
else:
print(total - abs(A[1] - A[0]) * 2)
# i が正負の一定方向の中間地点にあるケース
elif (A[i] >= A[i - 1] and A[i + 1] >= A[i]) or (
A[i] <= A[i - 1] and A[i + 1] <= A[i]
):
print(total)
# i が飛び出ているケース i-1 < i and i+1 < i
elif A[i - 1] <= A[i] and A[i + 1] <= A[i] or A[i - 1] >= A[i] and A[i + 1] >= A[i]:
print(total - abs(A[i] - A[i - 1]) * 2)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s401400200 | Wrong Answer | p03401 | 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(" ")))
# print(n, a)
if n == 2:
print(abs(a[0]) + abs(a[0] - a[1]) + abs(a[1]))
else:
for i in range(len(a)):
b = a[:]
b.remove(b[i])
# print(b)
cost = abs(b[0])
for j in range(len(b) - 1):
# print(b[j],b[j+1])
cost += abs(b[j] - b[j + 1])
cost += abs(b[-1])
print(cost)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s534198548 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | # PROBLEM C
n = int(input())
As = [int(s) for s in input().split()]
As = [0] + As + [0]
full_cost = sum(abs(a - As[idx - 1]) for idx, a in enumerate(As) if idx - 1 >= 0)
for idx in range(1, len(As) - 1):
a = As[idx]
if any([As[idx - 1] <= a <= As[idx + 1], As[idx - 1] >= a >= As[idx + 1]]):
ci = full_cost
elif any([a > As[idx + 1] >= As[idx - 1], a < As[idx + 1] <= As[idx - 1]]):
ci = full_cost - 2 * abs(a - As[idx + 1])
elif any([a < As[idx - 1] <= As[idx + 1], As[idx + 1] <= As[idx - 1] < a]):
ci = full_cost - 2 * abs(a - As[idx - 1])
else:
assert False
print(ci)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s352209499 | Wrong Answer | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | number_of_spot = int(input())
spot_places = [int(x) for x in input().split(" ")]
print(spot_places)
total_cost = 0
now_place = 0
for c1 in range(1, number_of_spot + 1):
for c2 in range(1, len(spot_places) + 1):
if c1 == c2:
pass
else:
total_cost += abs(spot_places[c2 - 1] - now_place)
now_place = spot_places[c2 - 1]
total_cost += abs(now_place)
print(total_cost)
total_cost = 0
now_place = 0
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s670157779 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | # coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
# @lru_cache(maxsize=None)
readline = sys.stdin.readline
sys.setrecursionlimit(2000000)
# import numpy as np
alphabet = "abcdefghijklmnopqrstuvwxyz"
mod = int(10**9 + 7)
inf = int(10**20)
def yn(b):
if b:
print("yes")
else:
print("no")
def Yn(b):
if b:
print("Yes")
else:
print("No")
def YN(b):
if b:
print("YES")
else:
print("NO")
class union_find:
def __init__(self, n):
self.n = n
self.P = [a for a in range(N)]
self.rank = [0] * n
def find(self, x):
if x != self.P[x]:
self.P[x] = self.find(self.P[x])
return self.P[x]
def same(self, x, y):
return self.find(x) == self.find(y)
def link(self, x, y):
if self.rank[x] < self.rank[y]:
self.P[x] = y
elif self.rank[y] < self.rank[x]:
self.P[y] = x
else:
self.P[x] = y
self.rank[y] += 1
def unite(self, x, y):
self.link(self.find(x), self.find(y))
def size(self):
S = set()
for a in range(self.n):
S.add(self.find(a))
return len(S)
def is_pow(a, b): # aはbの累乗数か
now = b
while now < a:
now *= b
if now == a:
return True
else:
return False
def getbin(num, size):
A = [0] * size
for a in range(size):
if (num >> (size - a - 1)) & 1 == 1:
A[a] = 1
else:
A[a] = 0
return A
def get_facs(n, mod_=0):
A = [1] * (n + 1)
for a in range(2, len(A)):
A[a] = A[a - 1] * a
if mod_ > 0:
A[a] %= mod_
return A
def comb(n, r, mod, fac):
if n - r < 0:
return 0
return (fac[n] * pow(fac[n - r], mod - 2, mod) * pow(fac[r], mod - 2, mod)) % mod
def next_comb(num, size):
x = num & (-num)
y = num + x
z = num & (~y)
z //= x
z = z >> 1
num = y | z
if num >= (1 << size):
return False
else:
return num
def get_primes(n, type="int"):
if n == 0:
if type == "int":
return []
else:
return [False]
A = [True] * (n + 1)
A[0] = False
A[1] = False
for a in range(2, n + 1):
if A[a]:
for b in range(a * 2, n + 1, a):
A[b] = False
if type == "bool":
return A
B = []
for a in range(n + 1):
if A[a]:
B.append(a)
return B
def is_prime(num):
if num <= 1:
return False
i = 2
while i * i <= num:
if num % i == 0:
return False
i += 1
return True
def ifelse(a, b, c):
if a:
return b
else:
return c
def join(A, c=""):
n = len(A)
A = list(map(str, A))
s = ""
for a in range(n):
s += A[a]
if a < n - 1:
s += c
return s
def factorize(n, type_="dict"):
b = 2
list_ = []
while b * b <= n:
while n % b == 0:
n //= b
list_.append(b)
b += 1
if n > 1:
list_.append(n)
if type_ == "dict":
dic = {}
for a in list_:
if a in dic:
dic[a] += 1
else:
dic[a] = 1
return dic
elif type_ == "list":
return list_
else:
return None
def pm(x):
return x // abs(x)
def inputintlist():
return list(map(int, input().split()))
######################################################################################################
def main():
n = int(input())
A = inputintlist()
ssum = abs(0 - A[0]) + abs(0 - A[-1])
for a in range(n - 1):
ssum += abs(A[a] - A[a + 1])
A = [0] + A + [0]
for a in range(1, n + 1):
ans = (
ssum
- (abs(A[a] - A[a - 1]) + abs(A[a] - A[a + 1]))
+ abs(A[a - 1] - A[a + 1])
)
print(ans)
main()
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s564328953 | Accepted | p03401 | Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | distanceSum = 0
spotCount = int(input())
spotList = input().split()
spotList = [int(i) for i in spotList]
spotList.append(0)
def calcDistance(num): # 配列num-1番のスポットから配列num番目のスポットへの距離を計算
if num == 0: # 開始地点から配列0番=最初のスポット
return abs(spotList[num])
elif num == spotCount: # 最後スポットから開始地点
return abs(spotList[num - 1])
else:
return abs(spotList[num] - spotList[num - 1])
def calcSkipEffect(num): # 配列num番をスキップした時の移動距離への影響を計算
if num == 0: # 最初のスポットの時だけの例外
return (
abs(spotList[num + 1])
- abs(spotList[num])
- abs(spotList[num + 1] - spotList[num])
)
else:
return (
abs(spotList[num + 1] - spotList[num - 1])
- abs(spotList[num] - spotList[num - 1])
- abs(spotList[num + 1] - spotList[num])
)
for i in range(spotCount + 1): # 総移動回数はスポット数+1
distanceSum += calcDistance(i)
for j in range(spotCount): # 配列0~n-1番までの各スポットについて実行
print(str(distanceSum + calcSkipEffect(j)))
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print N lines. In the i-th line, print the total cost of travel during the
trip when the visit to Spot i is canceled.
* * * | s521762135 | Wrong Answer | p03401 | 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()))
s1 = 0
s2 = 0
s3 = 0
ma = max(A)
mi = min(A)
A1 = [0] + A + [0]
for i in range(len(A1) - 1):
s1 += abs(A1[i] - A1[i + 1])
A2 = A[:]
A2.pop(A2.index(ma))
A2 = [0] + A2 + [0]
for i in range(len(A2) - 1):
s2 += abs(A2[i] - A2[i + 1])
A3 = A[:]
A3.pop(A3.index(mi))
A3 = [0] + A3 + [0]
for i in range(len(A3) - 1):
s3 += abs(A3[i] - A3[i + 1])
for a in A:
if a == ma:
print(s2)
elif a == mi:
print(s3)
else:
print(s1)
| Statement
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is
at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan)
to travel from a point with coordinate a to another point with coordinate b
along the axis.
You planned a trip along the axis. In this plan, you first depart from the
point with coordinate 0, then visit the N spots in the order they are
numbered, and finally return to the point with coordinate 0.
However, something came up just before the trip, and you no longer have enough
time to visit all the N spots, so you decided to choose some i and cancel the
visit to Spot i. You will visit the remaining spots as planned in the order
they are numbered. You will also depart from and return to the point with
coordinate 0 at the beginning and the end, as planned.
For each i = 1, 2, ..., N, find the total cost of travel during the trip when
the visit to Spot i is canceled. | [{"input": "3\n 3 5 -1", "output": "12\n 8\n 10\n \n\nSpot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively.\nFor each i, the course of the trip and the total cost of travel when the visit\nto Spot i is canceled, are as follows:\n\n * For i = 1, the course of the trip is 0 \\rightarrow 5 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen.\n * For i = 2, the course of the trip is 0 \\rightarrow 3 \\rightarrow -1 \\rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen.\n * For i = 3, the course of the trip is 0 \\rightarrow 3 \\rightarrow 5 \\rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.\n\n* * *"}, {"input": "5\n 1 1 1 2 0", "output": "4\n 4\n 4\n 2\n 4\n \n\n* * *"}, {"input": "6\n -679 -2409 -3258 3095 -3291 -4462", "output": "21630\n 21630\n 19932\n 8924\n 21630\n 19288"}] |
Print the answer.
* * * | s554065254 | Accepted | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | import sys
readline = sys.stdin.readline
MOD = 10**9 + 7
N = int(readline())
A = list(map(int, readline().split()))
SA = [0] * N
SA[0] = A[0]
for i in range(1, N):
SA[i] = SA[i - 1] ^ A[i]
table = [int(sa == 0) for sa in SA]
for i in range(1, N):
table[i] += table[i - 1]
table.append(0)
cnt = 0
pre = [-1] * (1 << 20)
dp0 = [1] * (1 << 20)
dp = [0] * (1 << 20)
for i in range(N):
a = SA[i]
if a:
y = table[i] - table[pre[a]]
pre[a] = i
dp[a], dp0[a] = dp0[a] + (1 + y) * dp[a], dp0[a] + y * dp[a]
dp[a] %= MOD
dp0[a] %= MOD
else:
cnt += 1
if SA[-1]:
ans = dp0[SA[-1]]
else:
ans = pow(2, cnt - 1, MOD)
for t in dp:
ans = (ans + t) % MOD
print(ans)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s935460115 | Wrong Answer | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = int(input())
a = list(map(int, input().split(" ")))
mod = 10**9 + 7
allxor = 0
tmpxor = 0
idx = []
value = {}
for i in range(N):
allxor ^= a[i]
tmpxor ^= a[i]
if not tmpxor in value:
value[tmpxor] = 1
else:
value[tmpxor] += 2
if tmpxor == 0:
idx.append(i)
if allxor != 0:
cnt = 0
tmpxor = 0
for i in range(N):
tmpxor ^= a[i]
if tmpxor == allxor:
cnt += 1
tmpxor = 0
print(pow(2, cnt, mod))
exit(0)
l = len(idx)
ans = pow(2, l - 1, mod)
for key, value in value.items():
if key == 0:
continue
if value == 1:
ans += 1
else:
ans += (value % 3) * (pow(2, value // 3) - 1) + 1
print(ans)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s687513880 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = input()
lis = list(map(int, input().split))
print(N - lis[0 : N - 1])
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s193468562 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | #include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=5e5,MOD=1e9+7;
typedef pair<ll,ll> P;
ll N,A[MAX_N+1],psm[MAX_N+2],dp[MAX_N+1][2];
map<ll,vector<P> > mp;
map<ll,ll> lst;
ll mpw(ll n,ll m){
ll ret=1;
while(m){
if(m&1){
ret*=n;
ret%=MOD;
}
n*=n;
n%=MOD;
m>>=1;
}
return ret;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll ans=0;
cin>>N;
REP(i,N){
cin>>A[i+1];
A[i+1]^=A[i];
}
REP(i,N+1){
psm[i+1]=psm[i];
if(A[i]==0){
psm[i+1]++;
}
}
if(A[N]==0){
REP(i,N){
if(A[i]!=0){
if(psm[i]-psm[lst[A[i]]]>0){
mp[A[i]].push_back(P(0,psm[i]-psm[lst[A[i]]]));
lst[A[i]]=i;
}
mp[A[i]].push_back(P(A[i],1));
}
}
for(auto p:lst){
// cout<<p.first<<' '<<p.second<<endl;
}
for(auto &i:mp){
if(psm[N+1]-psm[lst[i.first]]>0){
i.second.push_back(P(0,psm[N+1]-psm[lst[i.first]]));
}
}
for(const auto &i:mp){
// cout<<i.first<<' '<<i.second.size()<<endl;
dp[0][0]=1;
dp[0][1]=0;
REP(j,i.second.size()){
//cout<<" "<<i.second[j].first<<','<<i.second[j].second<<endl;
}
FOR(j,1,i.second.size()){
REP(k,2)dp[j][k]=dp[j-1][k];
if(i.second[j].first==0){
dp[j][0]+=dp[j-1][1]*i.second[j].second;
dp[j][0]%=MOD;
}else{
dp[j][1]+=dp[j-1][0]*i.second[j].second;
dp[j][1]%=MOD;
}
}
ans+=dp[i.second.size()-2][1];
ans%=MOD;
}
// cout<<psm[N+1]<<endl;
ans+=mpw(2,psm[N+1]-2);
ans%=MOD;
}else{
ll x=A[N];
dp[0][0]=1;
FOR(i,1,N+1){
REP(j,2)dp[i][j]=dp[i-1][j];
if(A[i]==0){
dp[i][0]+=dp[i-1][1];
dp[i][0]%=MOD;
}else if (A[i]==x){
dp[i][1]+=dp[i-1][0];
dp[i][0]%=MOD;
}
}
ans=dp[N-1][0];
}
cout<<ans<<endl;
} | Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s512648956 | Wrong Answer | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | print(1)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s478426251 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = input()
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s457710814 | Accepted | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
data = [0]
for i in range(N):
data.append(data[-1] ^ A[i])
if data[-1] == 0:
ans = 0
zero = [int(data[i] == 0) for i in range(N + 1)]
for i in range(1, N + 1):
zero[i] += zero[i - 1]
val = {}
for i in range(N + 1):
if data[i] != 0:
if data[i] not in val:
val[data[i]] = []
val[data[i]].append(i)
for v in val:
B = 0
W = 1
for i in range(len(val[v])):
j = val[v][i]
if i != len(val[v]) - 1:
B += W
W += B * (zero[val[v][i + 1]] - zero[j])
B %= mod
W %= mod
else:
B += W
B %= mod
ans += B
ans %= mod
n = data.count(0)
ans += pow(2, n - 2, mod)
ans %= mod
print(ans)
else:
val = data[-1]
que = [0] * 2**20
dp = [0] * (N + 1)
dp[0] = 1
que[0] = 1
for i in range(1, N + 1):
j = data[i]
dp[i] = que[j ^ val]
que[data[i]] += dp[i]
que[data[i]] %= mod
print(dp[N] % mod)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s550456406 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | # 参考にしたもの
# 1.解説 累積XORのケツが0な場合はこっちのやり方に則った
# 2.シナモンロールさんのブログ(https://cinnamo-coder.hatenablog.com/entry/2019/05/12/172458)
def main():
import sys
input = sys.stdin.readline
mod = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]
# 累積XOR
cum_xor = [0]
for a in A:
cum_xor.append(cum_xor[-1] ^ a)
print(cum_xor)
if cum_xor[-1] != 0:
dp = [[0] * 2 for i in range(N + 1)]
# dp[i][0]:i番目まで見て、選んだやつらの最後が0の数
# dp[i][1]:i番目まで見て、選んだやつらの最後がXの数
# 累積XORの最後がX(!=0)なら 0X0X0X0Xになるように選ぶ( X XOR X = 0 だしね♡)
X = cum_xor[-1]
dp[0][0] = 1
for i in range(1, N + 1): # 最後の要素はどうせXなので回さなくても良い
dp[i][0] = dp[i - 1][0] % mod
dp[i][1] = dp[i - 1][1] % mod
if cum_xor[i] == 0:
dp[i][0] += dp[i - 1][1]
elif cum_xor[i] == X:
dp[i][1] += dp[i - 1][0]
# N-1番目までで、最後が0になってる選び方をして、それに最後の奴を加えるだけなのでdp[N-1][0]
print(dp[N - 1][0] % mod)
else:
# dp[X][j]:美しさをXとしたとき、最後に選んだのが(0 / X)
dp = [[1, 0] for i in range(N + 1)]
# cnt______[X]:美しさがXの選び方で、今まで出てきた0の数
cnt_zero_prev_cumXOR_i = [0] * (1 << 20)
cnt_zero_now = 0
for i in range(1, N + 1):
if cum_xor[i] == 0:
cnt_zero_now += 1
else:
# まず更新してなかった0の部分をまとめて更新
dp[cum_xor[i]][0] += dp[cum_xor[i]][1] * (
cnt_zero_now - cnt_zero_prev_cumXOR_i[cum_xor[i]]
)
dp[cum_xor[i]][0] %= mod
# そしたらいまの数(cum_xor[i])を取った場合の数を加えて更新
dp[cum_xor[i]][1] += dp[cum_xor[i]][0]
dp[cum_xor[i]][1] %= mod
# 0の数の更新
cnt_zero_prev_cumXOR_i[cum_xor[i]] = cnt_zero_now
ans = 0
for c in set(cum_xor):
ans += dp[c][1]
ans %= mod
ans += 2 ** (cnt_zero_now - 1)
print(ans % mod)
if __name__ == "__main__":
main()
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s414389038 | Accepted | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = int(input())
A = [int(a) for a in input().split()]
P = 10**9 + 7
X = [1] * (1 << 20) # 0
Y = [0] * (1 << 20) # 1
Z = [0] * (1 << 20) # Cnt of Zeros at Last update
Z[0] = 1
X[0] = (P + 1) // 2
s = 0
for i in range(N):
s ^= A[i]
if s == 0:
X[0] = (X[0] * 2) % P
Z[0] += 1
else:
X[s] = (X[s] + Y[s] * (Z[0] - Z[s])) % P
Y[s] = (X[s] + Y[s]) % P
Z[s] = Z[0]
print((X[s] + sum(Y) * (s == 0)) % P)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s086328675 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | def cul(n):
memo[1] = 1
memo[2] = 1
memo[3] = 2
if memo[n] == -1:
t = 1
for i in range(1, N):
t += cul(N - i)
memo[n] = t
return memo[n]
import math
import sys
MOD = 10**9 + 7
N = int(input())
memo = [-1] * (N + 3)
tmp = 0
l = [-1]
a = list(map(int, input().split()))
b = []
x = []
for i in range(N):
tmp = tmp ^ a[i]
x.append(tmp)
if tmp == 0:
b.append([x[i] for i in range(len(x))])
x = []
if x != []:
b.append([x[i] for i in range(len(x))])
M = tmp
if tmp != 0:
tmp = 0
s = 0
for i in range(N):
tmp = tmp ^ a[i]
if tmp == M:
s += 1
print(cul(s))
sys.exit()
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s553541563 | Wrong Answer | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | import sys
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return input()
from collections import Counter
def main():
N = II()
A = LI()
acc = []
tmp = 0
for a in A:
tmp = tmp ^ a
acc.append(tmp)
cnts = []
cnt0 = Counter()
for x in acc:
cnt0[x] += 1
if x == 0:
cnts.append(cnt0)
cnt0 = Counter()
se = set([x]) if x != 0 else set(acc)
ans = 0
for k in se:
if k == 0:
ans = (ans + (2 ** (len(cnts) - 1))) % MOD
continue
tmp = 1
for cnt in cnts:
tmp = (tmp * (cnt[k] + 1)) % MOD
ans = (ans + tmp) % MOD
ans = (ans - len(se) + 1) % MOD
return ans
print(main())
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s278216373 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | from collections import defaultdict
N = int(input())
A = [int(x) for x in input().split()]
p = 10**9 + 7
B = [[0 for j in range(20)] for i in range(N + 1)]
D = defaultdict(list)
D[0].append(0)
for i in range(N):
a = A[i]
b = 0
for j in range(20):
B[i + 1][j] = B[i][j]
B[i + 1][j] += a % 2
B[i + 1][j] %= 2
b += B[i + 1][j] * 2**j
a //= 2
D[b].append(i + 1)
cnt = 0
def zig(A, Z):
As, Ar, Zs, Zr = 0, 0, 0, 0
i, j = len(A) - 1, len(Z) - 1
if A[-1] > Z[-1]:
while A[i] > Z[-1]:
i -= 1
Zr = 1
else:
while Z[j] > A[-1]:
j -= 1
Ar = 1
while i > 0 and j > 0:
if Ar:
j -= 1
while A[i] > Z[j]:
As + -Ar
i -= 1
if i == 0:
break
Zr = As % p
As, Ar = 0, 0
else:
i -= 1
while Z[j] > A[i]:
Zs += Zr
j -= 1
if j == 0:
break
Ar = Zs % p
Zs = 0
return Zr
if b != 0:
cnt += zig(D[b], D[0])
else:
for k in D.keys():
if k:
cnt += zig(D[k], D[0]) + 1
else:
cnt += 2 ** (len(D[0]) - 2) % p
print(cnt % p)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s239194553 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | def xor(a, b):
x = 0
i = 1
while a != 0 or b != 0:
an = a % 2
bn = b % 2
if an != bn:
x += i
a //= 2
b //= 2
i *= 2
return x
N = int(input())
a = list(map(int, input().split()))
MOD = 1e9 + 7
L = [0] * N
L[0] = a[0]
Z = [0] * (N + 1)
Z[1] = 1
for i in range(1, N):
Z[i + 1] = int(Z[i] * 2 % MOD)
for i in range(1, N):
L[i] = xor(L[i - 1], a[i])
D = [0] * N
if L[0] == 0:
D[0] = 1
for i in range(1, N):
D[i] = D[i - 1]
if L[i] == 0:
D[i] += 1
if L[-1] == 0:
Ans = Z[D[-1]]
R = {}
for i in range(N - 1):
t = L[i]
if t != 0:
if t not in R:
R[t] = [[1, i]]
else:
k = R[t][-1][1]
if D[k] == D[i]:
R[t][-1][0] += 1
else:
R[t].append([D[i] - D[k], -1])
R[t].append([1, i])
print(Ans)
for i in R.values():
t = i
t.append([D[-1] - D[i[-1][1]], -1])
k = 1
for j in range(0, len(t), 2):
k *= t[j][0] * t[j + 1][0]
Ans += k - 1
print(Ans)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s547054404 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | N = int(input())
A = [int(i) for i in input().split()]
B = [A[0]]
mod = 10**9 + 7
for i in range(1, N):
B.append(B[-1] ^ A[i])
# print(B)
if B[-1]:
table = []
for i in range(N):
if B[i] == B[-1]:
if table:
if table[-1][0] == 1:
table[-1] = (1, table[-1][1] + 1)
else:
table.append((1, 1))
else:
table.append((1, 1))
elif B[i] == 0:
if table:
if table[-1][0] == 0:
table[-1] = (0, table[-1][1] + 1)
else:
table.append((0, 1))
else:
table.append((0, 1))
l = len(table)
dp = [[0] * 2 for i in range(l + 1)]
dp[0][0] = 1
for i in range(l):
if table[i][0] == 1:
dp[i + 1][0] = dp[i][0]
dp[i + 1][1] = (dp[i][1] + dp[i][0] * table[i][1]) % mod
else:
dp[i + 1][1] = dp[i][1]
dp[i + 1][0] = (dp[i][0] + dp[i][1] * table[i][1]) % mod
# print(dp)
# print(table)
print(dp[l - 1][0])
else:
table = [[] for i in range(2**20)]
s = set()
ans = 1 / 2
for i in range(N):
if B[i] != 0:
s.add(B[i])
if table[B[i]]:
if table[B[i]][-1][0] == 1:
table[B[i]][-1] = (1, table[B[i]][-1][1] + 1)
else:
table[B[i]].append((1, 1))
else:
table[B[i]].append((1, 1))
elif B[i] == 0:
ans *= 2
for k in s:
if table[k]:
if table[k][-1][0] == 0:
table[k][-1] = (0, table[k][-1][1] + 1)
else:
table[k].append((0, 1))
else:
table[k].append((0, 1))
ans = int(ans)
for k in s:
l = len(table[k])
dp = [[0] * 2 for i in range(l + 1)]
dp[0][0] = 1
for i in range(l):
if table[k][i][0] == 1:
dp[i + 1][0] = dp[i][0]
dp[i + 1][1] = (dp[i][1] + dp[i][0] * table[k][i][1]) % mod
else:
dp[i + 1][1] = dp[i][1]
dp[i + 1][0] = (dp[i][0] + dp[i][1] * table[k][i][1]) % mod
ans = (ans + dp[l - 1][1]) % mod
# print(table)
print(ans % mod)
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
Print the answer.
* * * | s621277987 | Runtime Error | p03051 | Input is given from Standard Input in the following format:
N
A_1 A_2 \ldots A_{N} | #!/usr/bin/env python3
import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd
import numpy as np
# import scipy, scipy.special
# from sympy import isprime, nextprime
# from sympy.ntheory import factorint
# from sympy import divisors
inf = float("inf")
def lcm(a, b):
return a * b // gcd(a, b)
def perm(a, b):
import scipy.special
return scipy.special.perm(a, b, exact=True)
def comb(a, b):
import scipy.special
return scipy.special.comb(a, b, exact=True)
def dfact(n):
import scipy.special
return scipy.special.factorial2(n, exact=True)
def prod(l):
return reduce(operator.mul, l)
def input_ints(inp=input, sep=" ", conv=int):
return map(conv, inp().split(sep=sep))
################################################################################
N = int(input())
A = list(input_ints())
dp = np.empty((N))
def func(N, A, up_prod, i_start):
if i_start == N:
return 1
if dp[i_start] >= 0:
return dp[i_start]
prod = 0
cnt = 0
for i in range(i_start, N):
prod ^= A[i]
if prod == up_prod:
cnt += func(N, A, up_prod, i + 1)
dp[i_start] = cnt
return cnt
prod = 0
cnt = 0
for i in range(0, N):
dp.fill(-1)
prod ^= A[i]
cnt += func(N, A, prod, i + 1)
print(int(cnt % (1e9 + 7)))
| Statement
The _beauty_ of a sequence a of length n is defined as a_1 \oplus \cdots
\oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).
You are given a sequence A of length N. Snuke will insert zero or more
partitions in A to divide it into some number of non-empty contiguous
subsequences.
There are 2^{N-1} possible ways to insert partitions. How many of them divide
A into sequences whose beauties are all equal? Find this count modulo
10^{9}+7. | [{"input": "3\n 1 2 3", "output": "3\n \n\nFour ways of dividing A shown below satisfy the condition. The condition is\nnot satisfied only if A is divided into (1),(2),(3).\n\n * (1,2,3)\n * (1),(2,3)\n * (1,2),(3)\n\n* * *"}, {"input": "3\n 1 2 2", "output": "1\n \n\n* * *"}, {"input": "32\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "output": "147483634\n \n\nFind the count modulo 10^{9}+7.\n\n* * *"}, {"input": "24\n 1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2", "output": "292"}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s044035066 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | def main():
N = int(input())
for i range(26):
if i * 4 > N:
break
if (N - i * 4) % 7 == 0:
print('Yes')
return
print('No')
if __name__ == '__main__':
main()
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s760234606 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | N = int(input())
flag = False
for i in range(0,30):
for j in range(0,30):
if i * 4 + j * 7 == N:
flag = True
if flag == True:
print('Yes')
else:
print('No') | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s410150880 | Accepted | p03285 | Input is given from Standard Input in the following format:
N | import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
MOD = 10**9 + 7
MAX = float("inf")
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
N = ii()
A = N // 4 + 1
B = N // 7 + 1
for a in range(A):
for b in range(B):
if a * 4 + b * 7 == N:
print("Yes")
exit()
else:
print("No")
if __name__ == "__main__":
main()
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s154218407 | Accepted | p03285 | Input is given from Standard Input in the following format:
N | ###############################################################################
from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
mod = 1
def intin():
input_tuple = input().split()
if len(input_tuple) <= 1:
return int(input_tuple[0])
return tuple(map(int, input_tuple))
def intina():
return [int(i) for i in input().split()]
def intinl(count):
return [intin() for _ in range(count)]
def modadd(x, y):
global mod
return (x + y) % mod
def modmlt(x, y):
global mod
return (x * y) % mod
def lcm(x, y):
while y != 0:
z = x % y
x = y
y = z
return x
def combination(x, y):
assert x >= y
if y > x // 2:
y = x - y
ret = 1
for i in range(0, y):
j = x - i
i = i + 1
ret = ret * j
ret = ret // i
return ret
def get_divisors(x):
retlist = []
for i in range(1, int(x**0.5) + 3):
if x % i == 0:
retlist.append(i)
retlist.append(x // i)
return retlist
def get_factors(x):
retlist = []
for i in range(2, int(x**0.5) + 3):
while x % i == 0:
retlist.append(i)
x = x // i
retlist.append(x)
return retlist
def make_linklist(xylist):
linklist = {}
for a, b in xylist:
linklist.setdefault(a, [])
linklist.setdefault(b, [])
linklist[a].append(b)
linklist[b].append(a)
return linklist
def calc_longest_distance(linklist, v=1):
distance_list = {}
distance_count = 0
distance = 0
vlist_previous = []
vlist = [v]
nodecount = len(linklist)
while distance_count < nodecount:
vlist_next = []
for v in vlist:
distance_list[v] = distance
distance_count += 1
vlist_next.extend(linklist[v])
distance += 1
vlist_to_del = vlist_previous
vlist_previous = vlist
vlist = list(set(vlist_next) - set(vlist_to_del))
max_distance = -1
max_v = None
for v, distance in distance_list.items():
if distance > max_distance:
max_distance = distance
max_v = v
return (max_distance, max_v)
def calc_tree_diameter(linklist, v=1):
_, u = calc_longest_distance(linklist, v)
distance, _ = calc_longest_distance(linklist, u)
return distance
###############################################################################
def main():
n = intin()
for i in range(20):
diff = n - 7 * i
if diff >= 0 and diff % 4 == 0:
print("Yes")
return
print("No")
if __name__ == "__main__":
main()
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s072186164 | Accepted | p03285 | Input is given from Standard Input in the following format:
N | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from functools import *
from itertools import permutations, combinations, groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
(*a,) = map(int, open(0))
def S_():
return input()
def IS():
return input().split()
def LS():
return [i for i in input().split()]
def I():
return int(input())
def MI():
return map(int, input().split())
def LI():
return [int(i) for i in input().split()]
def LI_():
return [int(i) - 1 for i in input().split()]
def NI(n):
return [int(input()) for i in range(n)]
def NI_(n):
return [int(input()) - 1 for i in range(n)]
def StoI():
return [ord(i) - 97 for i in input()]
def ItoS(nn):
return chr(nn + 97)
def LtoS(ls):
return "".join([chr(i + 97) for i in ls])
def GI(V, E, Directed=False, index=0):
org_inp = []
g = [[] for i in range(n)]
for i in range(E):
inp = LI()
org_inp.append(inp)
if index == 0:
inp[0] -= 1
inp[1] -= 1
if len(inp) == 2:
a, b = inp
g[a].append(b)
if not Directed:
g[b].append(a)
elif len(inp) == 3:
a, b, c = inp
aa = (inp[0], inp[2])
bb = (inp[1], inp[2])
g[a].append(bb)
if not Directed:
g[b].append(aa)
return g, org_inp
def GGI(h, w, search=None, replacement_of_found=".", mp_def={"#": 1, ".": 0}):
# h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
mp = [1] * (w + 2)
found = {}
for i in range(h):
s = input()
for char in search:
if char in s:
found[char] = (i + 1) * (w + 2) + s.index(char) + 1
mp_def[char] = mp_def[replacement_of_found]
mp += [1] + [mp_def[j] for j in s] + [1]
mp += [1] * (w + 2)
return h + 2, w + 2, mp, found
def bit_combination(k, n=2):
rt = []
for tb in range(n**k):
s = [tb // (n**bt) % n for bt in range(k)]
rt += [s]
return rt
def show(*inp, end="\n"):
if show_flg:
print(*inp, end=end)
YN = ["YES", "NO"]
mo = 10**9 + 7
inf = float("inf")
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().rstrip()
def ran_input():
import random
n = random.randint(4, 16)
rmin, rmax = 1, 10
a = [random.randint(rmin, rmax) for _ in range(n)]
return n, a
show_flg = False
show_flg = True
n = I()
t = [0] * 102
for i in range(100):
for j in range(100):
t[min(101, 4 * i + 7 * j)] = 1
print(["No", "Yes"][t[n]])
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s930940926 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | n = int(input())
for f in range(100//4+1):
for s in range(100//7+1):
ans = f*4 + s*7
if ans == n:
print("Yes")
exit()
print("No") | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s150597558 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | n=int(input())
a=0
for i in range(0,26):
for j in range(0,20):
if 4*i+7*j==n:
a+=1
if a==0:
print("N0")
else:
print("Yes")
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s441954620 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | import sys
N=int(input())
for i range(101):
for j in range(101):
if 4*i + 7*j == N:
print('Yes')
sys.exit()
else:
print('No') | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s063967063 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | N = int(input())
for i in range(N // 4 + 1):
for j in range(N // 7 + 1):
if 4 * i + 7 * j == N:
print("Yes")
quit()
else:
pass
print("No") | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s508025109 | Accepted | p03285 | Input is given from Standard Input in the following format:
N | n = int(input())
money = [4 * i + 7 * j for i in range(n // 4 + 1) for j in range(n // 7 + 1)]
print("Yes" if n in money else "No")
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s608526073 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | n = int(input())
print("Yes" if any((n - i*7) % 4 == 0 for i in range(n // 7 + 1) else "No") | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s439281386 | Wrong Answer | p03285 | Input is given from Standard Input in the following format:
N | print("YNeos"[int(input()) in [1, 2, 3, 5, 6, 0, 10, 13, 17] :: 2])
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s310812865 | Wrong Answer | p03285 | Input is given from Standard Input in the following format:
N | print("YNeos"[int(input()) not in [1, 2, 3, 5, 6, 9, 10, 13, 17] :: 2])
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s633057387 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | print("Yes" if [4 * x + 11 * y for x in range(26) for y in range(9)].count(a) else "NO")
| Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
If there is a way to buy some cakes and some doughnuts for exactly N dollars,
print `Yes`; otherwise, print `No`.
* * * | s276943200 | Runtime Error | p03285 | Input is given from Standard Input in the following format:
N | n = int(input())
if n % 4 == 0 or n % 7 == 0
print('Yes')
elif (n % 7) % 4 == 0:
print('Yes')
else:
print('No') | Statement
_La Confiserie d'ABC_ sells cakes at 4 dollars each and doughnuts at 7
dollars each. Determine if there is a way to buy some of them for exactly N
dollars. You can buy two or more doughnuts and two or more cakes, and you can
also choose to buy zero doughnuts or zero cakes. | [{"input": "11", "output": "Yes\n \n\nIf you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.\n\n* * *"}, {"input": "40", "output": "Yes\n \n\nIf you buy ten cakes, the total will be 4 \\times 10 = 40 dollars.\n\n* * *"}, {"input": "3", "output": "No\n \n\nThe prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than\n3 dollars, so there is no such way."}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.