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 string displayed in the editor in the end.
* * * | s650832255 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | lst=[]
res=[]
a=input()
for i in range(len(a)):
lst.append(a[i])
if lst[i] == "0":
res.append(lst[i])
elif lst[i] == "1":
res.append(lst[i])
else:
if res == [] or res[0] == "" :
else:
res.remove(lst[len(res)-1])
print("".join(res)) | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s609142354 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
__MOD__ = (10**9) + 7
yn = "YNeos"
judge = False
cnt = 0
ans = None
def lcm(a, b):
return (a * b) // gcd(a, b)
def intinput():
return int(input())
def mulinputs():
return map(int, input().split())
def lineinputs(func=intinput):
datas = []
while True:
try:
datas.append(func())
except EOFError:
break
return datas
class ModInt:
def __init__(self, x):
self.__x = x % __MOD__
def __add__(self, other):
if type(other) == int:
other = self.__class__(other)
return int(self.__class__((self.__x + other.__x) % __MOD__))
elif type(other) == ModInt:
return self.__class__((self.__x + other.__x) % __MOD__)
else:
raise Exception("Not Int or Not ModInt")
def __sub__(self, other):
if type(other) == int:
other = self.__class__(other)
return int(self.__class__((self.__x - other.__x) % __MOD__))
elif type(other) == ModInt:
return self.__class__((self.__x - other.__x) % __MOD__)
else:
raise Exception("Not Int or Not ModInt")
def __mul__(self, other):
if type(other) == int:
other = self.__class__(other)
return int(self.__class__((self.__x * other.__x) % __MOD__))
elif type(other) == ModInt:
return self.__class__((self.__x * other.__x) % __MOD__)
else:
raise Exception("Not Int or Not ModInt")
def __truediv__(self, other):
if type(other) == int:
other = self.__class__(other)
return int(self.__class__((self.__x * other.__modinv()) % __MOD__))
elif type(other) == ModInt:
return self.__class__((self.__x * other.__modinv()) % __MOD__)
else:
raise Exception("Not Int or Not ModInt")
def __pow__(self, other):
if type(other) == int:
other = self.__class__(other)
return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
elif type(other) == ModInt:
return self.__class__(pow(self.__x, other.__x, __MOD__))
else:
raise Exception("Not Int or Not ModInt")
def __modinv(self, m=__MOD__):
a = self.__x
if a == 0:
raise ZeroDivisionError()
if gcd(a, m) != 1:
raise Exception("%sの逆数は求まりません。" % a)
b, u, v = m, 1, 0
while b != 0:
t = a // b
a -= t * b
a, b = b, a
u -= t * v
u, v = v, u
u %= m
if u < 0:
u += m
return u
def __int__(self):
return self.__x
if __name__ == "__main__":
S = input()
ret, i = "", 0
while i < len(S):
if S[i] == "B":
if i == 0:
ret = ""
else:
ret = ret[:-2]
else:
ret += S[i]
i += 1
# 出力
print(ret)
# EOF
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s652963973 | Accepted | p04030 | The input is given from Standard Input in the following format:
s | S = input()
I = []
for TS in S:
if TS == "0":
I.append("0")
elif TS == "1":
I.append("1")
elif TS == "B" and len(I) >= 1:
del I[-1]
print("".join(I))
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s463805708 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | a=input()
b=""
for i in range(len(a)):
if a[i]=="0":
b=b+"0"
if a[i]=="1":
b=b+"1"
if a[i]=="B":
if a[i]!="":
restrip(a)
else:
print(a)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s165556509 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | A = input()
AA = list(A)
for i in AA:
if i = "B":
AA.remove(AA[-1])
elif i = "0":
AA.appened('0')
elif i = "1":
AA.appened('1')
A = ''.join(AA)
print(A)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s533296891 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | print(input().replace("B", "\b"))
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s738179922 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s =input()
ary = []
for c in s:
if c == 'B':
if len(ary) > 0:
ary.pop()
else:
ary.append(c)
print(''join(ary)) | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s722685263 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | #! /usr/bin/python3
# バイナリハックイージー / Unhappy Hacking (ABC Edit)
"""
1. 先頭のB全部を消す
2.
"""
import re
test_mode = True
flag = False
s = str(input())
for _ in range(10):
while s[0] == "B":
s = s[1:]
if test_mode is True:
print(s)
s = re.sub("0B|1B", "", s)
if "B" not in s:
print(s)
break
"""
参考
Pythonで文字列の最初・最後の1文字(数文字)を削除する
https://robotics4society.com/2017/06/29/python_mojisakujo/
"""
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s363034738 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | string = input()
result = []
j=0
for i in range(len(string)):
if string[i]=='0':
result.append('0')
elif string[i]=='1':
result.append('1')
elif string[i]=='B' and len(result)>1 and result[-1] in ['0','1']
result[-1]=""
str_result="".join(result)
print(str_result)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s567835908 | Accepted | p04030 | The input is given from Standard Input in the following format:
s | lst = ""
i = list(input())
for j in i:
if j == "0" or j == "1":
lst += j
elif j == "B" and lst != []:
lst = lst[:-1]
print(lst)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s966172246 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s = input()
counter = 0
moji = ""
for i in s:
if i == "B":
moji[:-1]
continue
else:
moji+ i | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s276170248 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | print("1B" in "01B")
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s496970838 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | res = ''
for x in input():
if x = 'B':
res = res[:-1]
else:
res += x
print(res)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s748567802 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s = input()
out = ``
for w in s:
if w == '1' or w == '0':
out += w
elif len(out) > 0:
out = out[:-1]
print(out)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s203694323 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s = str(input())
ans = ""
n = len(s)
for i in range(n)
if s[i] = "B":
if ans == "":
ans = ans + ""
else:
ans = ans[:-1]
else:
ans = ans + s[i] | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s894842279 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | a=list(input())
x=[]
for ai in a:
if x !=[] and ai="B":
l=len(x)
del x[l-1]
elif ai in ["0","1"]:
x.append(ai)
print("".join(x))
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s694880959 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | list = input().split()
l = len(list)
output = ""
for i in l:
if list[i] == "0" or "1":
output = output + list[i]
else:
if i != 0:
output = output - list[i - 1]
print(output)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s716370003 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | print(input().replace("1B", "").replace("0B", "").replace("B", ""))
# print(*[s[q] if s[q] != "B" else chr(0x08) for q in range(len(s))], sep="")
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s323283854 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s = input()
ans = ""
for i in s
if i == "B":
if len(ans) > 0:
ans = ans[:-1]
else:
ans = ans
else:
ans = ans + c
print(ans) | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s693353613 | Accepted | p04030 | The input is given from Standard Input in the following format:
s | icase = 0
if icase == 0:
s = list(input())
p = ""
for i in range(len(s)):
if s[i] == "0":
p = p + "0"
elif s[i] == "1":
p = p + "1"
elif s[i] == "B":
if p != "":
p = p[0 : len(p) - 1]
print(p)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s835342510 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s=input()
ans=[]
for c in s:
if c=="0" or c=="1":
ans.append(c)
else:
ans.pop(-1)
print("".join(ans))s=input()
ans=[]
for c in s:
if c=="0" or c=="1":
ans.append(c)
else:
if len(ans)>0:
ans.pop(-1)
print("".join(ans)) | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s760066918 | Wrong Answer | p04030 | The input is given from Standard Input in the following format:
s | N = list(input().strip())
a = len(N)
count = []
counter = 0
for n, i in zip(N, range(a)):
if n != "B":
count.append(int(n))
else:
if len(count) == 0:
break
else:
del count[len(count) - 1]
p = "".join(map(str, count))
print(p)
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s869899455 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | inputs = list(map(str, input()))
output = ''
for i in inputs:
if output == 'B':
output = output[:-1]
elif output == '1':
output += '1'
else:
output += '0'
print(output) | Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the string displayed in the editor in the end.
* * * | s063841284 | Runtime Error | p04030 | The input is given from Standard Input in the following format:
s | s = list(input())
try
bs = s.index('B')
except:
bs=-1
while bs != -1:
if bs == 0:
del s[bs]
else:
del s[bs-1]
del s[bs-1]
try:
bs = s.index('B')
except:
bs = -1
print(''.join(s))
| Statement
Sig has built his own keyboard. Designed for ultimate simplicity, this
keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace
key.
To begin with, he is using a plain text editor with this keyboard. This editor
always displays one string (possibly empty). Just after the editor is
launched, this string is empty. When each key on the keyboard is pressed, the
following changes occur to the string:
* The `0` key: a letter `0` will be inserted to the right of the string.
* The `1` key: a letter `1` will be inserted to the right of the string.
* The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are
given a string s, which is a record of his keystrokes in order. In this
string, the letter `0` stands for the `0` key, the letter `1` stands for the
`1` key and the letter `B` stands for the backspace key. What string is
displayed in the editor now? | [{"input": "01B0", "output": "00\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `01`, `0`, `00`.\n\n* * *"}, {"input": "0BB1", "output": "1\n \n\nEach time the key is pressed, the string in the editor will change as follows:\n`0`, `(empty)`, `(empty)`, `1`."}] |
Print the maximum possible total weight of an independent set in W, modulo
998,244,353.
* * * | s605633315 | Accepted | p02737 | Input is given from Standard Input in the following format:
N
M_1
a_1 b_1
a_2 b_2
\vdots
a_{M_1} b_{M_1}
M_2
c_1 d_1
c_2 d_2
\vdots
c_{M_2} d_{M_2}
M_3
e_1 f_1
e_2 f_2
\vdots
e_{M_3} f_{M_3} | import sys
input = sys.stdin.readline
mod = 998244353
N = int(input())
M1 = int(input())
E1 = [[] for i in range(N + 1)]
for i in range(M1):
x, y = map(int, input().split())
E1[x].append(y)
E1[y].append(x)
M2 = int(input())
E2 = [[] for i in range(N + 1)]
for i in range(M2):
x, y = map(int, input().split())
E2[x].append(y)
E2[y].append(x)
M3 = int(input())
E3 = [[] for i in range(N + 1)]
for i in range(M3):
x, y = map(int, input().split())
E3[x].append(y)
E3[y].append(x)
G1 = [-1] * (N + 1)
G1[N] = 0
for i in range(N - 1, -1, -1):
GS = set()
for to in E1[i]:
GS.add(G1[to])
for j in range(N + 1):
if j in GS:
continue
else:
G1[i] = j
break
G2 = [-1] * (N + 1)
G2[N] = 0
for i in range(N - 1, -1, -1):
GS = set()
for to in E2[i]:
GS.add(G2[to])
for j in range(N + 1):
if j in GS:
continue
else:
G2[i] = j
break
G3 = [-1] * (N + 1)
G3[N] = 0
for i in range(N - 1, -1, -1):
GS = set()
for to in E3[i]:
GS.add(G3[to])
for j in range(N + 1):
if j in GS:
continue
else:
G3[i] = j
break
from collections import Counter
C1 = Counter()
C2 = Counter()
C3 = Counter()
for i in range(1, N + 1):
C1[G1[i]] = (C1[G1[i]] + pow(10, 18 * i, mod)) % mod
C2[G2[i]] = (C2[G2[i]] + pow(10, 18 * i, mod)) % mod
C3[G3[i]] = (C3[G3[i]] + pow(10, 18 * i, mod)) % mod
C12 = Counter()
for c1 in C1:
for c2 in C2:
C12[c1 ^ c2] = (C12[c1 ^ c2] + C1[c1] * C2[c2]) % mod
ANS = 0
for c3 in C3:
ANS = (ANS + C3[c3] * C12[c3]) % mod
print(ANS)
| Statement
Given are simple undirected graphs X, Y, Z, with N vertices each and M_1, M_2,
M_3 edges, respectively. The vertices in X, Y, Z are respectively called x_1,
x_2, \dots, x_N, y_1, y_2, \dots, y_N, z_1, z_2, \dots, z_N. The edges in X,
Y, Z are respectively (x_{a_i}, x_{b_i}), (y_{c_i}, y_{d_i}), (z_{e_i},
z_{f_i}).
Based on X, Y, Z, we will build another undirected graph W with N^3 vertices.
There are N^3 ways to choose a vertex from each of the graphs X, Y, Z. Each of
these choices corresponds to the vertices in W one-to-one. Let (x_i, y_j, z_k)
denote the vertex in W corresponding to the choice of x_i, y_j, z_k.
We will span edges in W as follows:
* For each edge (x_u, x_v) in X and each w, l, span an edge between (x_u, y_w, z_l) and (x_v, y_w, z_l).
* For each edge (y_u, y_v) in Y and each w, l, span an edge between (x_w, y_u, z_l) and (x_w, y_v, z_l).
* For each edge (z_u, z_v) in Z and each w, l, span an edge between (x_w, y_l, z_u) and (x_w, y_l, z_v).
Then, let the weight of the vertex (x_i, y_j, z_k) in W be
1,000,000,000,000,000,000^{(i +j + k)} = 10^{18(i + j + k)}. Find the maximum
possible total weight of the vertices in an independent set in W, and print
that total weight modulo 998,244,353. | [{"input": "2\n 1\n 1 2\n 1\n 1 2\n 1\n 1 2", "output": "46494701\n \n\nThe maximum possible total weight of an independent set is that of the set\n(x_2, y_1, z_1), (x_1, y_2, z_1), (x_1, y_1, z_2), (x_2, y_2, z_2). The output\nshould be (3 \\times 10^{72} + 10^{108}) modulo 998,244,353, which is\n46,494,701.\n\n* * *"}, {"input": "3\n 3\n 1 3\n 1 2\n 3 2\n 2\n 2 1\n 2 3\n 1\n 2 1", "output": "883188316\n \n\n* * *"}, {"input": "100000\n 1\n 1 2\n 1\n 99999 100000\n 1\n 1 100000", "output": "318525248"}] |
A list of _bridges_ of the graph ordered by name. For each bridge, names of
its end-ponints, source and target (source < target), should be printed
separated by a space. The sources should be printed ascending order, then the
target should also be printed ascending order for the same source. | s328347140 | Accepted | p02367 | |V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
, where |V| is the number of nodes and |E| is the number of edges in the
graph. The graph nodes are named with the numbers 0, 1,..., |V|-1
respectively.
si and ti represent source and target nodes of i-th edge (undirected). | import sys
sys.setrecursionlimit(10**6)
V, E = list(map(int, input().split()))
G = [[] for i in range(V)]
for i in range(E):
s, t = list(map(int, input().split()))
G[s].append(t)
G[t].append(s)
class LowLink:
def main(G, V):
LowLink.G = G
LowLink.used = [False] * V
LowLink.ord = [0] * V
LowLink.low = [0] * V
LowLink.aps = []
LowLink.bridges = []
n = 0
for i in range(V):
if not LowLink.used[i]:
n = LowLink.dfs(i, n, -1)
LowLink.aps.sort()
LowLink.bridges.sort()
def dfs(v, n, par):
LowLink.used[v] = True
LowLink.ord[v] = n + 1
n += 1
LowLink.low[v] = LowLink.ord[v]
is_aps = False
chi = 0
for u in LowLink.G[v]:
if not LowLink.used[u]:
chi += 1
n = LowLink.dfs(u, n, v)
LowLink.low[v] = min(LowLink.low[v], LowLink.low[u])
if par != -1 and LowLink.ord[v] <= LowLink.low[u]:
is_aps = True
if LowLink.ord[v] < LowLink.low[u]:
LowLink.bridges.append((min(v, u), max(v, u)))
elif u != par:
LowLink.low[v] = min(LowLink.low[v], LowLink.ord[u])
if par == -1 and chi >= 2:
is_aps = True
if is_aps:
LowLink.aps.append(v)
return n
LowLink.main(G, V)
for v in LowLink.bridges:
print(*v)
| Bridges
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the
number of connected components. | [{"input": "4 4\n 0 1\n 0 2\n 1 2\n 2 3", "output": "2 3"}, {"input": "5 4\n 0 1\n 1 2\n 2 3\n 3 4", "output": "0 1\n 1 2\n 2 3\n 3 4"}] |
A list of _bridges_ of the graph ordered by name. For each bridge, names of
its end-ponints, source and target (source < target), should be printed
separated by a space. The sources should be printed ascending order, then the
target should also be printed ascending order for the same source. | s729613308 | Accepted | p02367 | |V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
, where |V| is the number of nodes and |E| is the number of edges in the
graph. The graph nodes are named with the numbers 0, 1,..., |V|-1
respectively.
si and ti represent source and target nodes of i-th edge (undirected). | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
5 4
0 1
1 2
2 3
3 4
output:
0 1
1 2
2 3
3 4
"""
import sys
sys.setrecursionlimit(int(1e5))
def dfs_Tarjan(current, visited, parent, low, disc):
global timer
children = 0
visited[current] = True
disc[current] = timer
low[current] = timer
timer += 1
for adj in adj_table[current]:
if not visited[adj]:
parent[adj] = current
children += 1
dfs_Tarjan(adj, visited, parent, low, disc)
low[current] = min(low[current], low[adj])
if low[adj] > disc[current]:
ans.append(sorted([current, adj]))
elif adj != parent[current]:
low[current] = min(low[current], disc[adj])
return None
def dfs_init():
visited = [False] * v_num
disc = [float("Inf")] * v_num
low = [float("Inf")] * v_num
parent = [-1] * v_num
for v in range(v_num):
if not visited[v]:
dfs_Tarjan(v, visited, parent, low, disc)
return ans
if __name__ == "__main__":
_input = sys.stdin.readlines()
v_num, e_num = map(int, _input[0].split())
edges = map(lambda x: x.split(), _input[1:])
adj_table = tuple([] for _ in range(v_num))
for v_info in edges:
source, target = map(int, v_info)
adj_table[source].append(target)
adj_table[target].append(source)
timer = 0
ans = list()
dfs_init()
ans.sort()
for ele in ans:
print(*ele)
| Bridges
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the
number of connected components. | [{"input": "4 4\n 0 1\n 0 2\n 1 2\n 2 3", "output": "2 3"}, {"input": "5 4\n 0 1\n 1 2\n 2 3\n 3 4", "output": "0 1\n 1 2\n 2 3\n 3 4"}] |
A list of _bridges_ of the graph ordered by name. For each bridge, names of
its end-ponints, source and target (source < target), should be printed
separated by a space. The sources should be printed ascending order, then the
target should also be printed ascending order for the same source. | s786636674 | Wrong Answer | p02367 | |V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
, where |V| is the number of nodes and |E| is the number of edges in the
graph. The graph nodes are named with the numbers 0, 1,..., |V|-1
respectively.
si and ti represent source and target nodes of i-th edge (undirected). | from sys import stdin
readline = stdin.readline
from sys import stdin
readline = stdin.readline
def main():
v, e = map(int, readline().split())
from collections import defaultdict
g = defaultdict(list)
for _ in range(e):
s, t = map(int, readline().split())
g[s].append(t)
g[t].append(s)
visited = set()
lowest = [None] * v
parent = [None] * v
prenum = [None] * v
child = defaultdict(list)
root = 0
# dfs??§tree?????????
stack = [(root, None)]
while stack:
u, prev = stack.pop()
if u not in visited:
parent[u] = prev
if prev is not None:
child[prev].append(u)
visited |= {u}
prenum[u] = lowest[u] = len(visited)
stack.extend([(v, u) for v in g[u] if v not in visited])
# lowest????¨????
from collections import Counter
leaf = [i for i in range(v) if not child[i]]
unfinished = Counter()
for li in leaf:
while li is not None:
candidate = [prenum[li]] + [prenum[i] for i in g[li] if i != parent[li]] + [lowest[i] for i in child[li]]
lowest[li] = min(candidate)
li = parent[li]
if li is not None and 1 < len(child[li]):
unfinished[li] += 1
if unfinished[li] < len(child[li]):
break
# ????????????
bridge = []
for i in range(v):
if child[i]:
for j in child[i]:
if prenum[i] < lowest[j]:
if i > j:
i, j = j, i
bridge.append((i, j))
bridge.sort()
for bi in bridge:
print(*bi)
main() | Bridges
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the
number of connected components. | [{"input": "4 4\n 0 1\n 0 2\n 1 2\n 2 3", "output": "2 3"}, {"input": "5 4\n 0 1\n 1 2\n 2 3\n 3 4", "output": "0 1\n 1 2\n 2 3\n 3 4"}] |
A list of _bridges_ of the graph ordered by name. For each bridge, names of
its end-ponints, source and target (source < target), should be printed
separated by a space. The sources should be printed ascending order, then the
target should also be printed ascending order for the same source. | s240423766 | Wrong Answer | p02367 | |V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
, where |V| is the number of nodes and |E| is the number of edges in the
graph. The graph nodes are named with the numbers 0, 1,..., |V|-1
respectively.
si and ti represent source and target nodes of i-th edge (undirected). | import sys
sys.setrecursionlimit(100000)
def dfs(v, tm):
dts[v] = est[v] = tm + 1
child = 0
for i in adj[v]:
if est[i] == float("inf"):
child += 1
parents[i] = v
dfs(i, tm + 1)
est[v] = min(est[v], est[i])
if est[i] > dts[v]:
bridges.append((v, i))
elif parents[v] != i:
est[v] = min(est[v], dts[i])
nv, ne = map(int, input().split(" "))
adj = [[] for _ in range(nv)]
est = [float("inf")] * nv
parents = [None] * nv
dts = [0] * nv
bridges = []
for _ in range(ne):
s, t = map(int, input().split(" "))
adj[s].append(t)
adj[t].append(s)
dfs(0, 0)
bridges.sort(key=lambda tup: (tup[0], tup[1]))
[print(str(bridge[0]) + " " + str(bridge[1])) for bridge in bridges]
| Bridges
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the
number of connected components. | [{"input": "4 4\n 0 1\n 0 2\n 1 2\n 2 3", "output": "2 3"}, {"input": "5 4\n 0 1\n 1 2\n 2 3\n 3 4", "output": "0 1\n 1 2\n 2 3\n 3 4"}] |
A list of _bridges_ of the graph ordered by name. For each bridge, names of
its end-ponints, source and target (source < target), should be printed
separated by a space. The sources should be printed ascending order, then the
target should also be printed ascending order for the same source. | s975677580 | Accepted | p02367 | |V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1
, where |V| is the number of nodes and |E| is the number of edges in the
graph. The graph nodes are named with the numbers 0, 1,..., |V|-1
respectively.
si and ti represent source and target nodes of i-th edge (undirected). | # Undirected Graph
class Edge:
__slots__ = ("v", "w")
def __init__(self, v, w):
self.v = v
self.w = w
def either(self):
return self.v
def other(self, v):
if v == self.v:
return self.w
else:
return self.v
class Graph:
def __init__(self, v):
self.v = v
self._edges = [[] for _ in range(v)]
def add(self, e):
self._edges[e.v].append(e)
self._edges[e.w].append(e)
def adj(self, v):
return self._edges[v]
def edges(self):
for es in self._edges:
for e in es:
yield e
def bridges(graph):
def visit(v, e):
nonlocal n
w = e.other(v)
if not visited[w]:
parent[w] = v
n += 1
visited[w] = n
low[w] = n
return True
elif w != parent[v]:
low[v] = min(low[v], visited[w])
return False
def leave(p, e):
c = e.other(p)
if p == parent[c] and low[c] > visited[p]:
es.append(e)
low[p] = min(low[p], low[c])
return False
visited = [0] * graph.v
low = [0] * graph.v
parent = [-1] * graph.v
es = []
s = 0
n = 1
visited[s] = n
low[s] = n
stack = [(s, e, visit) for e in graph.adj(s)]
while stack:
v, e, func = stack.pop()
# print(v, e.v, e.w, func.__name__, visited, low)
if func(v, e):
stack.append((v, e, leave))
w = e.other(v)
for ne in graph.adj(w):
stack.append((w, ne, visit))
return es
def run():
v, e = [int(i) for i in input().split()]
g = Graph(v)
for _ in range(e):
s, t = [int(i) for i in input().split()]
g.add(Edge(s, t))
edges = [(e.v, e.w) if e.v < e.w else (e.w, e.v) for e in bridges(g)]
for v, w in sorted(edges):
print(v, w)
if __name__ == "__main__":
run()
| Bridges
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the
number of connected components. | [{"input": "4 4\n 0 1\n 0 2\n 1 2\n 2 3", "output": "2 3"}, {"input": "5 4\n 0 1\n 1 2\n 2 3\n 3 4", "output": "0 1\n 1 2\n 2 3\n 3 4"}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s536679192 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | N, K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B, C = zip(*A)
S = 10**36
for left in B:
for right in B:
for up in C:
for down in C:
if left < right and down < up:
cnt = 0
for x, y in A:
if left <= x <= right and down <= y <= up:
cnt += 1
if cnt >= K:
S = min(S, (right - left) * (up - down))
print(S)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s033661092 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | from itertools import groupby, accumulate, product, permutations, combinations
def compress(arr):
(*XS,) = set(arr)
XS.sort()
return {e: i + 1 for i, e in enumerate(XS)}, {i + 1: e for i, e in enumerate(XS)}
def solve():
ans = float("inf")
N, K = map(int, input().split())
X, Y = [0] * N, [0] * N
for i in range(N):
X[i], Y[i] = map(int, input().split())
x_c, x_r = compress(X)
y_c, y_r = compress(Y)
n_x = len(x_c)
n_y = len(y_c)
num = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
X[i] = x_c[X[i]]
Y[i] = y_c[Y[i]]
num[X[i]][Y[i]] += 1
cum2 = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
for j in range(1, N + 1):
cum2[i][j] = (
cum2[i - 1][j] + cum2[i][j - 1] - cum2[i - 1][j - 1] + num[i][j]
)
for x1, x2 in combinations(range(1, n_x + 1), 2):
x_l = x_r[x2] - x_r[x1]
for y1, y2 in combinations(range(1, n_y + 1), 2):
k = (
cum2[x2][y2]
+ cum2[x1 - 1][y1 - 1]
- cum2[x1 - 1][y2]
- cum2[x2][y1 - 1]
)
if k >= K:
y_l = y_r[y2] - y_r[y1]
ans = min(ans, x_l * y_l)
return ans
print(solve())
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s595880622 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | from collections import deque
import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return sys.stdin.readline()[:-1]
def main():
n, k = MI()
xx = set()
yy = set()
xy = []
for _ in range(n):
x, y = MI()
xy.append((x, y))
xx.add(x)
yy.add(y)
xy.sort()
xx = list(sorted(xx))
yy = list(sorted(yy))
xn = len(xx)
yn = len(yy)
ans = 10**20
for t in range(yn):
y2 = yy[t]
for b in range(t):
y1 = yy[b]
r = -1
s = 0
i = j = 0
for l, x1 in enumerate(xx):
while i < n and xy[i][0] < x1:
if y1 <= xy[i][1] <= y2:
s -= 1
i += 1
while s < k and r + 1 < xn:
r += 1
x2 = xx[r]
while j < n and xy[j][0] <= x2:
if y1 <= xy[j][1] <= y2:
s += 1
j += 1
if s >= k:
cur = (x2 - x1) * (y2 - y1)
if cur < ans:
ans = cur
print(ans)
main()
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s600192312 | Wrong Answer | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | n, k = list(map(int, input().split()))
xy = [tuple(map(int, input().split())) for i in range(n)]
import heapq
class Rect:
def __init__(self, xy):
self.xy = set(xy)
def excluded(self, p):
return Rect((q for q in self.xy if q != p))
def __lt__(self, other):
return self.get_score() < other.get_score()
def __len__(self):
return len(self.xy)
def get_x_max(self):
return max(self.xy, key=lambda t: t[0])
def get_x_min(self):
return min(self.xy, key=lambda t: t[0])
def get_y_max(self):
return max(self.xy, key=lambda t: t[1])
def get_y_min(self):
return min(self.xy, key=lambda t: t[1])
def get_score(self):
return (self.get_x_max()[0] - self.get_x_min()[0]) * (
self.get_y_max()[1] - self.get_y_min()[1]
)
def __str__(self):
return str(self.xy)
heap = []
r = Rect(xy)
score = r.get_score()
while len(r) > k:
s = r.excluded(r.get_x_max())
t = r.excluded(r.get_x_min())
u = r.excluded(r.get_y_max())
v = r.excluded(r.get_y_min())
heapq.heappush(heap, s)
heapq.heappush(heap, t)
heapq.heappush(heap, u)
heapq.heappush(heap, v)
r = heapq.heappop(heap)
print(r.get_score())
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s546498303 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | n, k = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]
x = [xy[i][0] for i in range(n)]
y = [xy[i][1] for i in range(n)]
for i in range(n - k):
x = [xy[i][0] for i in range(n - i)]
y = [xy[i][1] for i in range(n - i)]
xl = min(x)
xr = max(x)
yl = min(y)
yr = max(y)
xr2 = sorted(x)[-2]
xl2 = sorted(x)[0]
yr2 = sorted(y)[-2]
yl2 = sorted(y)[0]
res1 = (xl2 - xl) * (yr - yl)
res2 = (xr - xr2) * (yr - yl)
res3 = (yl2 - yl) * (xr - xl)
res4 = (yr - yr2) * (xr - xl)
if max(res1, res2, res3, res4) == res1:
xy.pop(x.index(xl))
elif max(res1, res2, res3, res4) == res2:
xy.pop(x.index(xr))
elif max(res1, res2, res3, res4) == res3:
xy.pop(x.index(yl))
elif max(res1, res2, res3, res4) == res4:
xy.pop(x.index(yr))
x = [xy[i][0] for i in range(k)]
y = [xy[i][1] for i in range(k)]
xl = min(x)
xr = max(x)
yl = min(y)
yr = max(y)
print((xr - xl) * (yr - yl))
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s311983682 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | N,K=map(int,input().split())
z=[tuple(map(int,input().split()))for _ in range(N)]
x=[i for i,_ in z]
y=[j for _,j in z]
x.sort()
y.sort()
a=10**20
for i in range(N):
for j in range(i+1,N):
for k in range(N):
for l in range(k+1,N):
l,r,d,u=x[i],x[j],y[k],y[l]
if sum([1for v,w in z if l<=v<=r and d<=w<=u else 0])>=K:
a=min(a,(r-l)*(u-d))
print(a) | Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s778193351 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | import math
# import numpy as np
import queue
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n, k = map(int, ipt().split())
dx = dict()
dy = dict()
xs = []
ys = []
for _ in range(n):
x, y = map(int, ipt().split())
dx[x] = y
dy[y] = x
xs.append(x)
ys.append(y)
xs.sort()
ys.sort()
sm = [[0] * (n + 1) for i in range(n + 1)]
f = False
ly = dx[xs[n - 1]]
for i, yi in enumerate(ys[::]):
if f:
sm[n - 1][i] = 0
else:
sm[n - 1][i] = 1
if ly == yi:
f = True
for i, xi in enumerate(xs[n - 2 :: -1]):
f = False
smx = sm[n - i - 2]
smpx = sm[n - i - 1]
ly = dx[xi]
for j, yj in enumerate(ys):
if f:
smx[j] = smpx[j]
else:
smx[j] = smpx[j] + 1
if ly == yj:
f = True
ma = 4 * 10**18 + 1
for xl, xli in enumerate(xs[: n - 1 :]):
smxl = sm[xl]
for xr, xri in enumerate(xs[xl + 1 : :]):
smxr = sm[xl + xr + 2]
for yd, ydi in enumerate(ys[: n - 1 :]):
for yu, yui in enumerate(ys[yd + 1 : :]):
sk = smxl[yd] + smxr[yu + yd + 2] - smxl[yu + yd + 2] - smxr[yd]
if sk == k:
ss = (yui - ydi) * (xri - xli)
if ss < ma:
ma = ss
print(ma)
return
if __name__ == "__main__":
main()
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s536243574 | Wrong Answer | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | n, K = map(int, input().split())
v = []
for i in range(0, n):
x, y = map(int, input().split())
v.append((x, y))
v.sort()
X = []
Y = []
for i in range(0, n):
x, y = v[i]
X.append(x)
Y.append(y)
def init_min(init_min_val):
# set_val
for i in range(n):
seg_min[i + num_min - 1] = init_min_val[i]
# built
for i in range(num_min - 2, -1, -1):
seg_min[i] = min(seg_min[2 * i + 1], seg_min[2 * i + 2])
def update_min(k, x):
k += num_min - 1
seg_min[k] = x
while k:
k = (k - 1) // 2
seg_min[k] = min(seg_min[k * 2 + 1], seg_min[k * 2 + 2])
def query_min(p, q):
if q <= p:
return ide_ele_min
p += num_min - 1
q += num_min - 2
res = ide_ele_min
while q - p > 1:
if p & 1 == 0:
res = min(res, seg_min[p])
if q & 1 == 1:
res = min(res, seg_min[q])
q -= 1
p = p // 2
q = (q - 1) // 2
if p == q:
res = min(res, seg_min[p])
else:
res = min(min(res, seg_min[p]), seg_min[q])
return res
#####単位元######
ide_ele_min = 10**10
# num_min:n以上の最小の2のべき乗
num_min = 2 ** (n - 1).bit_length()
seg_min = [ide_ele_min] * 2 * num_min
def init_max(init_max_val):
# set_val
for i in range(n):
seg_max[i + num_max - 1] = init_max_val[i]
# built
for i in range(num_max - 2, -1, -1):
seg_max[i] = max(seg_max[2 * i + 1], seg_max[2 * i + 2])
def update_max(k, x):
k += num_max - 1
seg_max[k] = x
while k:
k = (k - 1) // 2
seg_max[k] = max(seg_max[k * 2 + 1], seg_max[k * 2 + 2])
def query_max(p, q):
if q <= p:
return ide_ele_max
p += num_max - 1
q += num_max - 2
res = ide_ele_max
while q - p > 1:
if p & 1 == 0:
res = max(res, seg_max[p])
if q & 1 == 1:
res = max(res, seg_max[q])
q -= 1
p = p // 2
q = (q - 1) // 2
if p == q:
res = max(res, seg_max[p])
else:
res = max(max(res, seg_max[p]), seg_max[q])
return res
#####単位元######
ide_ele_max = -(10**10)
# num_max:n以上の最小の2のべき乗
num_max = 2 ** (n - 1).bit_length()
seg_max = [ide_ele_max] * 2 * num_max
ans = 10**20
init_min(Y)
init_max(Y)
for i in range(0, n - K + 1):
w = X[K - 1 + i] - X[i]
h = query_max(i, K + i) - query_min(i, K + i)
if ans > h * w:
ans = h * w
print(ans)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s361629977 | Wrong Answer | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
from collections import deque
from fractions import gcd
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def inputI():
return int(input().strip())
def inputS():
return input().strip()
def inputIL():
return list(map(int, input().split()))
def inputSL():
return list(map(str, input().split()))
def inputILs(n):
return list(int(input()) for _ in range(n))
def inputSLs(n):
return list(input().strip() for _ in range(n))
def inputILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n):
return [list(map(str, input().split())) for _ in range(n)]
#####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
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#############
# Main Code #
#############
N, K = inputIL()
P = inputILL(N)
xtic = list(set([xy[0] for xy in P]))
ytic = list(set([xy[1] for xy in P]))
xtic.sort()
ytic.sort()
ans = INF
for p in P:
x0, y0 = p
for xmax in xtic:
if xmax < x0:
continue
else:
tempP = []
for q in P:
if x0 <= q[0] <= xmax and y0 <= q[1]:
tempP.append(q)
if len(tempP) < K:
continue
tempP = sorted(tempP, key=lambda x: x[1])
ans = min(ans, (xmax - x0) * (tempP[K - 1][1] - y0))
P = [[-xy[0], xy[1]] for xy in P]
xtic = list(set([xy[0] for xy in P]))
ytic = list(set([xy[1] for xy in P]))
xtic.sort()
ytic.sort()
for p in P:
x0, y0 = p
for xmax in xtic:
if xmax < x0:
continue
else:
tempP = []
for q in P:
if x0 <= q[0] <= xmax and y0 <= q[1]:
tempP.append(q)
if len(tempP) < K:
continue
tempP = sorted(tempP, key=lambda x: x[1])
ans = min(ans, (xmax - x0) * (tempP[K - 1][1] - y0))
print(ans)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s911550722 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | # https://atcoder.jp/contests/abc075/tasks/abc075_d
# 座標圧縮して二次元累積和に打ち込めば良さそう
# はじめての座圧...?
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_col(H, n_cols):
"""
H is number of rows
n_cols is number of cols
A列、B列が与えられるようなとき
"""
ret = [[] for _ in range(n_cols)]
for _ in range(H):
tmp = list(map(int, read().split()))
for col in range(n_cols):
ret[col].append(tmp[col])
return ret
class cumsum2d: # 二次元累積和クラス pypyでも使えるよ
def __init__(self, ls: list):
"""
2次元のリストを受け取る
"""
from itertools import product
H = len(ls)
W = len(ls[0])
self.ls_accum = [[0] * (W + 1)]
for l in ls:
self.ls_accum.append([0] + l)
# 縦に累積
for i, j in product(range(1, H + 1), range(1, W + 1)):
self.ls_accum[i][j] += self.ls_accum[i - 1][j]
# 横に累積
for i, j in product(range(1, H + 1), range(1, W + 1)):
self.ls_accum[i][j] += self.ls_accum[i][j - 1]
def total(self, i1, j1, i2, j2):
"""
点(i1,j1),(i1,j2),(i2,j1),(i2,j2)の4点が成す四角の中の合計を取り出す
ただし i1<=i2, j1<=j2
ただし、i軸に関しては[i1,i2),j軸に関しては[j1,j2)の半開区間である
"""
return (
self.ls_accum[i2][j2]
- self.ls_accum[i1][j2]
- self.ls_accum[i2][j1]
+ self.ls_accum[i1][j1]
)
class ZaAtu:
def __init__(self, ls):
# 座標圧縮クラス(仮) #どうしたら使いやすくなるのか知らんけど
self.i_to_orig = sorted(set(ls))
self.orig_to_i = {}
for i, zahyou in enumerate(self.i_to_orig):
self.orig_to_i[zahyou] = i
self.len = len(self.i_to_orig)
def __len__(self):
return len(self.i_to_orig)
from itertools import product
N, K = read_ints()
X_ori, Y_ori = read_col(N, 2)
X = ZaAtu(X_ori)
Y = ZaAtu(Y_ori)
table = [[0] * Y.len for _ in range(X.len)] # 二次元累積和を作る
for x, y in zip(X_ori, Y_ori):
i = X.orig_to_i[x]
j = Y.orig_to_i[y]
table[i][j] += 1
table = cumsum2d(table)
# 怒りの全探索
ans = (2 * 10**9) ** 2 + 114514
for i, j in product(range(X.len), range(Y.len)): # 始点
for ii, jj in product(range(i, X.len + 1), range(j, Y.len + 1)): # 終点
if table.total(i, j, ii, jj) >= K:
S = (X.i_to_orig[ii - 1] - X.i_to_orig[i]) * (
Y.i_to_orig[jj - 1] - Y.i_to_orig[j]
)
ans = min(ans, S)
print(ans)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s643166553 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | def main():
N, K = map(int, input().split())
l = []
xl = []
yl = []
for _ in range(N):
x, y = map(int, input().split())
l.append((x, y))
xl.append(x)
yl.append(y)
xl.sort()
yl.sort()
xd = {}
dx = {}
t = 0
p = xl[0]
for i in xl:
if i != p:
t += 1
xd[i] = t
dx[t] = i
p = i
yd = {}
dy = {}
t = 0
p = yl[0]
for i in yl:
if i != p:
t += 1
yd[i] = t
dy[t] = i
p = i
l2 = []
for x, y in l:
l2.append((xd[x], yd[y]))
m = 10**100
for si in range(len(xd) - 1):
for ei in range(si + 1, len(xd)):
for sj in range(len(yd) - 1):
for ej in range(sj + 1, len(yd)):
t = 0
for x, y in l2:
if si <= x <= ei and sj <= y <= ej:
t += 1
if t >= K:
m = min(m, (dx[ei] - dx[si]) * (dy[ej] - dy[sj]))
return m
print(main())
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s110079471 | Accepted | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
import copy
n, k = getList()
buff = []
for i in range(n):
buff.append(getList())
def calc(width, cutbuf, k):
nn = len(cutbuf)
cutbuf.sort(key=lambda x: x[1])
ret = 10**19
for ii in range(nn - k + 1):
tmptmp = abs(cutbuf[ii][1] - cutbuf[ii + k - 1][1])
# print("here")
if ret > tmptmp:
# print("here")
ret = tmptmp
# print(ret, cutbuf)
return ret * width
buff.sort()
ans = 10**19
for i in range(n):
for j in range(i + 1, n):
width = abs(buff[i][0] - buff[j][0])
tmp = calc(width, buff[i : j + 1], k)
if ans > tmp:
ans = tmp
print(ans)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s606829598 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | nums = input().split()
n = int(nums[0])
k = int(nums[1])
points = []
for i in range(n):
temp = input().split()
points.append([int(temp[0]), int(temp[1])])
rmax = points[0][0]
lmax = points[0][0]
tmax = points[0][1]
bmax = points[0][1]
rmaxp = 0
lmaxp = 0
tmaxp = 0
bmaxp = 0
for i in range(1, n):
if points[i][0] > rmax:
rmax = points[i][0]
rmaxp = i
if points[i][0] < lmax:
lmax = points[i][0]
lmaxp = i
if points[i][1] > tmax:
tmax = points[i][0]
tmaxp = i
if points[i][1] < bmax:
bmax = points[i][0]
bmaxp = i
min = (points[rmaxp][0] - points[lmaxp][0]) * (points[tmaxp][1] - points[bmaxp][1])
patterns = []
for i in range(n - k):
for j in range(n - k - i):
for k in range(n - k - i - j):
patterns.append([i, j, k, k - n - i - j - k])
for pattern in patterns:
copypoints = points
for i in range(pattern[0]):
del copypoints[rmaxp]
for i in range(pattern[1]):
del copypoints[lmaxp]
for i in range(pattern[2]):
del copypoints[tmaxp]
for i in range(pattern[3]):
del copypoints[bmaxp]
ans = (points[rmaxp][0] - points[lmaxp][0]) * (points[tmaxp][1] - points[bmaxp][1])
if ans < min:
min = ans
print("{0}".format(min))
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s602561643 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | N, K = list(map(int, input().split()))
co = []
for i in range(N):
co.append(list(map(int, input().split())))
S = 99999999999999999999
for xi in range(N):
for xj in range(N):
for yi in range(N):
for yj in range(N):
l = abs(co[xi][0] - co[xj][0])
m = abs(co[yi][1] - co[yj][1])
----------------
a = min(co[xi][0], co[xj][0])
b = max(co[xi][0], co[xj][0])
c = min(co[yi][1], co[yj][1])
d = max(co[yi][1], co[yj][1])
num = 0
for i in range(N):
if (a <= co[i][0] <= b) and (c <= co[i][1] <= d):
num += 1
if num >= K:
p = l*m
S = min(S,p)
print(S)
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s547852443 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | #include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define plli pair<lli,lli>
using namespace std ;
void ps(string i){
cout << i << endl;
}
template <class T>
void pt(T s){
cout << s << endl;
}
void pi(int i){
cout << i << endl;
}
template <class T>
void pv(vector<T> v){
loop(v.size()){
pt<T>(v[i]);
}
}
/*********************************reused****************************/
int n,k;
plli p[60];
lli state[60];
map<string,lli> s;
lli getSurface(){
lli minx = -1,maxx = -1,miny = -1,maxy = -1;
loop(k){
if(minx == -1){
minx = p[state[i]].first;
}else{
minx = min(p[state[i]].first,minx);
}
if(maxx == -1){
maxx = p[state[i]].first;
}else{
maxx = max(p[state[i]].first,maxx);
}
if(miny == -1){
miny = p[state[i]].second;
}else{
miny = min(p[state[i]].second,miny);
}
if(maxy == -1){
maxy = p[state[i]].second;
}else{
maxy = max(p[state[i]].second,maxy);
}
}
return (maxy-miny)*(maxx-minx);
}
lli dp(){
plli p[60];
int maxi = -1;
lli mini = -1;
do{
if(mini == -1){
mini = getSurface();
}else{
mini = min(mini,getSurface());
}
int finishi = -1;
loop(k){
if(state[n-i-1]!=(n-i-1)){
state[n-i-1]++;
finishi = i;
break;
}
}
if(finishi == -1)
break;
loop(finishi){
state[n-i-1] = state[n-i-2]+1;
}
}while(true);
return mini;
}
bool compare(plli a,plli b){
return a.first < b.first?true:(a.first > b.first)?false:(a.second <= b.second?true:false);
}
int main()
{
cin >> n>>k;
loop(k){
state[i] = i;
}
loop(n){
lli x,y;
cin >> x >> y;
p[i] = make_pair(x,y);
}
sort(p,p+n,compare);
cout << dp() << endl;
return 0;
}
| Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s174235233 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | n,k = map(int,input().split())
xyl = []
for _ in range(n):
x,y = map(int,input().split())
xyl.append((x,y))
ans = float("inf")
for i in range(n):
for j in range(i+1, n):
for h in range(j+1, n):
for g in range(h+1, n):
x1 = min(xyl[i][0], xyl[j][0], xyl[h][0], xyl[g][0])
x2 = max(xyl[i][0], xyl[j][0], xyl[h][0], xyl[g][0])
y1 = min(xyl[i][1], xyl[j][1], xyl[h][1], xyl[g][1])
y2 = max(xyl[i][1], xyl[j][1], xyl[h][1], xyl[g][1])
cnt = 0
for p in range(n):
if x1 <= xyl[p][0] <= x2 and y1 <= xyl[p][1] <= y2:
cnt += 1
if k <= cnt:
ans = min(ans, (x2-x1)*(y2-y1))
for i in range(n):
for j in range(i+1, n):
for h in range(j+1, n):
x1 = min(xyl[i][0], xyl[j][0], xyl[h][0])
x2 = max(xyl[i][0], xyl[j][0], xyl[h][0])
y1 = min(xyl[i][1], xyl[j][1], xyl[h][1])
y2 = max(xyl[i][1], xyl[j][1], xyl[h][1])
cnt = 0
for p in range(n):
if x1 <= xyl[p][0] <= x2 and y1 <= xyl[p][1] <= y2:
cnt += 1
if k <= cnt:
ans = min(ans, (x2-x1)*(y2-y1))
for i in range(n):
for j in range(i+1, n):
x1 = min(xyl[i][0], xyl[j][0])
x2 = max(xyl[i][0], xyl[j][0])
y1 = min(xyl[i][1], xyl[j][1])
y2 = max(xyl[i][1], xyl[j][1])
cnt = 0
for p in range(n):
if x1 <= xyl[p][0] <= x2 and y1 <= xyl[p][1] <= y2:
cnt += 1
if k <= cnt:
ans = min(ans, (x2-x1)*(y2-y1))
print(ans) | Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum possible area of a rectangle that satisfies the condition.
* * * | s032786569 | Runtime Error | p03576 | Input is given from Standard Input in the following format:
N K
x_1 y_1
:
x_{N} y_{N} | /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
import numpy as np
from collections import OrderedDict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
sys.setrecursionlimit(10000)
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
class EndLoop(Exception):
pass
def debug_print(L):
for col in L:
print(col)
def debug_print_joined(L):
for col in L:
print("".join(col))
def transpose_matrix(L):
transposed = list(map(list, zip(*L)))
return transposed
def solve():
N, K = map(int, input().split())
x_coordinates = []
y_coordinates = []
for _ in range(N):
x, y = map(int, input().split())
x_coordinates.append(x)
y_coordinates.append(y)
x_coordinates_comb = []
y_coordinates_comb = []
for ele in itertools.combinations(x_coordinates, 2):
x_coordinates_comb.append(ele)
for ele in itertools.combinations(y_coordinates, 2):
y_coordinates_comb.append(ele)
min_area = 10e18
for x in x_coordinates_comb:
for y in x_coordinates_comb:
cnt = 0
for i in range(N):
if min(x) <= x_coordinates[i] <= max(x) and min(y) <= y_coordinates[i] <= max(y):
cnt += 1
if cnt >= K:
min_area = min(min_area, (max(x) - min(x)) * (max(y) - min(y)))
print(min_area)
solve() | Statement
We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes
that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the
interior.
Find the minimum possible area of such a rectangle. | [{"input": "4 4\n 1 4\n 3 3\n 6 2\n 8 1", "output": "21\n \n\nOne rectangle that satisfies the condition with the minimum possible area has\nthe following vertices: (1,1), (8,1), (1,4) and (8,4). \nIts area is (8-1) \u00d7 (4-1) = 21.\n\n* * *"}, {"input": "4 2\n 0 0\n 1 1\n 2 2\n 3 3", "output": "1\n \n\n* * *"}, {"input": "4 3\n -1000000000 -1000000000\n 1000000000 1000000000\n -999999999 999999999\n 999999999 -999999999", "output": "3999999996000000001\n \n\nWatch out for integer overflows."}] |
Print the minimum number of stones that needs to be recolored.
* * * | s412603565 | Wrong Answer | p03063 | Input is given from Standard Input in the following format:
N
S | a = int(input())
b = list(input())
white_stone = b.count(".")
black_stone = b.count("#")
print(min(white_stone, black_stone))
| Statement
There are N stones arranged in a row. Every stone is painted white or black. A
string S represents the color of the stones. The i-th stone from the left is
white if the i-th character of S is `.`, and the stone is black if the
character is `#`.
Takahashi wants to change the colors of some stones to black or white so that
there will be no white stone immediately to the right of a black stone. Find
the minimum number of stones that needs to be recolored. | [{"input": "3\n #.#", "output": "1\n \n\nIt is enough to change the color of the first stone to white.\n\n* * *"}, {"input": "5\n #.##.", "output": "2\n \n\n* * *"}, {"input": "9\n .........", "output": "0"}] |
Print the minimum number of stones that needs to be recolored.
* * * | s945136246 | Runtime Error | p03063 | Input is given from Standard Input in the following format:
N
S | N = int(input())
mod = 998244353
# DP ナップサックぽいやつ
# DP[i][j] := a_0からa_iまでの部分集合で和がjになるものの個数
# 配るDPの方が場合分けがなくて簡潔に書ける 計算量増えるかも
# DP[i-1][j]→DP[i][j]とDP[i][j + a_i ]に配る
aaa = [int(input()) for _ in range(N)]
sum_aaa = sum(aaa)
sum_now = 0
DP = [[0] * (sum_aaa + 1) for i in range(N)]
DP2 = [[0] * (sum_aaa + 1) for i in range(N)]
a = aaa[0]
DP[0][0] = 2
DP[0][a] = 1
DP2[0][0] = 1
DP2[0][a] = 1
sum_now += a
for i in range(1, N):
a = aaa[i]
sum_now += a
for j in range(sum_now + 1):
if j >= a:
DP[i][j] = DP[i - 1][j] * 2 + DP[i - 1][j - a]
else:
DP[i][j] = DP[i - 1][j] * 2
while DP[i][j] > mod:
DP[i][j] -= mod
for j in range(min(sum_now + 1, int(sum_aaa / 2) + 1)):
if j >= a:
DP2[i][j] = DP2[i - 1][j] + DP2[i - 1][j - a]
else:
DP2[i][j] = DP2[i - 1][j]
while DP2[i][j] > mod:
DP2[i][j] -= mod
# print(DP2)
minimum_invalid_length = int((sum_now + 1) // 2)
num_too_long = sum(DP[N - 1][minimum_invalid_length:])
if sum_aaa % 2 == 0:
num_too_long -= DP2[N - 1][int(sum_aaa / 2)]
# print(num_too_long)
# print(sum(aaa))
print((3**N - num_too_long * 3) % mod)
| Statement
There are N stones arranged in a row. Every stone is painted white or black. A
string S represents the color of the stones. The i-th stone from the left is
white if the i-th character of S is `.`, and the stone is black if the
character is `#`.
Takahashi wants to change the colors of some stones to black or white so that
there will be no white stone immediately to the right of a black stone. Find
the minimum number of stones that needs to be recolored. | [{"input": "3\n #.#", "output": "1\n \n\nIt is enough to change the color of the first stone to white.\n\n* * *"}, {"input": "5\n #.##.", "output": "2\n \n\n* * *"}, {"input": "9\n .........", "output": "0"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s352757103 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | int(N) = input()
int(A) = input()
if N % 500 > A:
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s408966609 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | a, b = int(input()), int(input())
print("Yes") if a % 500 <= b else print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s622674926 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes") if int(input()) % 500 <= int(input()) else print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s598676247 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("YNeos"[eval(input() + "%500>" + input()) :: 2])
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s097084147 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n=int(input())
a=int(input())
print(['Yes','No'][(n-a)%500>0] | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s953589540 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | n, a = open(0).read().split()
print("Yneos"[int(n) % 500 > int(a) :: 2])
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s662335149 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n = int(input())
a = int(input())
if n%500<= a:
plint("Yes")
else: | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s328857894 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes" if int(input()) >= (int(input()) % 500) else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s993345345 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input()), A = int(input())
print("Yes" if N % 500 <= A else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s220464612 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | N, A = map(int, open(0))
print("YES" if A >= (N % 500) else "NO")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s179995579 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes" if int(input()) > (int(input()) % 500) else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s077558234 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | import numpy as np
def solve(posi):
INF = 100000000000
d = np.zeros((H, W))
for i in range(H):
for j in range(W):
d[i][j] = INF
que = [posi]
d[posi[0], posi[1]] = 0
move = np.array([[1, 0], [-1, 0], [0, 1], [0, -1]])
while len(que):
p = que.pop(0)
if np.allclose(posi, np.array([H - 1, W - 1])):
break
for dir in move:
new_p = p + dir
if 0 <= new_p[0] and new_p[0] < H and 0 <= new_p[1] and new_p[1] < W:
if d[new_p[0], new_p[1]] == INF and maze[new_p[0]][new_p[1]] != "#":
que.append(new_p)
d[new_p[0], new_p[1]] = d[p[0], p[1]] + 1
if d[H - 1][W - 1] == INF:
return -1
return d[H - 1][W - 1]
if __name__ == "__main__":
H, W = map(int, input().split(" "))
maze = []
for i in range(H):
maze.append(list(input()))
counter = 0
for i in range(H):
for j in range(W):
if maze[i][j] == ".":
counter += 1
posi = np.array([0, 0])
print(int(counter - solve(posi) - 1))
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s776397239 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
a = sorted(list(map(int, input().split()), reverse=True)
Alice=0
Bob=0
for i in range(N):
if i % 2 = 0:
Alice += a[i]
else:
Bob += a[i]
print(Alice-Bob) | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s801249377 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | H, W = map(int, input().split())
s = [[i for i in input()] for i in range(H)]
maze = [[False for i in range(W)] for i in range(H)]
bknum = 0
for i in range(H):
for j in range(W):
if s[i][j] == ".":
maze[i][j] = True
else:
maze[i][j] = False
bknum += 1
def ncell(i, j):
tmp = [[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]]
out = []
for p in tmp:
if 0 <= p[0] < H and 0 <= p[1] < W and maze[i][j]:
out.append(p)
return out
d = [[1000 for j in range(W)] for i in range(H)]
prev = [[-1 for j in range(W)] for i in range(H)]
d[0][0] = 0
Q = set()
for i in range(H):
for j in range(W):
if maze[i][j]:
Q.add(i * W + j)
while len(Q) != 0:
u = list(Q)[0]
du = d[u // W][u % W]
for v in Q:
if d[v // W][v % W] < du:
du = d[v // W][v % W]
u = v
Q -= set([u])
for v in ncell(u // W, u % W):
if d[v[0]][v[1]] > d[u // W][u % W] + 1:
d[v[0]][v[1]] = d[u // W][u % W] + 1
prev[v[0]][v[1]] = u
length = d[H - 1][W - 1]
if length != 1000:
print(H * W - length - 1 - bknum)
else:
print(-1)
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s381186391 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | import sys
from collections import deque
sys.setrecursionlimit(10**9)
H, W = map(int, input().split())
Map = [[] for _ in range(H)]
reached = [[-1] * W for _ in range(H)]
route = [[False] * W for _ in range(H)]
q = deque()
check = False
b = 0
for y in range(H):
for x in input():
Map[y].append(x)
if x == "#":
b += 1
def BFS(x, y, pre):
global check
if x >= W or y >= H or x < 0 or y < 0 or Map[y][x] == "#" or reached[y][x] >= 0:
return
reached[y][x] = pre + 1
if x == (W - 1) and y == (H - 1):
ans = H * W - reached[y][x] + 1 - b - 2
print(ans)
sys.exit()
else:
q.append((x + 1, y, pre + 1))
q.append((x - 1, y, pre + 1))
q.append((x, y + 1, pre + 1))
q.append((x, y - 1, pre + 1))
q.append((0, 0, -1))
while q:
BFS(*q.popleft())
print(-1)
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s851670529 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
a = list(map(int, input().split()))
def sort_reverse(n):
n.sort(reverse=True)
return n
N_Even = list(range(0, N + 1, 2))
N_Odd = list(range(1, N + 1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0
for i in N_Even:
sum1 += a1[i]
for j in N_Odd:
sum2 += a1[j]
print(sum1 - sum2)
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s044940763 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N,A= (int(i) for i in input().split())
a = N % 500
if (a > A):
print("No")
else
print("Yes") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s095171250 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | x = [int(input()) for i in range(2)]
print("Yes") if (x[0] % 500) <= x[1] else print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s368885878 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | =input()
A=input()
B=N%500
if(int(B-A)==0):
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s059590922 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("No" if max(int(input()) % 500 - int(input()), 0) else "Yes")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s205642413 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("YNeos"[int(input()) % 500 > int(input()) :: 2])
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s913558869 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | money = int(input())
many_1_coin = int(input())
print("Yes" if (money % 500) <= many_1_coin else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s546406920 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n = int(input())
a = int(input())
m = n % 500
if a >= m :
print('Yes')
else:
print('No')
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s569417345 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
A = int(input())
if N%500=<A:
print('Yes')
else:
print('No')
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s521948809 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("No" if eval(input() + "%500>" + input()) else "Yes")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s746187820 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("YNeos"[(int(input()) % 500 > int(input())) :: 2])
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s794982696 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N,A=map(int,input().split())
if N%500<=A:
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s559514532 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | x, a = [int(input()) for i in range(2)]
print("Yes" if a > x % 500 else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s876298894 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes" if (int(input()) // 500) <= int(input()) else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s279090849 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print(int(input()) % 500 <= int(input()))
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s267422397 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | # -*- coding: utf-8 -*-
N = int(input())
A = int(input())
ans = False
for x in range(A):
if (N - x) % 500 == 0:
ans = True
print('Yes')
break
else:
ans = pass
if not ans:
print('No') | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s849023564 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | # -*- coding: utf-8 -*-
n = int(input())
a = int(input())
if a == 0 and n%500 != 0:
print("No")
elif n%500==0:
print("Yes")
elif n%500 =< a:
print("Yes")
else:
pass | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s646998408 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | money = for(int(i) in i = input().sprit())
mod = money[0] % 500
if money[1] >= mod:
print("Yes")
else:
print("No") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s363930196 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | %import numpy as np
c1 = [int(i) for i in input().split()]
c2 = [int(i) for i in input().split()]
c3 = [int(i) for i in input().split()]
s = sum(c1) + sum(c2) + sum(c3)
print('Yes' if s % 3 == 0 else 'No') | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s319286833 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
A = int(input())
N = N % 500
if N =< A:
print("Yes")
else:
print("No") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s059789445 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
A = list(map(int, input().split()))
SA = sorted(A, reverse=True)
ALI = 0
BOB = 0
for i in range(0, N, 2):
ALI += int(SA[i])
for n in range(1, N, 2):
BOB += int(SA[n])
ans = ALI - BOB
print(ans)
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s693669613 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N,A = map(int, input().split())
if N%500=< A:
print("Yes")
else:
print("No") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s761156730 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n = int(input())
a = int(input())
n // 500 = m
if m <= a:
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s670761235 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N = int(input())
A = int(input())
if(N % 500 =< A):
print('Yes')
else:
print('No') | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s127912196 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | a, b = map(int, input().split()))
if a % 500 <= b:
print("Yes")
else:
print("No") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s308552694 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n = int(input())
a = int(input())
if n % 500 =< a:
print('Yes')
else:
print('No') | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s549104048 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N=int(input())
A=int(input())
if N%500<=A:
print("Yes")
else:
print("No") | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s800271221 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n = int(input())
a = int(input())
n % 500 = m
if m <= a:
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s785194374 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | N=int(input())
A=int(input())
if((N%500<=A):
print("Yes")
else:
print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s901691941 | Accepted | p03433 | Input is given from Standard Input in the following format:
N
A | print("No") if int(input()) % 500 > int(input()) else print("Yes")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s660752189 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes" if int(input()) % 500 <= a else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s106889848 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print("YNeos"[(int(input()) % 500) <= int(input()) :: 2])
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s877441027 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n=int(input())
a=int(input())
print('Yes' if n%500<==a else 'No') | Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s515101489 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | print("Yes") if int(input()) // 500 <= int(input()) else print("No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s009878281 | Wrong Answer | p03433 | Input is given from Standard Input in the following format:
N
A | a, b = (int(input()) for _ in range(2))
print("Yes" if a % 500 < b else "No")
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print
`Yes`; otherwise, print `No`.
* * * | s880469722 | Runtime Error | p03433 | Input is given from Standard Input in the following format:
N
A | n=int(input())
a=int(input())
if n%500=<a:
print('Yes')
else:
print('No')
| Statement
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins. | [{"input": "2018\n 218", "output": "Yes\n \n\nWe can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer\nis `Yes`.\n\n* * *"}, {"input": "2763\n 0", "output": "No\n \n\nWhen we have no 1-yen coins, we can only pay a multiple of 500 yen using only\n500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.\n\n* * *"}, {"input": "37\n 514", "output": "Yes"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.