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 number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the
condition.
* * *
|
s076727660
|
Runtime Error
|
p02702
|
Input is given from Standard Input in the following format:
S
|
S = input()
def d(i, j):
def d1(i, j):
if i == 1 and j == int(S[0]):
return 1
if i == 1 and j != int(S[0]):
return 0
if i != 1 and j == int(S[i - 1]):
return d1(i - 1, (202 * (j - int(S[i - 1]))) % 2019) + 1
else:
return d1(i - 1, (202 * (j - int(S[i - 1]))) % 2019)
def d2(i, j):
if i == 1:
return 0
else:
return d1(i - 1, j) + d2(i - 1, j)
return d1(i, j) + d2(i, j)
print(d(len(S), 0))
|
Statement
Given is a string S consisting of digits from `1` through `9`.
Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the
following condition:
Condition: In base ten, the i-th through j-th characters of S form an integer
that is a multiple of 2019.
|
[{"input": "1817181712114", "output": "3\n \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n \n\n* * *"}, {"input": "2119", "output": "0\n \n\nNo pairs satisfy the condition."}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s257029522
|
Wrong Answer
|
p03810
|
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
|
a = int(input())
x = list(map(int, input().split())) # x or y
x.sort()
c = x[0]
s = 0
for i in range(1, a):
s += x[i] // c
s += x[i] % c
if c != 1:
s += 1
if s % 2 == 0:
print("First")
else:
print("Second")
|
Statement
There are N integers written on a blackboard. The i-th integer is A_i, and the
greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game,
starting from Takahashi the two player alternately perform the following
operation:
* Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.
* Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.
The player who is left with only 1s on the blackboard and thus cannot perform
the operation, loses the game. Assuming that both players play optimally,
determine the winner of the game.
|
[{"input": "3\n 3 6 7", "output": "First\n \n\nTakahashi, the first player, can win as follows:\n\n * Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).\n * Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).\n * Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).\n\n* * *"}, {"input": "4\n 1 2 4 8", "output": "First\n \n\n* * *"}, {"input": "5\n 7 8 8 8 8", "output": "Second"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s957145700
|
Runtime Error
|
p03810
|
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
|
n = int(input())
x = list(map(int, input().split()))
j = 1
k=1
while j:
s=0
if 1 in x:
s = sum(x)-n
break
for i in range(n):
if x[i]%2 == 0:
x[i]/=2
s+=1
else:
x[i] = (x[i]-1)/2
if s == n-1 and s%2==0):j = 1
else:j=0
if s %2 != 0:
print("First")
else:
print("Second")
|
Statement
There are N integers written on a blackboard. The i-th integer is A_i, and the
greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game,
starting from Takahashi the two player alternately perform the following
operation:
* Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.
* Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.
The player who is left with only 1s on the blackboard and thus cannot perform
the operation, loses the game. Assuming that both players play optimally,
determine the winner of the game.
|
[{"input": "3\n 3 6 7", "output": "First\n \n\nTakahashi, the first player, can win as follows:\n\n * Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).\n * Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).\n * Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).\n\n* * *"}, {"input": "4\n 1 2 4 8", "output": "First\n \n\n* * *"}, {"input": "5\n 7 8 8 8 8", "output": "Second"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s935726892
|
Wrong Answer
|
p03810
|
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
|
#
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log # log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import (
accumulate,
permutations,
combinations,
product,
combinations_with_replacement,
)
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a, b):
return (a + b - 1) // b
inf = float("inf")
mod = 10**9 + 7
def pprint(*A):
for a in A:
print(*a, sep="\n")
def INT_(n):
return int(n) - 1
def MI():
return map(int, input().split())
def MF():
return map(float, input().split())
def MI_():
return map(INT_, input().split())
def LI():
return list(MI())
def LI_():
return [int(x) - 1 for x in input().split()]
def LF():
return list(MF())
def LIN(n: int):
return [I() for _ in range(n)]
def LLIN(n: int):
return [LI() for _ in range(n)]
def LLIN_(n: int):
return [LI_() for _ in range(n)]
def LLI():
return [list(map(int, l.split())) for l in input()]
def I():
return int(input())
def F():
return float(input())
def ST():
return input().replace("\n", "")
def gcd_list(A):
res = A[0]
for a in A:
res = gcd(a, res)
return res
def check(N, A):
if 1 in A:
if (sum(A) - N) & 1:
return 0 # 先手
else:
return 1 # 後手
odd_cnt, even_cnt = 0, 0
for a in A:
if a & 1:
odd_cnt += 1
else:
even_cnt += 1
if even_cnt & 1:
return 0
else:
if odd_cnt >= 2:
return 1
else: ##奇数のを選ぶしかないのでその後どうなるかを調べる
odd_idx = [i for i in range(N) if A[i] & 1][0]
A[odd_idx] -= 1
G = gcd_list(A)
return check(N, [a // G for a in A])
def main():
N = I()
A = LI()
print(["First", "Second"][check(N, A)])
if __name__ == "__main__":
main()
|
Statement
There are N integers written on a blackboard. The i-th integer is A_i, and the
greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game,
starting from Takahashi the two player alternately perform the following
operation:
* Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.
* Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.
The player who is left with only 1s on the blackboard and thus cannot perform
the operation, loses the game. Assuming that both players play optimally,
determine the winner of the game.
|
[{"input": "3\n 3 6 7", "output": "First\n \n\nTakahashi, the first player, can win as follows:\n\n * Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).\n * Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).\n * Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).\n\n* * *"}, {"input": "4\n 1 2 4 8", "output": "First\n \n\n* * *"}, {"input": "5\n 7 8 8 8 8", "output": "Second"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s798554141
|
Wrong Answer
|
p03810
|
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
|
import random
def tester(N=0):
"""
制約
1≦N≦2000
1≦Ai≦108
"""
maxno1 = 2000
maxno2 = 1e5
s = input()
if s != "":
return s
if N == 0:
return 6
return random.randint(2, maxno1)
else:
print("Testing...")
print("N=", N)
return "1 2 3 4 5 2"
A = []
for i in range(N):
A.extend([random.randint(1, maxno2)])
r = " ".join(list(map(str, A)))
return r
def factorint(n):
i = 2
T = []
while i * i <= n:
while n % i == 0:
n //= i
T.append(i)
i += 1
if n > 1:
T.append(n)
return T
import logging
# create logger
logger = logging.getLogger("simple_example")
logger.setLevel(logging.WARNING) # DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.WARNING) # DEBUG)
# create formatter
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
import copy
N = int(tester())
A = [int(x) for x in tester(N).split()]
A.sort(reverse=False)
logger.debug("A is %s", str(A))
F = dict()
P = dict()
for i in range(N):
if A[i] == 1:
F[i] = {1}
else:
F[i] = set(factorint(A[i]))
for y in F[i]:
if y not in P.keys():
P[y] = set()
P[y].add(i)
G = dict()
for i in F.keys():
G[i] = set()
for y in F[i]:
G[i] = G[i].union(P[y])
G[i].remove(i)
Ac = list(range(N))
Gc = copy.deepcopy(G)
Tr = dict()
while len(Ac) > 0:
Tmp = []
rt = min(Ac)
me = rt
Tmp.extend([me])
Ac.remove(me)
while len(Gc[me]) > 0:
nxt = min(Gc[me])
if nxt not in Ac:
Gc[me].remove(nxt)
continue
else:
me = nxt
Tmp.extend([me])
Ac.remove(me)
Tr[rt] = Tmp
OoTr = list(Tr.keys())
OoTr.sort(reverse=True)
AnsIdx = []
for i in OoTr:
AnsIdx.extend(Tr[i])
Ans = [A[i] for i in AnsIdx]
print(" ".join(list(map(str, Ans))))
logger.removeHandler(ch)
|
Statement
There are N integers written on a blackboard. The i-th integer is A_i, and the
greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game,
starting from Takahashi the two player alternately perform the following
operation:
* Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.
* Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.
The player who is left with only 1s on the blackboard and thus cannot perform
the operation, loses the game. Assuming that both players play optimally,
determine the winner of the game.
|
[{"input": "3\n 3 6 7", "output": "First\n \n\nTakahashi, the first player, can win as follows:\n\n * Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).\n * Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).\n * Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).\n\n* * *"}, {"input": "4\n 1 2 4 8", "output": "First\n \n\n* * *"}, {"input": "5\n 7 8 8 8 8", "output": "Second"}]
|
If Takahashi will win, print `First`. If Aoki will win, print `Second`.
* * *
|
s756633341
|
Wrong Answer
|
p03810
|
The input is given from Standard Input in the following format:
N
A_1 A_2 … A_N
|
n = int(input().strip())
a = [int(x) for x in input().strip().split()]
sa = sum(a)
p = n % 2
q = sa % 2
r = sum([x % 2 for x in a])
if p + q == 1:
winner = 0
elif p + q == 0:
winner = 1
else:
winner = 0
fin = 0
while fin == 0:
winner = 1 - winner
r = sum([x % 2 for x in a])
if r > 1:
break
sa = sum(a)
b = 0
c = sa - 1
while c % 2 == 0:
b += 1
c /= 2
d = 2**b
for i in range(len(a)):
if a[i] % 2 == 0 and a[i] % d != 0:
fin = 1
break
elif a[i] % 2 == 0:
a[i] /= d
elif a[i] % 2 == 1 and (a[i] - 1) % d != 0:
fin = 1
break
else:
a[i] = (a[i] - 1) / d
winner_str = "Second" if winner else "First"
print(winner_str)
|
Statement
There are N integers written on a blackboard. The i-th integer is A_i, and the
greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game,
starting from Takahashi the two player alternately perform the following
operation:
* Select one integer on the blackboard that is not less than 2, and subtract 1 from the integer.
* Then, divide all the integers on the black board by g, where g is the greatest common divisor of the integers written on the blackboard.
The player who is left with only 1s on the blackboard and thus cannot perform
the operation, loses the game. Assuming that both players play optimally,
determine the winner of the game.
|
[{"input": "3\n 3 6 7", "output": "First\n \n\nTakahashi, the first player, can win as follows:\n\n * Takahashi subtracts 1 from 7. Then, the integers become: (1,2,2).\n * Aoki subtracts 1 from 2. Then, the integers become: (1,1,2).\n * Takahashi subtracts 1 from 2. Then, the integers become: (1,1,1).\n\n* * *"}, {"input": "4\n 1 2 4 8", "output": "First\n \n\n* * *"}, {"input": "5\n 7 8 8 8 8", "output": "Second"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s103672801
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
import math
import sys
import itertools
import queue
from fractions import gcd
def lcm(a, b):
return a * b // gcd(a, b)
def combination(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
sys.setrecursionlimit(10000)
mod = 1000000007
"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654
# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
# 標準入力取得
## 文字列
= sys.stdin.readline().rstrip()
= list(sys.stdin.readline().rstrip())
## 数値
= int(sys.stdin.readline())
= map(int, sys.stdin.readline().split())
= list(map(int, sys.stdin.readline().split()))
= [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき
"""
if __name__ == "__main__":
N = list(sys.stdin.readline().rstrip())
if N[:3].count(N[0]) == 3 or N[1:].count(N[1]) == 3:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s090695272
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=input()#整数Nを受け取る
#Nのi文字目とi+1文字目が同じであればカウントを増やす。
j_count=0
for i in range(0,3):
if N[i]==N[i+1]:
j_count+=1
#カウントが2以上かつ2文字目=3文字目であればYes、でなければNoを返す。
if j_count>=2 and N[1]==N[2]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s809102144
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
# 1 line 1 int
return int(sys.stdin.readline().rstrip())
def LI():
# 1 line n ints
return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
# 1 line 1 string
return sys.stdin.readline().rstrip()
def LS():
# 1 line n strings
return list(sys.stdin.readline().rstrip().split())
A = S()
if A[0] == A[1] == A[2] or
A[1] == A[2] == A[3]:
print("Yes")
else
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s610666663
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
num = list(input())
ans = 7
for i in range(2 ** len(num)):
total = 0
ans_num = []
ans_op = []
for j in range(len(num)):
if (i >> j) & 1:
ans_num.append(num[j])
if j >= 1:
ans_op.append("+")
total += int(num[j])
else:
ans_num.append(num[j])
if j >= 1:
ans_op.append("-")
total -= int(num[j])
if total == ans:
print(
ans_num[0]
+ ans_op[0]
+ ans_num[1]
+ ans_op[1]
+ ans_num[2]
+ ans_op[2]
+ ans_num[3]
+ "=7"
)
break
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s225026685
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
###==================================================
### import
# import bisect
# from collections import Counter, deque, defaultdict
# from copy import deepcopy
# from functools import reduce, lru_cache
# from heapq import heappush, heappop
# import itertools
# import math
# import string
import sys
### stdin
def input():
return sys.stdin.readline().rstrip()
def iIn():
return int(input())
def iInM():
return map(int, input().split())
def iInM1():
return map(int1, input().split())
def iInLH():
return list(map(int, input().split()))
def iInLH1():
return list(map(int1, input().split()))
def iInLV(n):
return [iIn() for _ in range(n)]
def iInLV1(n):
return [iIn() - 1 for _ in range(n)]
def iInLD(n):
return [iInLH() for _ in range(n)]
def iInLD1(n):
return [iInLH1() for _ in range(n)]
def sInLH():
return list(input().split())
def sInLV(n):
return [input().rstrip("\n") for _ in range(n)]
def sInLD(n):
return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=" "):
print(deli.join(map(str, lst)))
def OutV(lst):
print("\n".join(map(str, lst)))
### setting
sys.setrecursionlimit(10**6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------
N = input()
bool_1 = N[0] == N[1] and N[1] == N[2]
bool_2 = N[1] == N[2] and N[2] == N[3]
ans = "Yes" if (bool_1 and bool_2) else "No"
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s554316591
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
print(Set(n)==2?'Ye':'No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s549204780
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n=int(input())
print(‘Yes’ if (n//10)%111==0 or (n%1000)%111==0 else ‘No’)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s218998953
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n =list(input())
print(len(set(n))==2?'Yes':'No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s004496283
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
(
a,
b,
c,
d,
) = input()
print("Yes" if "a" == "b" == "c" or "b" == "c" == "d" else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s714993890
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
print(len(set(n))==2?'Yes':'No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s370094615
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = input()
print("Yes" if a[1]==a[2]==a[0] or a[1]==a[2]==a[3], else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s415241299
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a, b, c, d = input().split()
pirnt("Yes") if a == b == c or b == c == d else print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s124060789
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
s = input()
if((t[0:1] == t[1:2] == t[2:3]) or (t[1:2] == t[2:3] == t[3:4]):
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s643765403
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = input()
if len(set(N[1:]) == 1 or len(set(N[:3])) == 1:
print("Yes")
else
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s327674386
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = list(input())
print('Yes' if N[1] == N[2] and (N[0] == N[1] or N[2] == N[3]) else 'No')a
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s050144194
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
A=input()
if A[0]==A[1] and A[1]==A[2]:
print("Yes")
elif if A[1]==A[2] and A[2]==A[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s961581013
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=input()
j_count=0
for i in range(0,3):
if N[i]==N[i+1]:
j_count+=1
if j_count>=2 and N[1]==N[2]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s332195396
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
#79
n=list(input())
if (n[0]n[1]n[2] or n[0]n[2]n[3] or n[0]n[1]n[3] or n[1]n[2]n[3]):
print('Yes')
else:
print('No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s226190022
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
S = input()
if S[0] == S[1] and S[1] == S[2]:
print("Yes")
elif S[1] == S[2] and S[2] == S[3]:
print("Yes)
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s167634185
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
n1 = n // 10
n2 = n % 1000
print("No" if n1 % 111 and n2 % 111 else "Yes")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s256152498
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
slen = len(int(input()))
print("Yes" if slen > 3 else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s800088096
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n = int(input())
a, b = 1, 2
for i in range(n - 1):
a, b = a + b, a
print(a)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s698663427
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = int(input())
L_2 = 2
L_1 = 1
for i in range(N - 1):
K = L_1 + L_2
L_2 = L_1
L_1 = K
print(K)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s674814987
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
num_str = list(str(input()))
num = []
for i in range(4):
num.append(int(num_str[i]))
if num[0] + num[1] + num[2] + num[3] == 7:
print(num[0], "+", num[1], "+", num[2], "+", num[3], "=7", sep="")
elif num[0] - num[1] + num[2] + num[3] == 7:
print(num[0], "-", num[1], "+", num[2], "+", num[3], "=7", sep="")
elif num[0] + num[1] - num[2] + num[3] == 7:
print(num[0], "+", num[1], "-", num[2], "+", num[3], "=7", sep="")
elif num[0] + num[1] + num[2] - num[3] == 7:
print(num[0], "+", num[1], "+", num[2], "-", num[3], "=7", sep="")
elif num[0] - num[1] - num[2] + num[3] == 7:
print(num[0], "-", num[1], "-", num[2], "+", num[3], "=7", sep="")
elif num[0] - num[1] + num[2] - num[3] == 7:
print(num[0], "-", num[1], "+", num[2], "-", num[3], "=7", sep="")
elif num[0] - num[1] - num[2] - num[3] == 7:
print(num[0], "-", num[1], "-", num[2], "-", num[3], "=7", sep="")
elif num[0] + num[1] - num[2] - num[3] == 7:
print(num[0], "+", num[1], "-", num[2], "-", num[3], "=7", sep="")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s259819609
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 4 21:46:51 2018
@author: sk
"""
a = str(input())
char_list = list(a)
if a(0)==a(1):
if a(1)==a(2):
print("Yes")
elif a(1)==a(3):
print("Yes")
else :
print("No")
elif a(1)==a(2):
if a(2)=a(3):
print("Yes")
else :
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s878395778
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = int(input())
if ((a %10 == (a / 10) % 10 ) and (a %10 == (a / 100) % 10) or (((a / 10) %10 == (a / 100) % 10 ) and ((a / 10) %10 == (a / 1000)):
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s044995522
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
def solve():
A, B = map(int, input().split())
if A == B:
ans = "Draw"
else:
if A == 1:
ans = "Alice"
elif B == 1:
ans = "Bob"
elif A > B:
ans = "Alice"
else:
ans = "Bob"
print(ans)
def goodinteger():
inputstr = input()
a = inputstr[0]
b = inputstr[1]
c = inputstr[2]
d = inputstr[3]
count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
i = 0
while i < 10:
numstr = str(i)
if a == numstr:
count[i] += 1
if b == numstr:
count[i] += 1
if c == numstr:
count[i] += 1
if d == numstr:
count[i] += 1
i += 1
# print(i)
i = 0
while i < 10:
# print(i)
if count[i] >= 3:
return True
i += 1
return False
if __name__ == "__main__":
if goodinteger():
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s744688167
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
x = S()
c = 0
ans = "No"
for i in range(len(x)):
for j in range(i,len(x)-i):
if x[i] == x[i + j]:
c += 1
if c = 3:
ans = "Yes"
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s859927165
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
# sys.stdin.readline()
import sys
import math
input = sys.stdin.readline
n = input()
if n.count('0') >= or n.count('1') >= 3 or n.count('2') >= 3 or n.count('3') >= 3 or n.count('4') >= 3 or n.count('5') >= 3 or n.count('6') >= 3 or n.count('7') >= 3 or n.count('8') >= 3 or n.count('9'):
ans = 'Yes'
else:
ans = 'No'
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s111945147
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a=input()
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s457882401
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
s = input()
if s[0]==s[1]=s[2] or s[1]==s[2]==s[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s387013675
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = input()
if len(set(list(str(N))) <= 2:
print('Yes')
else:
print('No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s698842919
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
もうだめだ...
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s395341072
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a, b, c, d = input()
print("Yes if a == b == c or b == c ==d else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s126798466
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print("Yes" if len(set(input())) < 3 else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s017512540
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
x = input()
print(["Yes", "No"][x.count(x[0]) < 3 and x.count(x[1]) < 3])
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s072558971
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print("Yes" if len(set(list(input()))) < 3 else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s902046215
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print('Yes' if len(set(list(input()))))<3 else 'No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s136621821
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = set(int(input()))
if len(N)<=2:
print("Yes")
else:
print("No)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s347043731
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print("YNeos"[len(set(list(input()))) > 2 :: 2])
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s878858151
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a=list(input())
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s993648619
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a=list(int(input()))
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s292593765
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = str(input())
if a[0] = a[1] = a[2] or a[1] = a[2] = a[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s793692586
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = input()
if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
print("Yes")
else:
print("No)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s366714502
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
k = list(input())
ans = "No"
for i in k:
if sum(x == i for x in k) >= 3:
ans = "Yes
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s218296346
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
s = input()
if s[0] == s[1] == s[2] or s[1] == s[2] == s[3]
print('Yes')
else:
print('No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s330434170
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a=input()
if a[0]==a[1] and a[1]==a[2] || a[1]==a[2] and a[2]==a[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s054584771
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n=int(input())
a=n//1000
n=n%1000
b=n//100
n=n%100
c=n//10
d=n%10
if b==c and (a==b or c==d):
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s493896040
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
#-*- coding: utf-8 -*-
N = str(input())
if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s424762677
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = input()
# for i in range(1000,10000):
# print(i)
# N = str(i)
if N[0] == N[1] == N[2] == "1":
print("Yes")
elif N[0] == N[1] == N[2] == "2":
print("Yes")
elif N[0] == N[1] == N[2] == "3":
print("Yes")
elif N[0] == N[1] == N[2] == "4":
print("Yes")
elif N[0] == N[1] == N[2] == "5":
print("Yes")
elif N[0] == N[1] == N[2] == "6":
print("Yes")
elif N[0] == N[1] == N[2] == "7":
print("Yes")
elif N[0] == N[1] == N[2] == "8":
print("Yes")
elif N[0] == N[1] == N[2] == "9":
print("Yes")
elif N[1] == N[2] == N[3] == "0":
print("Yes")
elif N[1] == N[2] == N[3] == "1":
print("Yes")
elif N[1] == N[2] == N[3] == "2":
print("Yes")
elif N[1] == N[2] == N[3] == "3":
print("Yes")
elif N[1] == N[2] == N[3] == "4":
print("Yes")
elif N[1] == N[2] == N[3] == "5":
print("Yes")
elif N[1] == N[2] == N[3] == "6":
print("Yes")
elif N[1] == N[2] == N[3] == "7":
print("Yes")
elif N[1] == N[2] == N[3] == "8":
print("Yes")
elif N[1] == N[2] == N[3] == "9":
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s692691657
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
import sys
sys.setrecursionlimit(10**9)
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 li2(N):
return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j):
return [[ini] * i for i2 in range(j)]
def dp3(ini, i, j, k):
return [[[ini] * i for i2 in range(j)] for i3 in range(k)]
# import bisect #bisect.bisect_left(B, a)
# from collections import defaultdict #d = defaultdict(int) d[key] += value
H, W = mi()
C = li2(10)
a = li2(H)
memo = [C[i][1] for i in range(10)]
"""
tmp = -1
def dfs(column, m):
if column == 1:
global tmp
tmp = max(m, tmp)
for i in range(10):
if i != column and C[column][i] < m:
dfs(i, m-C[column][i])
#return
for i in range(10):
if i != 1:
dfs(i, C[i][1])
if tmp != -1:
memo[i] = C[i][1] - tmp
tmp = -1
"""
INF = 10**9
tmp = 10**9
"""
def dfs(col, m):
if col == 1:
global tmp
tmp = min(m, tmp)
for i in range(10):
if i != col and m + C[col][i] < lim:
dfs(i, m + C[col][i])
for i in range(10):
if i != 1:
tmp = INF
lim = C[i][1]
dfs(i, 0)
memo[i] = min(tmp, memo[i])
"""
from collections import deque
for i in range(10):
que = deque()
lim = C[i][1]
for j in range(10):
if C[i][j] < lim:
que.append([j, C[i][j]])
while que != deque():
# print(que)
k = que.popleft()
for j in range(10):
if C[k[0]][j] + k[1] < lim and k[0] != j:
if j == 1:
memo[i] = min(memo[i], C[k[0]][j] + k[1])
else:
que.append([j, C[k[0]][j] + k[1]])
ans = 0
for i in range(H):
for j in range(W):
if abs(a[i][j]) != 1:
ans += memo[a[i][j]]
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s541999320
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
import math
# グラフの作成
def make_list(V, E):
edges = []
path = [[0] * E for i in range(V)] # ルート作成に必要になる
for i in range(V):
a = list(map(int, input().split()))
for j in range(len(a)):
# print("j",j)
path[i][j] = i
if j != i and a[j] == 0:
a[j] = 30000
path[i][j] = -3000
edges.append((a)) # 有効辺グラフ
return edges, path
def mainasu_sycle(
dist,
): # 負のサイクルがあるか確認する 第一引数: 重みを含む配列 実装を確認していない
for i in range(0, len(dist)):
if dist[i][i] != 0:
print("Negative cycle at : ", i + 1)
# 最短経路をたどる
def ConstructPath(p, i, j):
i, j = int(i), int(j)
print("i,j:", i, j)
if i == j:
print(
i,
)
elif p[i][j] == -30000:
print(i, "-", j)
else:
ConstructPath(p, i, p[i][j])
print(
j,
)
# フロイド・ワーシャル
def warshall_floyd(glath, path):
for k in range(len(glath)):
for i in range(len(glath)):
for j in range(len(glath[i])):
if glath[i][j] > glath[i][k] + glath[k][j]:
glath[i][j] = glath[i][k] + glath[k][j]
path[i][j] = path[k][j]
# glath[i][j]= min(int(glath[i][j]),int(glath[i][k])+int(glath[k][j]))
return glath, path
if __name__ == "__main__":
H, W = [int(x) for x in str(input()).split()] # グラフの大きさ
cost_graph, graph = make_list(10, 10)
wall, wall_graph = make_list(H, W)
un_label = []
for i in wall:
for j in i:
if j != -1 and j != 1:
un_label.append(j)
cost = 0
all_cost, all_graph = warshall_floyd(cost_graph, graph)
for i in un_label:
cost += all_cost[i][1]
print(cost)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s866570689
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
# -*- coding: utf-8 -*-
import itertools
def shortest_path(st, end, n, w, es):
# s→iの最短距離
# st:始点, end:終点, n:頂点数, w:辺の数, es[i]: [辺の始点,辺の終点,辺のコスト]
d = [float("inf")] * n
# d[i] : s→iの最短距離
d[st] = 0
while True:
updata = False
for i in range(w):
e = es[i]
# e: 辺iについて [from,to,cost]
if d[e[0]] != float("inf") and d[e[1]] > d[e[0]] + e[2]:
d[e[1]] = d[e[0]] + e[2]
updata = True
if not updata:
break
if e[1] == end:
break
return d[end]
############入力始まり################
(
input_load_info_num,
input_crossing_info_num,
input_parking_info_num,
input_delivery_info_num,
input_query_info_num,
) = map(int, input().split())
# 道路情報数:input_load_info_num
# 交差点情報数:input_crossing_info_num
# 駐車可能箇所情報数:input_parking_info_num
# 配達先情報数:input_delivery_info_num
# クエリ件数:input_query_info_num
input_load_info = [[] for i in range(input_load_info_num)]
input_crossing_info = [[] for i in range(input_crossing_info_num)]
input_parking_info = [[] for i in range(input_parking_info_num)]
input_delivery_info = [[] for i in range(input_delivery_info_num)]
input_query_info = [[] for i in range(input_query_info_num)]
# 入力・道路情報:input_load_info
# 入力・交差点情報:input_crossing_info
# 入力・駐車可能箇所情報:input_parking_info
# 入力・配達先情報:input_delivery_info
# 入力・クエリ:input_query_info
for i in range(input_load_info_num):
x, y, z = input().split()
input_load_info[i] = [x, y, z]
for i in range(input_crossing_info_num):
x, y, z = input().split()
input_crossing_info[i] = [x, y, z]
for i in range(input_parking_info_num):
x, y, z = input().split()
input_parking_info[i] = [x, y, z]
for i in range(input_delivery_info_num):
x, y, z = input().split()
input_delivery_info[i] = [x, y, z]
for i in range(input_query_info_num):
x, y, z = input().split()
input_query_info[i] = [x, y, z]
############入力終わり################
###########車両での走行グラフ:始まり#####################
node = 0
car_node = []
# [名前,ノード]
# [R00SE-S,node]->R00のSE方向時のS
car_graph = []
# [開始ノード, 終了ノード, 距離]
car_load_info = []
# [道(SE or ES),距離,開始ノード,終了ノード]
for i in range(input_load_info_num):
car_load_info.append(
[input_load_info[i][0] + "SE", int(input_load_info[i][1]), node, node + 1]
)
car_node.append([input_load_info[i][0] + "SE-S", node])
car_node.append([input_load_info[i][0] + "SE-E", node + 1])
node += 2
if int(input_load_info[i][2]) == 0:
car_load_info.append(
[input_load_info[i][0] + "ES", int(input_load_info[i][1]), node, node + 1]
)
car_node.append([input_load_info[i][0] + "ES-E", node])
car_node.append([input_load_info[i][0] + "ES-S", node + 1])
node += 2
for i in range(len(car_load_info)):
making_point_info = []
# [Sからの距離,ポイント名,ノード番号]
load = car_load_info[i][0]
if "SE" in load:
making_point_info.append([0, car_load_info[i][0] + "-S", car_load_info[i][2]])
# 道路のS地点
for j in range(input_parking_info_num):
if (
load == input_parking_info[j][1] + "SE"
and "SE" in input_parking_info[j][0]
):
making_point_info.append(
[int(input_parking_info[j][2]), input_parking_info[j][0], node]
)
car_node.append([input_parking_info[j][0], node])
node += 1
making_point_info.append(
[car_load_info[i][1], car_load_info[i][0] + "-E", car_load_info[i][3]]
)
# 道路のE地点
making_point_info.sort()
for j in range(len(making_point_info) - 1):
w = making_point_info[j + 1][0] - making_point_info[j][0]
car_graph.append([making_point_info[j][2], making_point_info[j + 1][2], w])
if "ES" in load:
making_point_info.append(
[car_load_info[i][1], car_load_info[i][0] + "-E", car_load_info[i][2]]
)
# 道路のE地点
for j in range(input_parking_info_num):
if (
load == input_parking_info[j][1] + "ES"
and "ES" in input_parking_info[j][0]
):
making_point_info.append(
[int(input_parking_info[j][2]), input_parking_info[j][0], node]
)
car_node.append([input_parking_info[j][0], node])
node += 1
making_point_info.append([0, car_load_info[i][0] + "-S", car_load_info[i][3]])
# 道路のE地点
making_point_info.sort(reverse=True)
# print(making_point_info)
for j in range(len(making_point_info) - 1):
w = making_point_info[j][0] - making_point_info[j + 1][0]
car_graph.append([making_point_info[j][2], making_point_info[j + 1][2], w])
for i in range(input_crossing_info_num):
load1 = input_crossing_info[i][1] # in
load2 = input_crossing_info[i][2] # out
for j in range(len(car_load_info)):
if load1 == car_load_info[j][0]:
point1 = car_load_info[j][3]
if load2 == car_load_info[j][0]:
point2 = car_load_info[j][2]
car_graph.append([point1, point2, 0])
# print(car_load_info)
# print(car_graph)
# print(car_node)
###########車両での走行グラフ:終わり#####################
for i in range(input_query_info_num):
s_point = input_query_info[i][1]
e_point = input_query_info[i][2]
if int(input_query_info[i][0]) == 0:
for j in range(len(car_node)):
if car_node[j][0] == s_point:
s_node = car_node[j][1]
if car_node[j][0] == e_point:
e_node = car_node[j][1]
print(shortest_path(s_node, e_node, len(car_node), len(car_graph), car_graph))
if int(input_query_info[i][0]) == 1:
print("100")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s781086255
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a,b,c,d = list(input())
#print(b)
if a==b==c or b==c==d:
print("Yes")
else:
print("No
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s467284669
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
num = int(input())
x = []
x.append(num // 1000)
num = num % 1000
x.append(num // 100)
num = num % 100
x.append(num // 10)
num = num % 10
x.append(num)
if (x[0] == x[1] and x[1] == x[2]) or (x[1] == x[2] and x[2] == x[3]):
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s164979974
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
# -*- coding: utf-8 -*-
def arraycount(arr):
arr_target = [[]]
cnt = 1
for i in range(1, len(arr)):
if arr[i] == arr[i - 1]:
cnt += 1
else:
arr_target.append([arr[i - 1], cnt])
cnt = 1
arr_target.append([arr[len(arr) - 1], cnt])
del arr_target[0]
return arr_target
def digit_list(num):
num = str(num)
num = list(num)
num = list(map(int, num))
return num
n = int(input())
a = arraycount(digit_list(n))
for i in range(len(a)):
a[i][0], a[i][1] = a[i][1], a[i][0]
a.sort()
a.reverse()
if a[0][0] >= 3:
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s399940754
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
i = int(input())
lst = []
while i > 0:
lst.append(i % 10)
i //= 10
lst.reverse()
a = lst[0]
b = lst[1]
c = lst[2]
d = lst[3]
sa = str(a)
sb = str(b)
sc = str(c)
sd = str(d)
if a + b + c + d == 7:
print(sa + "+" + sb + "+" + sc + "+" + sd + "=7")
elif a + b + c - d == 7:
print(sa + "+" + sb + "+" + sc + "-" + sd + "=7")
elif a + b - c + d == 7:
print(sa + "+" + sb + "-" + sc + "+" + sd + "=7")
elif a - b + c + d == 7:
print(sa + "-" + sb + "+" + sc + "+" + sd + "=7")
elif a - b - c + d == 7:
print(sa + "-" + sb + "-" + sc + "+" + sd + "=7")
elif a - b + c - d == 7:
print(sa + "-" + sb + "+" + sc + "-" + sd + "=7")
elif a + b - c - d == 7:
print(sa + "+" + sb + "-" + sc + "-" + sd + "=7")
elif a - b - c - d == 7:
print(sa + "-" + sb + "-" + sc + "-" + sd + "=7")
else:
print("none")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s944455839
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
h, w = map(int, input().split(" "))
tbl = [list(map(int, input().split(" "))) for i in range(10)]
tbli = list(zip(*tbl))
cost = [10**18] * 10
cost[1] = 0
sorttool = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
order = list(zip(tbli[1], sorttool))
order.sort()
del order[0]
for i, (c, x) in enumerate(order):
cost[x] = min(cost[x], tbli[1][x])
if i == 0:
continue
for j in range(i):
cost[x] = min(cost[x], cost[order[j][1]] + tbli[order[j][1]][x])
cost.append(0)
wall = [list(map(int, input().split(" "))) for i in range(h)]
ans = 0
for i in range(h):
for j in range(w):
ans += cost[wall[i][j]]
print(ans)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s296183574
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print("Yes" if len(set(input()[:3])) == 1 or len(set(input()[1:])) == 1 else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s978464739
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print("Yes")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s537121218
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = input()
print("Yes" if a[0]==a[1]==a[2] or a[3]==a[1]==a[2] "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s810641912
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
print(['Yes','No'][len(set(input())<3])
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s870716270
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
n=input()
print("Yes" if n[0]==n[1]==n[2] elif n[3]==n[1]==n[2] else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s354572153
|
Accepted
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = list(map(int, list(input())))
print("Yes" if a[0] == a[1] and a[1] == a[2] or a[3] == a[1] and a[1] == a[2] else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s594146106
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=input()
res=0
for in range(1:10):
if N.count("i")>=3:
res+=1
print("Yes")
if res==0:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s114668297
|
Wrong Answer
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = list(input())
ans = -1
for n in N:
ans = max(ans, N.count(n))
print("Yes" if 3 <= ans else "No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s736756778
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N = input()
if len(set(N[0:2])) == 1 || len(set(N[1:3])):
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s343298307
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=input()
answer="No"
for i in range(len(N)-2)
if N[i]==N[i+1]:
if N[i+1]==N[i+2]:
answer="Yes"
print(answer)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s169064376
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = list(input())
if ((a[0] == a[1]) and (a[1] == a[2])) or ((a[1] == a[2]) and (a[2] == a[3]))
print("Yes")
else:
print("No")
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s732742548
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=input();c=0
for n in range(len(N)-1):
if N[n]==N[n+1]:
c+=1
else:
c=0
if c>=3:
print('Yes')
exit()
print('No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s142784807
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
N=list(input())
answer="no"
for i in range(len(N)-2)
if N[i]==N[i+1]:
if N[i+1]==N[i+2]:
if N[i+2]==N[i+3]:
answer="yes"
print(answer)
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If N is **good** , print `Yes`; otherwise, print `No`.
* * *
|
s476977462
|
Runtime Error
|
p03543
|
Input is given from Standard Input in the following format:
N
|
a = int(input())
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] a[0]==a[1]==a[2]==a[3]:
print('Yes')
else:
print('No')
|
Statement
We call a 4-digit integer with three or more consecutive same digits, such as
1118, **good**.
You are given a 4-digit integer N. Answer the question: Is N **good**?
|
[{"input": "1118", "output": "Yes\n \n\nN is **good** , since it contains three consecutive 1.\n\n* * *"}, {"input": "7777", "output": "Yes\n \n\nAn integer is also **good** when all the digits are the same.\n\n* * *"}, {"input": "1234", "output": "No"}]
|
If the answer is no, print a single `-1`.
Otherwise, print one possible move of Snuke in the following format:
Q
x_1 x_2 \cdots x_Q
It means that he opens boxes x_1, x_2, \cdots, x_Q in this order.
In case there are multiple possible solutions, you can output any.
* * *
|
s815537725
|
Wrong Answer
|
p03113
|
Input is given from Standard Input in the following format:
N K
a_1 a_2 \cdots a_N
|
import sys
import numpy as np
sys.setrecursionlimit(10**9)
INF = 10**18
def input():
return sys.stdin.readline().rstrip()
def main():
N, K = map(int, input().split())
a = list(map(int, input().split()))
a_i = list(map(lambda x: x + 1, np.argsort(a)))
ans = (N - 1) * (K + 1) + 1
if (
a[a_i[0] - 1] < ans // N
or a[a_i[N - (ans % N if ans % N != 0 else N)] - 1] < ans // N + 1
):
print(-1)
quit()
print(ans)
s = " ".join(list(map(str, list(reversed(a_i))))) + " "
s2 = " ".join(list(map(str, list(reversed(a_i))))[: ans % N if ans % N != 0 else N])
print(s * (ans // N) + s2)
if __name__ == "__main__":
main()
|
Statement
Snuke participated in a magic show.
A magician prepared N identical-looking boxes. He put a treasure in one of the
boxes, closed the boxes, shuffled them, and numbered them 1 through N.
Since the boxes are shuffled, now Snuke has no idea which box contains the
treasure. Snuke wins the game if he opens a box containing the treasure. You
may think that if Snuke opens all boxes at once, he can always win the game.
However, there are some tricks:
* Snuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.
* He is only allowed to open Box i at most a_i times.
* The magician may secretly move the treasure from a closed box to another closed box, using some magic trick. For simplicity, assume that the magician never moves the treasure while Snuke is opening some box. However, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).
* The magician can perform the magic trick at most K times.
Can Snuke always win the game, regardless of the initial position of the
treasure and the movements of the magician?
|
[{"input": "2 1\n 5 5", "output": "7\n 1 1 2 1 2 2 1\n \n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2\n\\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find\nthe treasure regardless of its initial position and the movements of the\nmagician.\n\n* * *"}, {"input": "3 50\n 5 10 15", "output": "-1"}]
|
If the answer is no, print a single `-1`.
Otherwise, print one possible move of Snuke in the following format:
Q
x_1 x_2 \cdots x_Q
It means that he opens boxes x_1, x_2, \cdots, x_Q in this order.
In case there are multiple possible solutions, you can output any.
* * *
|
s830098634
|
Wrong Answer
|
p03113
|
Input is given from Standard Input in the following format:
N K
a_1 a_2 \cdots a_N
|
# coding:utf-8
import sys
# from collections import Counter, defaultdict
INF = float("inf")
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return input()
n, k = LI()
A = LI()
print(-1)
|
Statement
Snuke participated in a magic show.
A magician prepared N identical-looking boxes. He put a treasure in one of the
boxes, closed the boxes, shuffled them, and numbered them 1 through N.
Since the boxes are shuffled, now Snuke has no idea which box contains the
treasure. Snuke wins the game if he opens a box containing the treasure. You
may think that if Snuke opens all boxes at once, he can always win the game.
However, there are some tricks:
* Snuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.
* He is only allowed to open Box i at most a_i times.
* The magician may secretly move the treasure from a closed box to another closed box, using some magic trick. For simplicity, assume that the magician never moves the treasure while Snuke is opening some box. However, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).
* The magician can perform the magic trick at most K times.
Can Snuke always win the game, regardless of the initial position of the
treasure and the movements of the magician?
|
[{"input": "2 1\n 5 5", "output": "7\n 1 1 2 1 2 2 1\n \n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2\n\\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find\nthe treasure regardless of its initial position and the movements of the\nmagician.\n\n* * *"}, {"input": "3 50\n 5 10 15", "output": "-1"}]
|
If the answer is no, print a single `-1`.
Otherwise, print one possible move of Snuke in the following format:
Q
x_1 x_2 \cdots x_Q
It means that he opens boxes x_1, x_2, \cdots, x_Q in this order.
In case there are multiple possible solutions, you can output any.
* * *
|
s257197278
|
Wrong Answer
|
p03113
|
Input is given from Standard Input in the following format:
N K
a_1 a_2 \cdots a_N
|
print(2, 1, 2)
|
Statement
Snuke participated in a magic show.
A magician prepared N identical-looking boxes. He put a treasure in one of the
boxes, closed the boxes, shuffled them, and numbered them 1 through N.
Since the boxes are shuffled, now Snuke has no idea which box contains the
treasure. Snuke wins the game if he opens a box containing the treasure. You
may think that if Snuke opens all boxes at once, he can always win the game.
However, there are some tricks:
* Snuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.
* He is only allowed to open Box i at most a_i times.
* The magician may secretly move the treasure from a closed box to another closed box, using some magic trick. For simplicity, assume that the magician never moves the treasure while Snuke is opening some box. However, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).
* The magician can perform the magic trick at most K times.
Can Snuke always win the game, regardless of the initial position of the
treasure and the movements of the magician?
|
[{"input": "2 1\n 5 5", "output": "7\n 1 1 2 1 2 2 1\n \n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2\n\\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find\nthe treasure regardless of its initial position and the movements of the\nmagician.\n\n* * *"}, {"input": "3 50\n 5 10 15", "output": "-1"}]
|
If the answer is no, print a single `-1`.
Otherwise, print one possible move of Snuke in the following format:
Q
x_1 x_2 \cdots x_Q
It means that he opens boxes x_1, x_2, \cdots, x_Q in this order.
In case there are multiple possible solutions, you can output any.
* * *
|
s914377228
|
Wrong Answer
|
p03113
|
Input is given from Standard Input in the following format:
N K
a_1 a_2 \cdots a_N
|
print("3\n1 2 1")
|
Statement
Snuke participated in a magic show.
A magician prepared N identical-looking boxes. He put a treasure in one of the
boxes, closed the boxes, shuffled them, and numbered them 1 through N.
Since the boxes are shuffled, now Snuke has no idea which box contains the
treasure. Snuke wins the game if he opens a box containing the treasure. You
may think that if Snuke opens all boxes at once, he can always win the game.
However, there are some tricks:
* Snuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.
* He is only allowed to open Box i at most a_i times.
* The magician may secretly move the treasure from a closed box to another closed box, using some magic trick. For simplicity, assume that the magician never moves the treasure while Snuke is opening some box. However, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).
* The magician can perform the magic trick at most K times.
Can Snuke always win the game, regardless of the initial position of the
treasure and the movements of the magician?
|
[{"input": "2 1\n 5 5", "output": "7\n 1 1 2 1 2 2 1\n \n\nIf Snuke opens the boxes 7 times in the order 1 \\rightarrow 1 \\rightarrow 2\n\\rightarrow 1 \\rightarrow 2 \\rightarrow 2 \\rightarrow 1, he can always find\nthe treasure regardless of its initial position and the movements of the\nmagician.\n\n* * *"}, {"input": "3 50\n 5 10 15", "output": "-1"}]
|
Print the answer.
* * *
|
s983325148
|
Runtime Error
|
p03406
|
Input is given from Standard Input in the following format:
N M
A_1 A_2 ... A_M
|
def cmb(n, r, mod): # コンビネーションの高速計算
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
N = 10**5
g1 = [1] * (N + 1) # 元テーブル
g2 = [1] * (N + 1) # 逆元テーブル
inverse = [1] * (N + 1) # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1[i] = (g1[i - 1] * i) % mod
inverse[i] = (-inverse[mod % i] * (mod // i)) % mod
g2[i] = (g2[i - 1] * inverse[i]) % mod
inverse[0] = 0
N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))
start = time.time()
dp = [[0 for i in range(2**N)] for j in range(M + 1)]
dp[0][0] = g1[2**N - 1]
for i in range(1, M + 1):
for j in range(2**N):
dp[i][j] = dp[i - 1][j]
for k in range(N):
if j >> k & 1 == 0 and 2**N - A[i] - j >= 2**k - 1:
dp[i][j] = (
dp[i][j]
+ (
(-1)
* (
(g1[2**N - A[i] - j] * g2[2**N - A[i] + 1 - (j + 2**k)])
% mod
)
* ((dp[i - 1][j + 2**k] + g1[2**N - 1 - j - 2**k]) * 2**k)
% mod
)
% mod
) % mod
# for i in range(M+1):
# print(dp[i])
print((dp[M][0] * pow(2, N, mod)) % mod)
|
Statement
There are 2^N players, numbered 1, 2, ..., 2^N. They decided to hold a
tournament.
The tournament proceeds as follows:
* Choose a permutation of 1, 2, ..., 2^N: p_1, p_2, ..., p_{2^N}.
* The players stand in a row in the order of Player p_1, Player p_2, ..., Player p_{2^N}.
* Repeat the following until there is only one player remaining in the row:
* Play the following matches: the first player in the row versus the second player in the row, the third player versus the fourth player, and so on. The players who lose leave the row. The players who win stand in a row again, preserving the relative order of the players.
* The last player who remains in the row is the champion.
It is known that, the result of the match between two players can be written
as follows, using M integers A_1, A_2, ..., A_M given as input:
* When y = A_i for some i, the winner of the match between Player 1 and Player y (2 \leq y \leq 2^N) will be Player y.
* When y \neq A_i for every i, the winner of the match between Player 1 and Player y (2 \leq y \leq 2^N) will be Player 1.
* When 2 \leq x < y \leq 2^N, the winner of the match between Player x and Player y will be Player x.
The champion of this tournament depends only on the permutation p_1, p_2, ...,
p_{2^N} chosen at the beginning. Find the number of permutation p_1, p_2, ...,
p_{2^N} chosen at the beginning of the tournament that would result in Player
1 becoming the champion, modulo 10^9 + 7.
|
[{"input": "2 1\n 3", "output": "8\n \n\nExamples of p that satisfy the condition are: [1, 4, 2, 3] and [3, 2, 1, 4].\nExamples of p that do not satisfy the condition are: [1, 2, 3, 4] and [1, 3,\n2, 4].\n\n* * *"}, {"input": "4 3\n 2 4 6", "output": "0\n \n\n* * *"}, {"input": "3 0", "output": "40320\n \n\n* * *"}, {"input": "3 3\n 3 4 7", "output": "2688\n \n\n* * *"}, {"input": "16 16\n 5489 5490 5491 5492 5493 5494 5495 5497 18993 18995 18997 18999 19000 19001 19002 19003", "output": "816646464"}]
|
Print the complexity of the given grid.
* * *
|
s046860173
|
Accepted
|
p03056
|
Input is given from Standard Input in the following format:
H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}
|
H, W = map(int, input().split())
A = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]
X = [[[-2] * (H + 2) for _ in range(W + 2)] for _ in range(H + 2)]
Y = [[[-2] * (W + 2) for _ in range(W + 2)] for _ in range(H + 2)]
for i in range(H):
Xi = X[i]
Yi = Y[i]
for j in range(W):
Xi[j][i] = j
Yi[j][j] = i
for i in range(H):
Xi = X[i]
Ai = A[i]
for j in range(W - 1)[::-1]:
if Ai[j] == Ai[j + 1]:
Xi[j][i] = Xi[j + 1][i]
for i in range(H - 1)[::-1]:
Yi = Y[i]
Yi1 = Y[i + 1]
Ai = A[i]
Ai1 = A[i + 1]
for j in range(W):
if Ai[j] == Ai1[j]:
Yi[j][j] = Yi1[j][j]
for i in range(H):
Xi = X[i]
Ai = A[i]
for j in range(W):
Xij = Xi[j]
for ii in range(i + 1, H):
if A[ii][j] != Ai[j]:
break
Xij[ii] = min(Xij[ii - 1], X[ii][j][ii])
for i in range(H):
Yi = Y[i]
Ai = A[i]
for j in range(W):
Yij = Yi[j]
for jj in range(j + 1, W):
if Ai[jj] != Ai[j]:
break
Yij[jj] = min(Yij[jj - 1], Yi[jj][jj])
for k in range(16):
if X[0][0][H - 1] == W - 1:
print(k)
break
elif k == 15:
print(16)
break
for i in range(H):
Xi = X[i]
Yi = Y[i]
for j in range(W):
Xij = Xi[j]
Yij = Yi[j]
for ii in range(i, H):
Xijii = Xij[ii]
if Xijii >= 0 and X[i][Xijii + 1][ii] >= 0:
Xij[ii] = X[i][Xijii + 1][ii]
for jj in range(j, W):
Yijjj = Yij[jj]
if Yijjj >= 0 and Y[Yijjj + 1][j][jj] >= 0:
Yij[jj] = Y[Yijjj + 1][j][jj]
jj = W - 1
for ii in range(i, H):
while jj >= j and Yij[jj] < ii:
jj -= 1
if j <= jj > Xij[ii]:
Xij[ii] = jj
ii = H - 1
for jj in range(j, W):
while ii >= i and Xij[ii] < jj:
ii -= 1
if i <= ii > Yij[jj]:
Yij[jj] = ii
|
Statement
**Note the unusual memory limit.**
For a rectangular grid where each square is painted white or black, we define
its **complexity** as follows:
* If all the squares are black or all the squares are white, the complexity is 0.
* Otherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \max(c_1, c_2) in those divisions. The complexity of the grid is m+1.
You are given a grid with H horizontal rows and W vertical columns where each
square is painted white or black. HW characters from A_{11} to A_{HW}
represent the colors of the squares. A_{ij} is `#` if the square at the i-th
row from the top and the j-th column from the left is black, and A_{ij} is `.`
if that square is white.
Find the complexity of the given grid.
|
[{"input": "3 3\n ...\n .##\n .##", "output": "2\n \n\nLet us divide the grid by the boundary line between the first and second\ncolumns. The subgrid consisting of the first column has the complexity of 0,\nand the subgrid consisting of the second and third columns has the complexity\nof 1, so the whole grid has the complexity of at most 2.\n\n* * *"}, {"input": "6 7\n .####.#\n #....#.\n #....#.\n #....#.\n .####.#\n #....##", "output": "4"}]
|
Print the complexity of the given grid.
* * *
|
s643929770
|
Runtime Error
|
p03056
|
Input is given from Standard Input in the following format:
H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}
|
H, W = map(int, input().split())
A_list = [[0] * W for _ in range(H)]
for h in range(H):
s = list(input())
for w in range(W):
if s[w] == "#":
A_list[h][w] = 1
entropie_list = [
[[[-1] * (W + 1) for _ in range(W + 1)] for _ in range(H + 1)] for _ in range(H + 1)
]
def entropie(p, q, r, s):
# p, q : H
# r, s : W
if entropie_list[p][q][r][s] != -1:
return entropie_list[p][q][r][s]
S = sum([sum([A_list[h][w] for h in range(p, q)]) for w in range(r, s)])
if S == 0:
entropie_list[p][q][r][s] = 0
return 0
elif S == (q - p) * (s - r):
entropie_list[p][q][r][s] = 0
return 0
else:
if p + 1 == q:
res_1 = 100000000
else:
res_1 = min(
[
max(entropie(p, u, r, s), entropie(u, q, r, s)) + 1
for u in range(p + 1, q)
]
)
if r + 1 == s:
res_2 = 100000000
else:
res_2 = min(
[
max(entropie(p, q, r, v), entropie(p, q, v, s)) + 1
for v in range(r + 1, s)
]
)
res = min(res_1, res_2)
entropie_list[p][q][r][s] = res
return res
print(entropie(0, H, 0, W))
|
Statement
**Note the unusual memory limit.**
For a rectangular grid where each square is painted white or black, we define
its **complexity** as follows:
* If all the squares are black or all the squares are white, the complexity is 0.
* Otherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \max(c_1, c_2) in those divisions. The complexity of the grid is m+1.
You are given a grid with H horizontal rows and W vertical columns where each
square is painted white or black. HW characters from A_{11} to A_{HW}
represent the colors of the squares. A_{ij} is `#` if the square at the i-th
row from the top and the j-th column from the left is black, and A_{ij} is `.`
if that square is white.
Find the complexity of the given grid.
|
[{"input": "3 3\n ...\n .##\n .##", "output": "2\n \n\nLet us divide the grid by the boundary line between the first and second\ncolumns. The subgrid consisting of the first column has the complexity of 0,\nand the subgrid consisting of the second and third columns has the complexity\nof 1, so the whole grid has the complexity of at most 2.\n\n* * *"}, {"input": "6 7\n .####.#\n #....#.\n #....#.\n #....#.\n .####.#\n #....##", "output": "4"}]
|
Print the complexity of the given grid.
* * *
|
s224306725
|
Wrong Answer
|
p03056
|
Input is given from Standard Input in the following format:
H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}
|
print(1)
|
Statement
**Note the unusual memory limit.**
For a rectangular grid where each square is painted white or black, we define
its **complexity** as follows:
* If all the squares are black or all the squares are white, the complexity is 0.
* Otherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \max(c_1, c_2) in those divisions. The complexity of the grid is m+1.
You are given a grid with H horizontal rows and W vertical columns where each
square is painted white or black. HW characters from A_{11} to A_{HW}
represent the colors of the squares. A_{ij} is `#` if the square at the i-th
row from the top and the j-th column from the left is black, and A_{ij} is `.`
if that square is white.
Find the complexity of the given grid.
|
[{"input": "3 3\n ...\n .##\n .##", "output": "2\n \n\nLet us divide the grid by the boundary line between the first and second\ncolumns. The subgrid consisting of the first column has the complexity of 0,\nand the subgrid consisting of the second and third columns has the complexity\nof 1, so the whole grid has the complexity of at most 2.\n\n* * *"}, {"input": "6 7\n .####.#\n #....#.\n #....#.\n #....#.\n .####.#\n #....##", "output": "4"}]
|
Print the complexity of the given grid.
* * *
|
s242221369
|
Wrong Answer
|
p03056
|
Input is given from Standard Input in the following format:
H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}
|
h, w = map(int, input().split())
f = [input() for _ in [0] * h]
rc = 0
for r1, r2 in zip(f, f[1:]):
if r1 != r2:
rc += 1
ft = list(map("".join, zip(f)))
cc = 0
for r1, r2 in zip(ft, ft[1:]):
if r1 != r2:
cc += 1
ans = 0
while rc > 0 or cc > 0:
if rc > cc:
rc = rc // 2
else:
cc = cc // 2
ans += 1
print(ans)
|
Statement
**Note the unusual memory limit.**
For a rectangular grid where each square is painted white or black, we define
its **complexity** as follows:
* If all the squares are black or all the squares are white, the complexity is 0.
* Otherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \max(c_1, c_2) in those divisions. The complexity of the grid is m+1.
You are given a grid with H horizontal rows and W vertical columns where each
square is painted white or black. HW characters from A_{11} to A_{HW}
represent the colors of the squares. A_{ij} is `#` if the square at the i-th
row from the top and the j-th column from the left is black, and A_{ij} is `.`
if that square is white.
Find the complexity of the given grid.
|
[{"input": "3 3\n ...\n .##\n .##", "output": "2\n \n\nLet us divide the grid by the boundary line between the first and second\ncolumns. The subgrid consisting of the first column has the complexity of 0,\nand the subgrid consisting of the second and third columns has the complexity\nof 1, so the whole grid has the complexity of at most 2.\n\n* * *"}, {"input": "6 7\n .####.#\n #....#.\n #....#.\n #....#.\n .####.#\n #....##", "output": "4"}]
|
Print the complexity of the given grid.
* * *
|
s336030665
|
Wrong Answer
|
p03056
|
Input is given from Standard Input in the following format:
H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}
|
def complexity(H: int, W: int, A: list) -> int:
if H == 1:
# 1 行のものは、白ますの連続領域と黒ますの連続領域を
# n 個とすると [n/2] が複雑さとなる。
part = 1
c = A[0][0]
for a in A[0]:
if a != c:
part += 1
c = a
return part // 2
else:
# 同じ行を圧縮する。
complexities = []
s = A[0]
h = 0
while h < H:
s = A[h]
while h + 1 < H and s == A[h + 1]:
h += 1
complexities.append(complexity(1, W, [s]))
h += 1
def sum_bin(l: int, r: int) -> int:
if l == r:
return -1
if l + 1 == r:
return complexities[l]
return max(sum_bin(l, (l + r) // 2), sum_bin((l + r) // 2, r)) + 1
return sum_bin(0, len(complexities))
if __name__ == "__main__":
H = 0
H, W = map(int, input().split())
A = [input() for _ in range(H)]
ans = complexity(H, W, A)
print(ans)
|
Statement
**Note the unusual memory limit.**
For a rectangular grid where each square is painted white or black, we define
its **complexity** as follows:
* If all the squares are black or all the squares are white, the complexity is 0.
* Otherwise, divide the grid into two subgrids by a line parallel to one of the sides of the grid, and let c_1 and c_2 be the complexities of the subgrids. There can be multiple ways to perform the division, and let m be the minimum value of \max(c_1, c_2) in those divisions. The complexity of the grid is m+1.
You are given a grid with H horizontal rows and W vertical columns where each
square is painted white or black. HW characters from A_{11} to A_{HW}
represent the colors of the squares. A_{ij} is `#` if the square at the i-th
row from the top and the j-th column from the left is black, and A_{ij} is `.`
if that square is white.
Find the complexity of the given grid.
|
[{"input": "3 3\n ...\n .##\n .##", "output": "2\n \n\nLet us divide the grid by the boundary line between the first and second\ncolumns. The subgrid consisting of the first column has the complexity of 0,\nand the subgrid consisting of the second and third columns has the complexity\nof 1, so the whole grid has the complexity of at most 2.\n\n* * *"}, {"input": "6 7\n .####.#\n #....#.\n #....#.\n #....#.\n .####.#\n #....##", "output": "4"}]
|
Print the intensity A{'}_i of each bulb i after the K operations to Standard
Output in the following format:
A{'}_1 A{'}_2 \ldots A{'}_N
* * *
|
s739072632
|
Accepted
|
p02647
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \ldots A_N
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, k = map(int, readline().split())
A = list(map(int, readline().split()))
class SegmentTree:
def __init__(self, n, ele, segfun):
#####単位元######要設定0or1orinf
self.ide_ele = ele
self.segfun = segfun
####################
self.n = n
self.N0 = 1 << n.bit_length()
self.data = [self.ide_ele] * (self.N0 * 2)
def update_add(self, l, r, val):
l += self.N0
r += self.N0
while l < r:
if l & 1:
self.data[l] += val
l += 1
if r & 1:
self.data[r - 1] += val
r -= 1
l //= 2
r //= 2
def update(self, l, r, val):
l += self.N0
r += self.N0
while l < r:
if l & 1:
self.data[l] = self.segfun(self.data[l], val)
l += 1
if r & 1:
self.data[r - 1] = self.segfun(self.data[r - 1], val)
r -= 1
l //= 2
r //= 2
def query(self, i):
i += len(self.data) // 2
ret = self.data[i]
while i > 0:
i //= 2
ret = self.segfun(ret, self.data[i])
return ret
for i in range(k):
m = n
S = SegmentTree(n, 0, lambda a, b: a + b)
for j in range(n):
q = A[j]
m = min(m, q)
S.update_add(max(1, j - q + 1), min(n + 1, j + q + 2), 1)
if i < k - 1 and m >= n - 1:
A = [n] * n
break
for l in range(n):
p = S.query(l + 1)
A[l] = p
print(*A)
|
Statement
We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.
Each bulb has a non-negative integer parameter called intensity. When there is
a bulb of intensity d at coordinate x, the bulb illuminates the segment from
coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We
will now do the following operation K times in a row:
* For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.
Find the intensity of each bulb after the K operations.
|
[{"input": "5 1\n 1 0 0 1 0", "output": "1 2 2 1 2 \n \n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1\nbecomes 1 after the operation. Similarly, the bulbs initially illuminating\ncoordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\n* * *"}, {"input": "5 2\n 1 0 0 1 0", "output": "3 3 4 4 3"}]
|
Print the intensity A{'}_i of each bulb i after the K operations to Standard
Output in the following format:
A{'}_1 A{'}_2 \ldots A{'}_N
* * *
|
s309869949
|
Wrong Answer
|
p02647
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \ldots A_N
|
N, K = map(int, input().split())
list = list(map(int, input().split()))
l = len(list)
rlist = [0] * l
for i in range(0, K):
j = 0
for j in range(0, l):
rlist[j] = rlist[j] + 1
a = list[j]
k = 1
while k <= a:
if 0 <= j - k:
rlist[j - k] = rlist[j - k] + 1
if j + k < l:
rlist[j + k] = rlist[j + k] + 1
k += 1
list = rlist
rlist = [0] * l
print(list)
|
Statement
We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.
Each bulb has a non-negative integer parameter called intensity. When there is
a bulb of intensity d at coordinate x, the bulb illuminates the segment from
coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We
will now do the following operation K times in a row:
* For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.
Find the intensity of each bulb after the K operations.
|
[{"input": "5 1\n 1 0 0 1 0", "output": "1 2 2 1 2 \n \n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1\nbecomes 1 after the operation. Similarly, the bulbs initially illuminating\ncoordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\n* * *"}, {"input": "5 2\n 1 0 0 1 0", "output": "3 3 4 4 3"}]
|
Print the intensity A{'}_i of each bulb i after the K operations to Standard
Output in the following format:
A{'}_1 A{'}_2 \ldots A{'}_N
* * *
|
s417715763
|
Wrong Answer
|
p02647
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \ldots A_N
|
x, n = map(int, input().split())
if n == 0:
print(x)
elif n == 100:
ff = 101 - x
gg = x
if ff < gg:
print(101)
else:
print(0)
else:
p = list(map(int, input().split()))
if not (x in p):
print(x)
else:
m = [i for i in range(1, 101)]
for i in range(len(m)):
if m[i] in p:
m[i] = 10000
else:
m[i] = abs(x - m[i])
print(m.index(min(m)) + 1)
|
Statement
We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.
Each bulb has a non-negative integer parameter called intensity. When there is
a bulb of intensity d at coordinate x, the bulb illuminates the segment from
coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We
will now do the following operation K times in a row:
* For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.
Find the intensity of each bulb after the K operations.
|
[{"input": "5 1\n 1 0 0 1 0", "output": "1 2 2 1 2 \n \n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1\nbecomes 1 after the operation. Similarly, the bulbs initially illuminating\ncoordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\n* * *"}, {"input": "5 2\n 1 0 0 1 0", "output": "3 3 4 4 3"}]
|
Print the intensity A{'}_i of each bulb i after the K operations to Standard
Output in the following format:
A{'}_1 A{'}_2 \ldots A{'}_N
* * *
|
s306103632
|
Wrong Answer
|
p02647
|
Input is given from Standard Input in the following format:
N K
A_1 A_2 \ldots A_N
|
# import numpy as np
N, K = tuple(int(c) for c in input().split(" "))
A = [N] * (N + 1)
print(" ".join([str(s) for s in A[1:]]))
|
Statement
We have N bulbs arranged on a number line, numbered 1 to N from left to right.
Bulb i is at coordinate i.
Each bulb has a non-negative integer parameter called intensity. When there is
a bulb of intensity d at coordinate x, the bulb illuminates the segment from
coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We
will now do the following operation K times in a row:
* For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i.
Find the intensity of each bulb after the K operations.
|
[{"input": "5 1\n 1 0 0 1 0", "output": "1 2 2 1 2 \n \n\nInitially, only Bulb 1 illuminates coordinate 1, so the intensity of Bulb 1\nbecomes 1 after the operation. Similarly, the bulbs initially illuminating\ncoordinate 2 are Bulb 1 and 2, so the intensity of Bulb 2 becomes 2.\n\n* * *"}, {"input": "5 2\n 1 0 0 1 0", "output": "3 3 4 4 3"}]
|
Output k+1 lines. First line, the length of the sequence, k. Following k
lines, the index of the i-th element of the subsequence, s_i (one element per
line).
|
s231581831
|
Wrong Answer
|
p01968
|
N
a_1 a_2 $\cdots$ a_N
|
# -*- coding: utf-8 -*-
from collections import Counter
def inpl():
return tuple(map(int, input().split()))
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
if C[-2] % 2 == 0:
ans = [i + 1 for i, a in enumerate(A) if abs(a) == 2]
print(len(ans))
if len(ans):
print(*ans, sep="\n")
elif C[-1] > 0:
ans = [i + 1 for i, a in enumerate(A) if abs(a) == 2] + [A.index(-1) + 1]
print(len(ans))
if len(ans):
print(*sorted(ans), sep="\n")
else:
del A[-A[::-1].index(-2) - 1]
ans = [i + 1 for i, a in enumerate(A) if abs(a) == 2]
print(len(ans))
if len(ans):
print(*ans, sep="\n")
|
Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she
considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At
first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0. Next, let x_1
be the output of s_1 and evaluate s_2-th formulae with x = x_1, and so on.
She wants to maximize the final output of the procedure, x_{s_k}. If there are
many candidates, she wants the """shortest one""". If there are still many
candidates, she wants the """lexicographically smallest one""".
Sequence s is lexicographically smaller than sequence t, if and only if either
of the following conditions hold:
* there exists m < |s| such that s_i = t_i for i in 1 to m (inclusive) and s_{m+1} < t_{m+1}, or
* s_i = t_i for i in 1 to |s| (inclusive) and |s| < |t|,
where |s| is the length of the s.
|
[{"input": "4\n 2 0 -2 1", "output": "for Input 1\n\n \n \n 1\n 1\n \n\nShe evaluates the first one and gets the maximum value 2."}, {"input": "3\n 2 -2 -2", "output": "for Input 2\n\n \n \n 3\n 1\n 2\n 3\n \n\nShe evaluates all of them and gets the maximum value 8."}, {"input": "2\n -1 0", "output": "for Input 3\n\n \n \n 0\n\nShe evaluates none of them and gets the maximum value 0. Empty sequence is the\nshorter and lexicographically smaller than any other sequences."}, {"input": "5\n -1 2 1 -2 -1", "output": "for Input 4\n\n \n \n 3\n 1\n 2\n 4\n \n\nShe evaluates $\\langle$ 1, 2, 4 $\\rangle$ ones and gets the maximum value 4.\nNote that $\\langle$ 2, 4, 5 $\\rangle$ is not lexicographically smallest one."}]
|
If Snuke's objective is achievable, print `Yes`. Otherwise, print `No`.
* * *
|
s977537546
|
Wrong Answer
|
p03955
|
The input is given from Standard Input in the following format:
N
a_{1,1} a_{1,2} ... a_{1,N}
a_{2,1} a_{2,2} ... a_{2,N}
a_{3,1} a_{3,2} ... a_{3,N}
|
n = int(input())
input()
t = list(range(2, 2 + (n - 1) * 3 + 1, 3))
k = sorted([int(i) for i in input().strip().split(" ")])
input()
if t == k:
print("Yes")
else:
print("No")
|
Statement
We have a grid with 3 rows and N columns. The cell at the i-th row and j-th
column is denoted (i, j). Initially, each cell (i, j) contains the integer
i+3j-3.

A grid with N=5 columns
Snuke can perform the following operation any number of times:
* Choose a 3×3 subrectangle of the grid. The placement of integers within the subrectangle is now rotated by 180°.

An example sequence of operations (each chosen subrectangle is colored blue)
Snuke's objective is to manipulate the grid so that each cell (i, j) contains
the integer a_{i,j}. Determine whether it is achievable.
|
[{"input": "5\n 9 6 15 12 1\n 8 5 14 11 2\n 7 4 13 10 3", "output": "Yes\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "5\n 1 2 3 4 5\n 6 7 8 9 10\n 11 12 13 14 15", "output": "No\n \n\n* * *"}, {"input": "5\n 1 4 7 10 13\n 2 5 8 11 14\n 3 6 9 12 15", "output": "Yes\n \n\nThe objective is already achieved with the initial placement of the integers.\n\n* * *"}, {"input": "6\n 15 10 3 4 9 16\n 14 11 2 5 8 17\n 13 12 1 6 7 18", "output": "Yes\n \n\n* * *"}, {"input": "7\n 21 12 1 16 13 6 7\n 20 11 2 17 14 5 8\n 19 10 3 18 15 4 9", "output": "No"}]
|
If Snuke's objective is achievable, print `Yes`. Otherwise, print `No`.
* * *
|
s100465489
|
Wrong Answer
|
p03955
|
The input is given from Standard Input in the following format:
N
a_{1,1} a_{1,2} ... a_{1,N}
a_{2,1} a_{2,2} ... a_{2,N}
a_{3,1} a_{3,2} ... a_{3,N}
|
import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for _ in range(3)]
for j in range(n):
if not (
(a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j])
or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])
):
print("No")
exit()
for j in range(n):
if (j % 2) * (((a[0][j] - 1) // 3) % 2) == 1:
print("No")
exit()
# BIT
def add(a, w, bit):
x = a
while x <= n:
bit[x] += w
x += x & -x
def solve(a, bit):
ret = 0
x = a
while x > 0:
ret += bit[x]
x -= x & -x
return ret
bit_odd = [0] * (3 * n + 1)
inv_odd = 0
flip_even = 0
for j in range(n):
if j % 2 == 1:
if a[0][j] > a[1][j]:
flip_even += 1
else:
inv_odd += j - solve(a[0][j], bit_odd)
add(a[0][j], 1, bit_odd)
if flip_even % 2 != inv_odd % 2:
print("No")
exit()
bit_even = [0] * (3 * n + 1)
inv_even = 0
flip_odd = 0
for j in range(n):
if j % 2 == 0:
if a[0][j] > a[1][j]:
flip_odd += 1
else:
inv_even += j - solve(a[0][j], bit_even)
add(a[0][j], 1, bit_even)
if flip_odd % 2 != inv_even % 2:
print("No")
exit()
print("Yes")
|
Statement
We have a grid with 3 rows and N columns. The cell at the i-th row and j-th
column is denoted (i, j). Initially, each cell (i, j) contains the integer
i+3j-3.

A grid with N=5 columns
Snuke can perform the following operation any number of times:
* Choose a 3×3 subrectangle of the grid. The placement of integers within the subrectangle is now rotated by 180°.

An example sequence of operations (each chosen subrectangle is colored blue)
Snuke's objective is to manipulate the grid so that each cell (i, j) contains
the integer a_{i,j}. Determine whether it is achievable.
|
[{"input": "5\n 9 6 15 12 1\n 8 5 14 11 2\n 7 4 13 10 3", "output": "Yes\n \n\nThis case corresponds to the figure in the problem statement.\n\n* * *"}, {"input": "5\n 1 2 3 4 5\n 6 7 8 9 10\n 11 12 13 14 15", "output": "No\n \n\n* * *"}, {"input": "5\n 1 4 7 10 13\n 2 5 8 11 14\n 3 6 9 12 15", "output": "Yes\n \n\nThe objective is already achieved with the initial placement of the integers.\n\n* * *"}, {"input": "6\n 15 10 3 4 9 16\n 14 11 2 5 8 17\n 13 12 1 6 7 18", "output": "Yes\n \n\n* * *"}, {"input": "7\n 21 12 1 16 13 6 7\n 20 11 2 17 14 5 8\n 19 10 3 18 15 4 9", "output": "No"}]
|
If there does not exist an undirected graph with N vertices satisfying the
conditions, print `-1`.
If there exists such a graph, print an example in the following format (refer
to Problem Statement for what the symbols stand for):
M
u_1 v_1
:
u_M v_M
If there exist multiple graphs satisfying the conditions, any of them will be
accepted.
* * *
|
s623222330
|
Wrong Answer
|
p02997
|
Input is given from Standard Input in the following format:
N K
|
# using main() makes code faster from the point of view of "access to variables in global name-space"
# def main():
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
import sys
sys.setrecursionlimit(10**7)
from itertools import (
accumulate,
combinations,
permutations,
) # https://docs.python.org/ja/3/library/itertools.html
from math import factorial
def factorize(n):
"""return the factors of the Arg and count of each factor
Args:
n (long): number to be resolved into factors
Returns:
list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
"""
fct = [] # prime factor
b, e = 2, 0 # base, exponent
while b * b <= n:
while n % b == 0:
n = n // b
e = e + 1
if e > 0:
fct.append((b, e))
b, e = b + 1, 0
if n > 1:
fct.append((n, 1))
return fct
def combinations_count(n, r):
# faster than the following code
# def combinations_count(n, r):
# return factorial(n) // (factorial(n - r) * factorial(r))
if n - r < r:
r = n - r
if r == 0:
return 1
if r == 1:
return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r + 1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p - 1, r, p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
return result
def combination_with_repetition_count(n, r):
return combinations_count(n + r - 1, r)
from collections import (
deque,
Counter,
defaultdict,
) # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import (
heapify,
heappop,
heappush,
heappushpop,
heapreplace,
nlargest,
nsmallest,
) # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from operator import itemgetter
# ex1: List.sort(key=itemgetter(1))
# ex2: sorted(tuples, key=itemgetter(1,2))
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
return reduce(gcd, numbers)
def lcm(x, y):
return (x * y) // gcd(x, y)
def lcms(numbers):
return reduce(lcm, numbers, 1)
# first create factorial_list
# fac_list = mod_factorial_list(n)
INF = 10**18
MOD = 10**9 + 7
modpow = lambda a, n, p=MOD: pow(a, n, p) # Recursive function in python is slow!
def modinv(a, p=MOD):
# evaluate reciprocal using Fermat's little theorem:
# a**(p-1) is identical to 1 (mod p) when a and p is coprime
return modpow(a, p - 2, p)
def modinv_list(n, p=MOD):
if n <= 1:
return [0, 1][: n + 1]
else:
inv_t = [0, 1]
for i in range(2, n + 1):
inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
return inv_t
def modfactorial_list(n, p=MOD):
if n == 0:
return [1]
else:
l = [0] * (n + 1)
tmp = 1
for i in range(1, n + 1):
tmp = tmp * i % p
l[i] = tmp
return l
def modcomb(n, k, fac_list=[], p=MOD):
# fac_list = modfactorial_list(100)
# print(modcomb(100, 5, modfactorial_list(100)))
from math import factorial
if n < 0 or k < 0 or n < k:
return 0
if n == 0 or k == 0:
return 1
if len(fac_list) <= n:
a = factorial(n) % p
b = factorial(k) % p
c = factorial(n - k) % p
else:
a = fac_list[n]
b = fac_list[k]
c = fac_list[n - k]
return (a * modpow(b, p - 2, p) * modpow(c, p - 2, p)) % p
def modadd(a, b, p=MOD):
return (a + b) % MOD
def modsub(a, b, p=MOD):
return (a - b) % p
def modmul(a, b, p=MOD):
return ((a % p) * (b % p)) % p
def moddiv(a, b, p=MOD):
return modmul(a, modpow(b, p - 2, p))
# initialize variables and set inputs
# initialize variables
# to initialize list, use [0] * n
# to initialize two dimentional array, use [[0] * N for _ in range(N)]
# set inputs
# open(0).read() is a convenient method:
# ex) n, m, *x = map(int, open(0).read().split())
# min(x[::2]) - max(x[1::2])
# ex2) *x, = map(int, open(0).read().split())
# don't forget to add comma after *x if only one variable is used
# calculate and output
# output pattern
# ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
# functions used
r = (
lambda: sys.stdin.readline().strip()
) # single: int(r()), line: map(int, r().split())
R = lambda: list(map(int, r().split())) # line: R(), lines: [R() for _ in range(n)]
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())
# set inputs
N, K = R()
T = combinations_count(N - 1, 2)
if K > T:
print(-1)
exit() # <= to avoid deep nest
# to make star (,or uni), N-1 edges are needed
M = (N - 1) + (T - K)
for i in range(2, N + 1):
print(1, i)
count = 1
i, j = 2, 3
while count <= T - K:
print(i, j)
if j < N:
j += 1
else:
i += 1
j = i + 1
count += 1
# if __name__ == '__main__':
# main()
|
Statement
Does there exist an undirected graph with N vertices satisfying the following
conditions?
* The graph is simple and connected.
* The vertices are numbered 1, 2, ..., N.
* Let M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.
* There are exactly K pairs of vertices (i,\ j)\ (i < j) such that the shortest distance between them is 2.
If there exists such a graph, construct an example.
|
[{"input": "5 3", "output": "5\n 4 3\n 1 2\n 3 1\n 4 5\n 2 3\n \n\nThis graph has three pairs of vertices such that the shortest distance between\nthem is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\n* * *"}, {"input": "5 8", "output": "-1\n \n\nThere is no graph satisfying the conditions."}]
|
If there does not exist an undirected graph with N vertices satisfying the
conditions, print `-1`.
If there exists such a graph, print an example in the following format (refer
to Problem Statement for what the symbols stand for):
M
u_1 v_1
:
u_M v_M
If there exist multiple graphs satisfying the conditions, any of them will be
accepted.
* * *
|
s705899849
|
Runtime Error
|
p02997
|
Input is given from Standard Input in the following format:
N K
|
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = int((n - 2) * (n - 1) / 2)
k_min =
if k > k_max:
print(-1)
sys.exit()
edges = list()
for i in range(2, n + 1):
edges.append((1, i))
cnt = k_max
exit_flag = False
for i in range(2, n):
for j in range(i + 1, n + 1):
edges.append((i, j))
cnt -= 1
if cnt == k:
exit_flag = True
break
if exit_flag:
break
print(len(edges))
for u, v in edges:
print(u, v)
|
Statement
Does there exist an undirected graph with N vertices satisfying the following
conditions?
* The graph is simple and connected.
* The vertices are numbered 1, 2, ..., N.
* Let M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.
* There are exactly K pairs of vertices (i,\ j)\ (i < j) such that the shortest distance between them is 2.
If there exists such a graph, construct an example.
|
[{"input": "5 3", "output": "5\n 4 3\n 1 2\n 3 1\n 4 5\n 2 3\n \n\nThis graph has three pairs of vertices such that the shortest distance between\nthem is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\n* * *"}, {"input": "5 8", "output": "-1\n \n\nThere is no graph satisfying the conditions."}]
|
If there does not exist an undirected graph with N vertices satisfying the
conditions, print `-1`.
If there exists such a graph, print an example in the following format (refer
to Problem Statement for what the symbols stand for):
M
u_1 v_1
:
u_M v_M
If there exist multiple graphs satisfying the conditions, any of them will be
accepted.
* * *
|
s904121924
|
Runtime Error
|
p02997
|
Input is given from Standard Input in the following format:
N K
|
from e import resolve
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """5 3"""
output = """5
4 3
1 2
3 1
4 5
2 3"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """5 8"""
output = """-1"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """5 1"""
output = """-1"""
self.assertIO(input, output)
def test_入力例_4(self):
input = """5 0"""
output = """-1"""
self.assertIO(input, output)
if __name__ == "__main__":
unittest.main()
|
Statement
Does there exist an undirected graph with N vertices satisfying the following
conditions?
* The graph is simple and connected.
* The vertices are numbered 1, 2, ..., N.
* Let M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.
* There are exactly K pairs of vertices (i,\ j)\ (i < j) such that the shortest distance between them is 2.
If there exists such a graph, construct an example.
|
[{"input": "5 3", "output": "5\n 4 3\n 1 2\n 3 1\n 4 5\n 2 3\n \n\nThis graph has three pairs of vertices such that the shortest distance between\nthem is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\n* * *"}, {"input": "5 8", "output": "-1\n \n\nThere is no graph satisfying the conditions."}]
|
If there does not exist an undirected graph with N vertices satisfying the
conditions, print `-1`.
If there exists such a graph, print an example in the following format (refer
to Problem Statement for what the symbols stand for):
M
u_1 v_1
:
u_M v_M
If there exist multiple graphs satisfying the conditions, any of them will be
accepted.
* * *
|
s750267774
|
Wrong Answer
|
p02997
|
Input is given from Standard Input in the following format:
N K
|
print(-1)
|
Statement
Does there exist an undirected graph with N vertices satisfying the following
conditions?
* The graph is simple and connected.
* The vertices are numbered 1, 2, ..., N.
* Let M be the number of edges in the graph. The edges are numbered 1, 2, ..., M, the length of each edge is 1, and Edge i connects Vertex u_i and Vertex v_i.
* There are exactly K pairs of vertices (i,\ j)\ (i < j) such that the shortest distance between them is 2.
If there exists such a graph, construct an example.
|
[{"input": "5 3", "output": "5\n 4 3\n 1 2\n 3 1\n 4 5\n 2 3\n \n\nThis graph has three pairs of vertices such that the shortest distance between\nthem is 2: (1,\\ 4), (2,\\ 4), and (3,\\ 5). Thus, the condition is satisfied.\n\n* * *"}, {"input": "5 8", "output": "-1\n \n\nThere is no graph satisfying the conditions."}]
|
Print `YES` if the objective is achievable; print `NO` otherwise.
* * *
|
s962885594
|
Accepted
|
p03685
|
Input is given from Standard Input in the following format:
R C N
x_{1,1} y_{1,1} x_{1,2} y_{1,2}
:
x_{N,1} y_{N,1} x_{N,2} y_{N,2}
|
w, h, n = map(int, input().split())
pos = []
for i in range(n):
x1, y1, x2, y2 = map(int, input().split())
if (x1 in [0, w] or y1 in [0, h]) and (x2 in [0, w] or y2 in [0, h]):
pos.append((x1, y1, i))
pos.append((x2, y2, i))
pos.sort(key=lambda v: v[0]) # top →
edge = [v[-1] for v in pos if v[1] == 0 and v[0] != 0]
pos.sort(key=lambda v: v[1]) # left ↓
edge += [v[-1] for v in pos if v[0] == w and v[1] != 0]
pos.sort(key=lambda v: v[0], reverse=True) # bottom ←
edge += [v[-1] for v in pos if v[1] == h and v[0] != w]
pos.sort(key=lambda v: v[1], reverse=True) # right ↑
edge += [v[-1] for v in pos if v[0] == 0 and v[1] != h]
# for i in range(len(edge) - 1):
# if edge[i] == edge[i + 1]:
# break
# for j in range(len(edge) // 2):
# if edge[(i + j + 1) % n] != edge[(i - j + n) % n]:
# print("NO")
# break
# else:
# print("YES")
# print(edge)
hist = [None] * n
step = 0
for v in edge:
if hist[v] is None:
hist[v] = step + 1
step += 1
else:
if hist[v] != step:
print("NO")
break
step -= 1
else:
print("YES")
|
Statement
Snuke is playing a puzzle game. In this game, you are given a rectangular
board of dimensions R × C, filled with numbers. Each integer i from 1 through
N is written twice, at the coordinates (x_{i,1},y_{i,1}) and
(x_{i,2},y_{i,2}).
The objective is to draw a curve connecting the pair of points where the same
integer is written, for every integer from 1 through N. Here, the curves may
not go outside the board or cross each other.
Determine whether this is possible.
|
[{"input": "4 2 3\n 0 1 3 1\n 1 1 4 1\n 2 0 2 2", "output": "YES\n \n\n\n\nThe above figure shows a possible solution.\n\n* * *"}, {"input": "2 2 4\n 0 0 2 2\n 2 0 0 1\n 0 2 1 2\n 1 1 2 1", "output": "NO\n \n\n* * *"}, {"input": "5 5 7\n 0 0 2 4\n 2 3 4 5\n 3 5 5 2\n 5 5 5 4\n 0 3 5 1\n 2 2 4 4\n 0 5 4 1", "output": "YES\n \n\n* * *"}, {"input": "1 1 2\n 0 0 1 1\n 1 0 0 1", "output": "NO"}]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.