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 N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s570838653 | Accepted | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | n, m = map(int, input().split())
listForStudent = []
index = 0
while index < n:
listI = list(map(int, input().split()))
listForStudent.append(listI)
index += 1
listForCheck = []
index2 = 0
while index2 < m:
listI2 = list(map(int, input().split()))
listForCheck.append(listI2)
index2 += 1
index3 = 0
listForAnswer = []
while index3 < len(listForStudent):
answer = 2 * (10**8)
index4 = 0
while index4 < len(listForCheck):
if index4 == 0:
indexA = index4 + 1
distX = max(listForCheck[index4][0], listForStudent[index3][0]) - min(
listForCheck[index4][0], listForStudent[index3][0]
)
distY = max(listForCheck[index4][1], listForStudent[index3][1]) - min(
listForCheck[index4][1], listForStudent[index3][1]
)
totalDist = distX + distY
if answer > totalDist:
answer = totalDist
indexA = index4 + 1
index4 += 1
listForAnswer.append(indexA)
index3 += 1
for ans in listForAnswer:
print(ans)
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s843459711 | Accepted | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | N, M = map(int, input().split())
li = [[int(it) for it in input().split()] for i in range(N)]
lj = [[int(it) for it in input().split()] for i in range(M)]
for a, b in li:
mi = 100000000000
kk = -1
k = 0
for c, d in lj:
if mi > abs(a - c) + abs(b - d):
mi = abs(a - c) + abs(b - d)
kk = k
k += 1
print(kk + 1)
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s484708873 | Accepted | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | import sys
import math
import collections
import itertools
import array
import inspect
# Set max recursion limit
sys.setrecursionlimit(1000000)
# Debug output
def chkprint(*args):
names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args))
# Binary converter
def to_bin(x):
return bin(x)[2:]
def li_input():
return [int(_) for _ in input().split()]
def gcd(n, m):
if n % m == 0:
return m
else:
return gcd(m, n % m)
def gcd_list(L):
v = L[0]
for i in range(1, len(L)):
v = gcd(v, L[i])
return v
def lcm(n, m):
return (n * m) // gcd(n, m)
def lcm_list(L):
v = L[0]
for i in range(1, len(L)):
v = lcm(v, L[i])
return v
# Width First Search (+ Distance)
def wfs_d(D, N, K):
"""
D: 隣接行列(距離付き)
N: ノード数
K: 始点ノード
"""
dfk = [-1] * (N + 1)
dfk[K] = 0
cps = [(K, 0)]
r = [False] * (N + 1)
r[K] = True
while len(cps) != 0:
n_cps = []
for cp, cd in cps:
for i, dfcp in enumerate(D[cp]):
if dfcp != -1 and not r[i]:
dfk[i] = cd + dfcp
n_cps.append((i, cd + dfcp))
r[i] = True
cps = n_cps[:]
return dfk
# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
"""
v: 現在のノード
pre: 1つ前のノード
dist: 現在の距離
以下は別途用意する
D: 隣接リスト(行列ではない)
D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト
"""
global D
global D_dfs_d
D_dfs_d[v] = dist
for next_v, d in D[v]:
if next_v != pre:
dfs_d(next_v, v, dist + d)
return
def sigma(N):
ans = 0
for i in range(1, N + 1):
ans += i
return ans
def comb(n, 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 bisearch(L, target):
low = 0
high = len(L) - 1
while low <= high:
mid = (low + high) // 2
guess = L[mid]
if guess == target:
return True
elif guess < target:
low = mid + 1
elif guess > target:
high = mid - 1
if guess != target:
return False
# --------------------------------------------
dp = None
def calc_distance(s, p):
x, y = s
x_, y_ = p
return abs(x - x_) + abs(y - y_)
def main():
N, M = li_input()
S = [li_input() for _ in range(N)]
P = [li_input() for _ in range(M)]
for s in S:
ans_d = -1
ans_i = -1
for i, p in enumerate(P, start=1):
d = calc_distance(s, p)
if ans_d == -1 or d < ans_d:
ans_d = d
ans_i = i
print(ans_i)
main()
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s879157670 | Accepted | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10**7)
# UnionFind
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())
# ダイクストラ
def dijkstra_heap(s, edge, n):
# 始点sから各頂点への最短距離
d = [10**20] * n
used = [True] * n # True:未確定
d[s] = 0
used[s] = False
edgelist = []
for a, b in edge[s]:
heapq.heappush(edgelist, a * (10**6) + b)
while len(edgelist):
minedge = heapq.heappop(edgelist)
# まだ使われてない頂点の中から最小の距離のものを探す
if not used[minedge % (10**6)]:
continue
v = minedge % (10**6)
d[v] = minedge // (10**6)
used[v] = False
for e in edge[v]:
if used[e[1]]:
heapq.heappush(edgelist, (e[0] + d[v]) * (10**6) + e[1])
return d
# 素因数分解
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
# 2数の最小公倍数
def lcm(x, y):
return (x * y) // gcd(x, y)
# リストの要素の最小公倍数
def lcm_list(numbers):
return reduce(lcm, numbers, 1)
# リストの要素の最大公約数
def gcd_list(numbers):
return reduce(gcd, numbers)
# 素数判定
def is_prime(n):
if n <= 1:
return False
p = 2
while True:
if p**2 > n:
break
if n % p == 0:
return False
p += 1
return True
# limit以下の素数を列挙
def eratosthenes(limit):
A = [i for i in range(2, limit + 1)]
P = []
while True:
prime = min(A)
if prime > sqrt(limit):
break
P.append(prime)
i = 0
while i < len(A):
if A[i] % prime == 0:
A.pop(i)
continue
i += 1
for a in A:
P.append(a)
return P
# 同じものを含む順列
def permutation_with_duplicates(L):
if L == []:
return [[]]
else:
ret = []
# set(集合)型で重複を削除、ソート
S = sorted(set(L))
for i in S:
data = L[:]
data.remove(i)
for j in permutation_with_duplicates(data):
ret.append([i] + j)
return ret
# ここから書き始める
n, m = map(int, input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
c = [0 for i in range(m)]
d = [0 for i in range(m)]
for i in range(n):
a[i], b[i] = map(int, input().split())
for i in range(m):
c[i], d[i] = map(int, input().split())
# print("a =", a)
# print("b =", b)
# print("c =", c)
# print("d =", d)
for i in range(n):
x1, y1 = a[i], b[i]
d1 = INF
ans = 0
for j in range(m):
x2 = c[j]
y2 = d[j]
d2 = abs(x1 - x2) + abs(y1 - y2)
# if i == 0:
# print("d2 =", d2)
if d1 > d2:
ans = j + 1
d1 = d2
print(ans)
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s428715029 | Accepted | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
di = [list(map(int, input().split())) for _ in range(m)]
mn = [float("inf")] * n
num = [0] * n
for i in range(n):
for j in range(m):
k = abs(ls[i][0] - di[j][0]) + abs(ls[i][1] - di[j][1])
if k < mn[i]:
mn[i] = k
num[i] = j + 1
for p in range(n):
print(num[p])
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s514986708 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | 3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5 | Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s218030771 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | n,m = map(int,input())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m = 0:
temp = (abs(A[i] - x) + abs(B[i] - y))
ans = 0
if (abs(A[i] - x) + abs(B[i] - y)) < temp:
ans = j
print(ans)
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s438228619 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | #-*- coding:utf-8 -*-
a = list(map(int,input().split()))
num = 0
for i in range(a[0] + a[1]):
num += 1
list_{}.format(num) = []
list_{}.format(num).append(list(map(int,input().split())))
print(list_{}.format(num))
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s781728335 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | a
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s489649830 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | 3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5 | Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s650006126 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | n, m = map(int, input().split())
std = [list(map(int, input().split())) for i in range(n)]
chk = [list(map(int, input().split())) for i in range(m)]
for s in std:
print(min(lambda i: abs(s[0] - chk[i][0]) + abs(s[1] - chk[i][1])))
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s509686081 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | import sys
input=sys.stdin.readline
n,m=map(int,input().split())
g=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
for i in g:
a,b=i[0],i[1]
dis=10**10
ind=1
for j in range(m):
x,y=c[j][0],c[j][1]
now=abs(a-x)+abs(b-y)
if now<dis:
dis=now
ind=j+1
print(ind)import sys
input=sys.stdin.readline
n,m=map(int,input().split())
g=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
for i in g:
a,b=i[0],i[1]
dis=10**10
ind=1
for j in range(m):
x,y=c[j][0],c[j][1]
now=abs(a-x)+abs(b-y)
if now<dis:
dis=now
ind=j+1
print(ind) | Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
Print N lines.
The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for
the i-th student to go.
* * * | s317377202 | Runtime Error | p03774 | The input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_N b_N
c_1 d_1
:
c_M d_M | a = list(map(int,input().split(" ")))
b = list()
c = list()
ans = list()
for i in range(a[0]):
b.append(list(map(int,input().split(" "))))
for i in range(a[1]):
c.append(list(map(int,input().split(" "))))
for i in range(a[0]):
d = 0
e = 99999999
for ii in range(a[1]):
if e > abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
e = abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
d = ii
ans.append(d)
for i in range(a[0]):
print(ans[i])
| Statement
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the
coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest
checkpoint measured in _Manhattan distance_.
The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is
|x_1-x_2|+|y_1-y_2|.
Here, |x| denotes the absolute value of x.
If there are multiple nearest checkpoints for a student, he/she will select
the checkpoint with the smallest index.
Which checkpoint will each student go to? | [{"input": "2 2\n 2 0\n 0 0\n -1 0\n 1 0", "output": "2\n 1\n \n\nThe Manhattan distance between the first student and each checkpoint is:\n\n * For checkpoint 1: |2-(-1)|+|0-0|=3\n * For checkpoint 2: |2-1|+|0-0|=1\n\nThe nearest checkpoint is checkpoint 2. Thus, the first line in the output\nshould contain 2.\n\nThe Manhattan distance between the second student and each checkpoint is:\n\n * For checkpoint 1: |0-(-1)|+|0-0|=1\n * For checkpoint 2: |0-1|+|0-0|=1\n\nWhen there are multiple nearest checkpoints, the student will go to the\ncheckpoint with the smallest index. Thus, the second line in the output should\ncontain 1.\n\n* * *"}, {"input": "3 4\n 10 10\n -10 -10\n 3 3\n 1 2\n 2 3\n 3 5\n 3 5", "output": "3\n 1\n 2\n \n\nThere can be multiple checkpoints at the same coordinates.\n\n* * *"}, {"input": "5 5\n -100000000 -100000000\n -100000000 100000000\n 100000000 -100000000\n 100000000 100000000\n 0 0\n 0 0\n 100000000 100000000\n 100000000 -100000000\n -100000000 100000000\n -100000000 -100000000", "output": "5\n 4\n 3\n 2\n 1"}] |
The number of totatives in a line. | s799189030 | Accepted | p02470 | n
An integer n (1 ≤ n ≤ 1000000000). | from itertools import takewhile
from functools import reduce
def gen_prime_candidates():
yield 2
yield 3
n = 0
while 1:
yield n + 5
yield n + 7
n += 6
def calc_exp(n, p):
e = 0
while n % p == 0:
e += 1
n /= p
return e, n
def factorize(n):
f = ()
for p in takewhile(lambda p: p * p <= n, gen_prime_candidates()):
e, n = calc_exp(n, p)
if e:
f += (p,)
if n > 1:
f += (n,)
return f
def phi(n):
return reduce(lambda x, p: x * (p - 1) / p, factorize(n), n)
n = int(input())
print(int(phi(n)))
| Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers
less than or equal to n that are relatively prime to n. | [{"input": "6", "output": "2"}, {"input": "1000000", "output": "400000"}] |
The number of totatives in a line. | s441484212 | Accepted | p02470 | n
An integer n (1 ≤ n ≤ 1000000000). | import math
def sieve(n):
p = [1] * (n + 1)
p[0] = p[1] = 0
for i in range(math.ceil((n + 1) ** 0.5)):
if p[i]:
for j in range(2 * i, len(p), i):
p[j] = 0
return p
from itertools import compress, count
def prime_factor(n):
p = sieve(int(n**0.5))
factor = []
for pi in compress(count(0), p):
while n % pi == 0:
n //= pi
factor.append(pi)
if n != 1:
factor.append(n)
return factor
from sys import stdin
from functools import reduce
from operator import mul
from collections import Counter
readline = stdin.readline
print(
reduce(
mul,
(
pow(p, k) - pow(p, k - 1)
for p, k in Counter(prime_factor(int(readline()))).items()
),
)
)
| Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers
less than or equal to n that are relatively prime to n. | [{"input": "6", "output": "2"}, {"input": "1000000", "output": "400000"}] |
The number of totatives in a line. | s433670559 | Accepted | p02470 | n
An integer n (1 ≤ n ≤ 1000000000). | N = int(input())
orgN = N
div = []
def bitsoncount(x):
return bin(x).count('1')
for d in range(2, N):
if d*d > N:
break
if N % d == 0:
div.append(d)
while N % d == 0:
N = N // d
if N != 1: div.append(N)
M = len(div)
ans = 0
for i in range(1, 2 ** M): # divを因数にもちうるものであるため、i=0は不適
mul = 1
bc = bitsoncount(i)
for m in range(M):
if i >> m & 1:
mul *= div[m]
if bc % 2 == 1:
ans += orgN // mul
else:
ans -= orgN // mul
ans = orgN - ans
print(ans)
| Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers
less than or equal to n that are relatively prime to n. | [{"input": "6", "output": "2"}, {"input": "1000000", "output": "400000"}] |
The number of totatives in a line. | s189493982 | Accepted | p02470 | n
An integer n (1 ≤ n ≤ 1000000000). | p = n = int(input())
d = 2
while d * d <= n:
if n % d == 0:
p = p * (d - 1) // d
while n % d == 0:
n //= d
d += 1
if n > 1:
p = p * (n - 1) // n
print(p)
| Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers
less than or equal to n that are relatively prime to n. | [{"input": "6", "output": "2"}, {"input": "1000000", "output": "400000"}] |
The number of totatives in a line. | s627620964 | Accepted | p02470 | n
An integer n (1 ≤ n ≤ 1000000000). | a = []
n = int(input())
s = n**0.5
while n % 2 == 0 and n > 3:
a += [2]
n //= 2
d = 3
while s > d and n > d:
if n % d > 0:
d += 2
else:
a += [d]
n //= d
a += [n]
p = 1
for f in set(a):
p *= f ** a.count(f) * (1 - 1 / f)
print(int(p))
| Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers
less than or equal to n that are relatively prime to n. | [{"input": "6", "output": "2"}, {"input": "1000000", "output": "400000"}] |
Print Q lines.
The i-th line should contain the minimum number of times the tank needs to be
fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable,
the line should contain -1 instead.
* * * | s457589215 | Wrong Answer | p02889 | Input is given from Standard Input in the following format:
N M L
A_1 B_1 C_1
:
A_M B_M C_M
Q
s_1 t_1
:
s_Q t_Q | input_list = input().split()
town_num = int(input_list[0])
road_num = int(input_list[1])
tank_max = int(input_list[2])
road_list = []
for _ in range(road_num):
road_list.append(input().split())
query_num = int(input())
query_list = []
for _ in range(query_num):
query_list.append(input().split())
for query in query_list:
sup_tank = 0
tank = tank_max
query[0] = int(query[0])
query[1] = int(query[1])
query = sorted(query)
s_town = query[0]
e_town = query[1]
if road_list == []:
print(-1)
continue
for road in road_list:
if int(road[0]) == s_town:
if tank < int(road[2]):
sup_tank += 1
tank = tank_max
elif tank_max < int(road[2]):
print(-1)
break
tank -= int(road[2])
if int(road[1]) == e_town:
print(sup_tank)
break
s_town = int(road[1])
| Statement
There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i
and Town B_i bidirectionally and has a length of C_i.
Takahashi will travel between these towns by car, passing through these roads.
The fuel tank of his car can contain at most L liters of fuel, and one liter
of fuel is consumed for each unit distance traveled. When visiting a town
while traveling, he can full the tank (or choose not to do so). Travel that
results in the tank becoming empty halfway on the road cannot be done.
Process the following Q queries:
* The tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1. | [{"input": "3 2 5\n 1 2 3\n 2 3 3\n 2\n 3 2\n 1 3", "output": "0\n 1\n \n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2\nwithout fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to\nTown 2, full the tank, and use the second road to reach Town 3.\n\n* * *"}, {"input": "4 0 1\n 1\n 2 1", "output": "-1\n \n\nThere may be no road at all.\n\n* * *"}, {"input": "5 4 4\n 1 2 2\n 2 3 2\n 3 4 3\n 4 5 2\n 20\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 3 2\n 4 2\n 5 2\n 1 3\n 2 3\n 4 3\n 5 3\n 1 4\n 2 4\n 3 4\n 5 4\n 1 5\n 2 5\n 3 5\n 4 5", "output": "0\n 0\n 1\n 2\n 0\n 0\n 1\n 2\n 0\n 0\n 0\n 1\n 1\n 1\n 0\n 0\n 2\n 2\n 1\n 0"}] |
Print Q lines.
The i-th line should contain the minimum number of times the tank needs to be
fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable,
the line should contain -1 instead.
* * * | s970090476 | Wrong Answer | p02889 | Input is given from Standard Input in the following format:
N M L
A_1 B_1 C_1
:
A_M B_M C_M
Q
s_1 t_1
:
s_Q t_Q | from collections import defaultdict
from heapq import heappop, heappush
class Graph(object):
def __init__(self):
self.graph = defaultdict(list)
def __len__(self):
return len(self.graph)
def add_edge(self, src, dst, weight=1):
self.graph[src].append((dst, weight))
def get_nodes(self):
return self.graph.keys()
class Dijkstra(object):
def __init__(self, graph, start, l):
self.g = graph.graph
# startノードからの最短距離
# startノードは0, それ以外は無限大で初期化
self.dist = defaultdict(lambda: float("inf"))
self.dist[start] = 0
# 最短経路での1つ前のノード
self.prev = defaultdict(lambda: None)
# startノードをキューに入れる
self.Q = []
heappush(self.Q, (self.dist[start], start))
while self.Q:
# 優先度(距離)が最小であるキューを取り出す
dist_u, u = heappop(self.Q)
if self.dist[u] < dist_u:
continue
for v, weight in self.g[u]:
alt = dist_u + weight
if dist_u != 0:
if (dist_u - 1) // l != (alt - 1) // l:
alt = ((dist_u - 1) // l + 1) * l + weight
if self.dist[v] > alt:
self.dist[v] = alt
self.prev[v] = u
heappush(self.Q, (alt, v))
def shortest_distance(self, goal):
if self.dist[goal] == float("inf"):
return -1
return self.dist[goal] // l
def shortest_path(self, goal):
path = []
node = goal
while node is not None:
path.append(node)
node = self.prev[node]
return path[::-1]
n, m, l = map(int, input().split())
abc = [list(map(int, input().split())) for i in range(m)]
q = int(input())
st = [list(map(int, input().split())) for i in range(q)]
path = Graph()
for i in abc:
a, b, c = i[0], i[1], i[2]
if c <= l:
path.add_edge(a - 1, b - 1, c)
path.add_edge(b - 1, a - 1, c)
for i in st:
s, t = i[0] - 1, i[1] - 1
s_path = Dijkstra(path, s, l)
ans = s_path.shortest_distance(t)
print(ans)
| Statement
There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i
and Town B_i bidirectionally and has a length of C_i.
Takahashi will travel between these towns by car, passing through these roads.
The fuel tank of his car can contain at most L liters of fuel, and one liter
of fuel is consumed for each unit distance traveled. When visiting a town
while traveling, he can full the tank (or choose not to do so). Travel that
results in the tank becoming empty halfway on the road cannot be done.
Process the following Q queries:
* The tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1. | [{"input": "3 2 5\n 1 2 3\n 2 3 3\n 2\n 3 2\n 1 3", "output": "0\n 1\n \n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2\nwithout fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to\nTown 2, full the tank, and use the second road to reach Town 3.\n\n* * *"}, {"input": "4 0 1\n 1\n 2 1", "output": "-1\n \n\nThere may be no road at all.\n\n* * *"}, {"input": "5 4 4\n 1 2 2\n 2 3 2\n 3 4 3\n 4 5 2\n 20\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 3 2\n 4 2\n 5 2\n 1 3\n 2 3\n 4 3\n 5 3\n 1 4\n 2 4\n 3 4\n 5 4\n 1 5\n 2 5\n 3 5\n 4 5", "output": "0\n 0\n 1\n 2\n 0\n 0\n 1\n 2\n 0\n 0\n 0\n 1\n 1\n 1\n 0\n 0\n 2\n 2\n 1\n 0"}] |
Print Q lines.
The i-th line should contain the minimum number of times the tank needs to be
fulled while traveling from Town s_i to Town t_i. If Town t_i is unreachable,
the line should contain -1 instead.
* * * | s834022105 | Accepted | p02889 | Input is given from Standard Input in the following format:
N M L
A_1 B_1 C_1
:
A_M B_M C_M
Q
s_1 t_1
:
s_Q t_Q | from math import isinf
class WarshallFloyd(object):
def __init__(self, adj):
"""
ワーシャル・フロイド法によって全頂点間の最短距離を O(|V|^3) で計算する。
:param adj: 隣接行列 adj[i][j] でi番目の頂点からj番目の頂点へのコストを示す パスがなければINF
"""
self._dist = adj # 各頂点間の最短距離 初期値として隣接行列をそのまま用い、[i, i]要素を0に初期化する
for i in range(len(adj)):
self._dist[i][i] = 0
self._solve()
def _solve(self):
v_len = len(self._dist)
for i in range(v_len): # 経由する頂点
for j in range(v_len): # 開始頂点
for k in range(v_len): # 終端
self._dist[j][k] = min(
self._dist[j][k], self._dist[j][i] + self._dist[i][k]
)
def distance(self, start, goal):
return self._dist[start][goal]
def path(self, start, goal):
pass
N, M, L = map(int, input().split())
adj = [[float("inf") for _ in range(N)] for _ in range(N)]
for A, B, C in [tuple(map(int, input().split())) for _ in range(M)]:
adj[A - 1][B - 1] = C
adj[B - 1][A - 1] = C
wf = WarshallFloyd(adj)
adj2 = [[float("inf") for _ in range(N)] for _ in range(N)]
for i in range(N):
for j in range(N):
if i == j:
continue
if wf.distance(i, j) <= L:
adj2[i][j] = 1
wf2 = WarshallFloyd(adj2)
Q = int(input())
for s, t in [tuple(map(int, input().split())) for _ in range(Q)]:
ans = wf2.distance(s - 1, t - 1) - 1
if isinf(ans):
print(-1)
else:
print(ans)
| Statement
There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i
and Town B_i bidirectionally and has a length of C_i.
Takahashi will travel between these towns by car, passing through these roads.
The fuel tank of his car can contain at most L liters of fuel, and one liter
of fuel is consumed for each unit distance traveled. When visiting a town
while traveling, he can full the tank (or choose not to do so). Travel that
results in the tank becoming empty halfway on the road cannot be done.
Process the following Q queries:
* The tank is now full. Find the minimum number of times he needs to full his tank while traveling from Town s_i to Town t_i. If Town t_i is unreachable, print -1. | [{"input": "3 2 5\n 1 2 3\n 2 3 3\n 2\n 3 2\n 1 3", "output": "0\n 1\n \n\nTo travel from Town 3 to Town 2, we can use the second road to reach Town 2\nwithout fueling the tank on the way.\n\nTo travel from Town 1 to Town 3, we can first use the first road to get to\nTown 2, full the tank, and use the second road to reach Town 3.\n\n* * *"}, {"input": "4 0 1\n 1\n 2 1", "output": "-1\n \n\nThere may be no road at all.\n\n* * *"}, {"input": "5 4 4\n 1 2 2\n 2 3 2\n 3 4 3\n 4 5 2\n 20\n 2 1\n 3 1\n 4 1\n 5 1\n 1 2\n 3 2\n 4 2\n 5 2\n 1 3\n 2 3\n 4 3\n 5 3\n 1 4\n 2 4\n 3 4\n 5 4\n 1 5\n 2 5\n 3 5\n 4 5", "output": "0\n 0\n 1\n 2\n 0\n 0\n 1\n 2\n 0\n 0\n 0\n 1\n 1\n 1\n 0\n 0\n 2\n 2\n 1\n 0"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s561325677 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | N=int(input())
A=list(input()for i in range(N))
if len(A)==len(set(A)):
if all(A[i][-1]==A[i+1][0]) for i in range(N-2):
print('Yes')
else:print('No')
else:print('No') | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s284802039 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | n = int(input())
alist = [input() for i in range(n)]
if len(set(alist))==n:
if all(alist[i][-1]==alist[i+1][0])for i in range(n-1):
print("Yes")
else:
print("No") | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s120775584 | Accepted | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI():
return list(map(int, stdin.readline().split()))
def LF():
return list(map(float, stdin.readline().split()))
def LI_():
return list(map(lambda x: int(x) - 1, stdin.readline().split()))
def II():
return int(stdin.readline())
def IF():
return float(stdin.readline())
def LS():
return list(map(list, stdin.readline().split()))
def S():
return list(stdin.readline().rstrip())
def IR(n):
return [II() for _ in range(n)]
def LIR(n):
return [LI() for _ in range(n)]
def FR(n):
return [IF() for _ in range(n)]
def LFR(n):
return [LI() for _ in range(n)]
def LIR_(n):
return [LI_() for _ in range(n)]
def SR(n):
return [S() for _ in range(n)]
def LSR(n):
return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")
# A
def A():
a, b = LI()
if (a * b) % 2:
print("Yes")
else:
print("No")
return
# B
def B():
n = II()
w = SR(n)
d = []
for i in w:
d.append("".join(i))
if len(set(d)) != n:
print("No")
return
for i in range(n - 1):
if w[i][-1] != w[i + 1][0]:
print("No")
return
print("Yes")
return
# C
def C():
return
# D
def D():
return
# Solve
if __name__ == "__main__":
B()
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s145672061 | Wrong Answer | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | import math
from collections import deque
from collections import defaultdict
# 自作関数群
def readInt():
return int(input())
def readInts():
return list(map(int, input().split()))
def readChar():
return input()
def readChars():
return input().split()
def factorization(n):
res = []
if n % 2 == 0:
res.append(2)
for i in range(3, math.floor(n // 2) + 1, 2):
if n % i == 0:
c = 0
for j in res:
if i % j == 0:
c = 1
if c == 0:
res.append(i)
return res
def fact2(n):
p = factorization(n)
res = []
for i in p:
c = 0
z = n
while 1:
if z % i == 0:
c += 1
z /= i
else:
break
res.append([i, c])
return res
def fact(n): # 階乗
ans = 1
m = n
for _i in range(n - 1):
ans *= m
m -= 1
return ans
def comb(n, r): # コンビネーション
if n < r:
return 0
l = min(r, n - r)
m = n
u = 1
for _i in range(l):
u *= m
m -= 1
return u // fact(l)
def combmod(n, r, mod):
return (fact(n) / fact(n - r) * pow(fact(r), mod - 2, mod)) % mod
def printQueue(q):
r = copyQueue(q)
ans = [0] * r.qsize()
for i in range(r.qsize() - 1, -1, -1):
ans[i] = r.get()
print(ans)
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x): # root
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -1 * self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x): # much time
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n): # ビット全探索
x = 1
zero = "0" * n
ans = []
ans.append([0] * n)
for i in range(2**n - 1):
ans.append(list(map(lambda x: int(x), list((zero + bin(x)[2:])[-1 * n :]))))
x += 1
return ans
def arrsSum(a1, a2):
for i in range(len(a1)):
a1[i] += a2[i]
return a1
def maxValue(a, b, v):
v2 = v
for i in range(v2, -1, -1):
for j in range(v2 // a + 1): # j:aの個数
k = i - a * j
if k % b == 0:
return i
return -1
def copyQueue(q):
nq = queue.Queue()
n = q.qsize()
for i in range(n):
x = q.get()
q.put(x)
nq.put(x)
return nq
def get_sieve_of_eratosthenes(n):
# data = [2]
data = [0, 0, 0]
for i in range(3, n + 1, 2):
data.append(i)
data.append(0)
for i in range(len(data)):
interval = data[i]
if interval != 0:
for j in range(i + interval, n - 1, interval):
data[j] = 0
# ans = [x for x in data if x!=0]
ans = data[:]
return ans
n = readInt()
d = defaultdict(int)
p = "0"
for i in range(n):
x = input()
if p[-1] != x[0]:
print("No")
exit()
d[x] += 1
p = x
for i in d:
if d[i] > 1:
print("No")
exit()
print("Yes")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s517402891 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | from collections import Counter
f = open("pokemon", "r")
names = []
for line in f:
names.append(line)
max_length = 0
pokemon = ""
for i in range(len(names)):
p = [names[i]]
start = names[i][-2]
shiritori = True
count = 1
while shiritori == True:
shiritori = False
for j in range(len(names)):
if i != j and names[j][0] == start and not names[j] in p:
count += 1
start = names[j][-2]
shiritori = True
p.append(names[j])
if count > max_length:
max_length = count
pokemon = names[i]
break
print(p)
print(pokemon + str(max_length))
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s694857128 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | def isDupe(_arg_list):
return True if len(_arg_list) != len(set(_arg_list)) else False
def isWordMatch(_arg_list):
_i = 0
import pdb
pdb.set_trace()
try:
while True:
if _arg_list[_i][-1:] != _arg_list[_i + 1][0:1]:
return True
_i += 1
except IndexError:
return False
i = int(input())
word_list = []
while i > 0:
word_list.append(input())
i -= 1
print("No") if (isDupe(word_list) or isWordMatch(word_list)) else print("Yes")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s644136866 | Accepted | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | _, *l = open(0)
print("YNeos"[any(a[-2] != b[0] * l.count(a) for a, b in zip(l, l[1:])) :: 2])
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s330042039 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | n=int(input())
w=[input() for i in range(n)]
flag=True
for s in w:
if w.count(s) > 1:
flag = False
for i in range(1,n)
if w[i][0] != w[i-1][len(w[i-1])-1]:
flag = False
print("Yes" if flag else "No")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s578677970 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | 3
abc
arc
agc
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s418544800 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | n = int(input())
shiritori = [list(input()) for i in range(n)]
for i in range(n-1):
if shiritori[i][-1] != shiritori[i+1][0]:
print("No")
break
if i =n-2:
print("Yes") | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s419499439 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | import sys
n = int(input())
l = []
p = None
for i in range(n):
s = input()
if s in l && (p == None || p[-1:] == s[1:]):
l.append(s)
p = s
else:
print("No")
sys.exit()
print("Yes") | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s193981690 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | w = input().split('\n')
valid = False
for i in range(1,len(w))
if w[i][-1] == w[i+1][0] and len(set(w)) == len(w)
vaild = True
else:
vaild = False
print("Yes" if vaild else "NO")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s306692303 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | #include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;
typedef uintmax_t ull;
typedef intmax_t ll;
typedef uint64_t ul;
typedef uint32_t ui;
typedef uint8_t uc;
typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;
constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
void solve(void)
{
ui N; cin >> N;
vector<string> w(N);
for(auto& s : w) cin >> s;
std::unordered_set<string> s(w.begin(), w.end());
if(s.size() != w.size())
{
cout << "No" << CRLF;
return;
}
ui res{1};
for(ui i = 1; i < N; ++i)
{
if(w[i][0] != w[i - 1].back())
{
res = 0;
break;
}
}
cout << (res ? "Yes" : "No") << CRLF;
return;
}
int main(void)
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
solve();
return 0;
}
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s833561629 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | N = int(input())
l = list()
al = list()
bl = list()
for n in range(0,N):
a = input()
l.append(a)
al.append(a[1])
bl.append(a[-1])
l_unq = list(set(l))
if len(l) == len(l_unq):
for i in range(0,N-1):
if al[i+1] != bl[i]:
print("No")
break
print("Yes")
else:
print("No")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s314038565 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | # coding: utf-8
def is_unique(seq):
return len(seq) == len(set(seq))
def main():
n = int(input())
w = []
for i in range(n):
w.append(input())
for i in range(n-1):
if w[i][-1] != w[i + 1][0] and not is_unique(w)::
return 'No'
else:
return 'Yes'
if __name__ == '__main__':
main() | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s186961394 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | def main():
siri_list = map(int, input().split())
used = {}
result = true
for word in siri_list:
if word in used:
print('NO')
break
elif:
if used.keys()[- 1][-1] == word[0]:
print('NO')
break
used.setdefault(word, 0)
print('Yes')
if __name__ == "__main__":
main() | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s686246627 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | i=int(input())
l=[]
c=True
for k in range(1,i+1):
l.append(list(input())
if len(l)==len(set(l)):
for k in range(0,i):
if l[k][-1]!=l[k+1][0]:
c=False
break
else:
c=False
if c==False:
print("No")
else:
print("Yes")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s616047164 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | import sys
n = int (input())
words = []
No=" "
for i in range (n) :
words.append(input())
for x in range(len(words)-1):
if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
No="No"
print (No)
sys.exit()
If No != "No":
print ("Yes") | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s575945374 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | def main():
lists = [str(input())]
used = {}
result = True
for word in lists:
if word in used:
print('NO')
break
elif:
if used.keys()[- 1][-1] == word[0]:
print('NO')
break
used.setdefault(word, 0)
if result:
print('Yes')
if __name__ == "__main__":
main() | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s339957371 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | from collections import defaultdict
dic = defaultdict(str)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
flag = True
for i in range(1, n):
if lst[i][0] != last[-1]:
flag = False
break
dic[lst[i]] += 1
if dic[lst[i]] > 1
flag = False
break
if flag:
print("Yes")
else:
print("No")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s613020595 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | w=[input() for _ in range(n)]
chk=[]
chk.append(w[0])
ans='Yes'
for i in range(1,n):
if w[i-1][-1]!=w[i][0] or (w[i] in chk):
ans='No'
break
chk.append(w[i])
print(ans)
if __name__ == '__main__':
resolve() | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s314779099 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | N = int(input())
W = [[list(input())]]
def shiritori(N):
for i in range(N):
if N > 1:
if any(W[i]):
return "No"
else:
if W[i-1][-1] == W[i][0]:
return "Yes"
else:
return "No"
print(shiritori(N))
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s337275674 | Runtime Error | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | n = int(input())
words = [input() for _ in range(n)]
print("Yes" if all([y[0] == x[-1] for x, y in zip(words, words[1:]]) and len(set(words)) == n else "No") | Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
If every word announced by Takahashi satisfied the conditions, print `Yes`;
otherwise, print `No`.
* * * | s889196030 | Wrong Answer | p03261 | Input is given from Standard Input in the following format:
N
W_1
W_2
:
W_N | if __name__ == "__main__":
flag = 1
wordNum = int(input())
wordAll = []
for i in range(wordNum):
word = input()
wordAll.append(word)
wordLen = len(word)
if i > 0 and wordLast != word[0]:
flag = 0
break
for j in range(len(wordAll) - 1):
if wordAll[j] == word:
print(j, wordAll[j], word)
flag = 0
break
wordLast = word[wordLen - 1]
print(wordAll)
if flag == 1:
print("Yes")
else:
print("No")
| Statement
Takahashi is practicing _shiritori_ alone again today.
Shiritori is a game as follows:
* In the first turn, a player announces any one word.
* In the subsequent turns, a player announces a word that satisfies the following conditions:
* That word is not announced before.
* The first character of that word is the same as the last character of the last word announced.
In this game, he is practicing to announce as many words as possible in ten
seconds.
You are given the number of words Takahashi announced, N, and the i-th word he
announced, W_i, for each i. Determine if the rules of shiritori was observed,
that is, every word announced by him satisfied the conditions. | [{"input": "4\n hoge\n english\n hoge\n enigma", "output": "No\n \n\nAs `hoge` is announced multiple times, the rules of shiritori was not\nobserved.\n\n* * *"}, {"input": "9\n basic\n c\n cpp\n php\n python\n nadesico\n ocaml\n lua\n assembly", "output": "Yes\n \n\n* * *"}, {"input": "8\n a\n aa\n aaa\n aaaa\n aaaaa\n aaaaaa\n aaa\n aaaaaaa", "output": "No\n \n\n* * *"}, {"input": "3\n abc\n arc\n agc", "output": "No"}] |
Print the maximum number of times you can move.
* * * | s519265194 | Accepted | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | while True:
try:
N = int(input())
H = list(map(int, input().split()))
H.reverse()
dp = [0] * N
for i in range(1, N):
if H[i] >= H[i - 1]:
dp[i] = dp[i - 1] + 1
else:
dp[i] = 0
print(max(dp))
except:
break
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
Print the maximum number of times you can move.
* * * | s683799599 | Accepted | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | number = int(input())
heights = list(map(int, input().split()))
plusminus = []
answerlist = [0]
q = 0
for i in range(number - 1):
if i != number - 2 and heights[i] >= heights[i + 1]:
q += 1
elif i == number - 2 and heights[i] >= heights[i + 1]:
q += 1
answerlist.append(q)
else:
answerlist.append(q)
q = 0
print(max(answerlist))
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
Print the maximum number of times you can move.
* * * | s670944825 | Wrong Answer | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | max_num = 0
temp_num = 0
prev_i = 0
for i in input().split():
i = int(i)
if prev_i > i:
temp_num = 0
else:
temp_num += 1
prev_i = i
if max_num < temp_num:
max_num = temp_num
print(max_num)
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
Print the maximum number of times you can move.
* * * | s250106905 | Runtime Error | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | # import random
n = input()
n = int(n)
# if n == 1:
# _ = input()
# print(0)
# else:
# h = []
for i in range(n):
input()
# rnd = random.randint(0, n)
# count = 0
# for i in range(rnd, n-1):
# if h[i+1] <= h[i]:
# count += 1
print(0)
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
Print the maximum number of times you can move.
* * * | s145836431 | Runtime Error | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | number = int(input())
lower = list(map(int, input().split()))
time = 0
max = 0
def down(i):
global max
global time
if max > range(i, number):
return
for j in range(i, number - 1):
if lower[j] >= lower[j + 1]:
time += 1
else:
return
for i in range(len(lower)):
down(i)
if max < time:
max = time
time = 0
print(max)
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
Print the maximum number of times you can move.
* * * | s678366675 | Accepted | p02923 | Input is given from Standard Input in the following format:
N
H_1 H_2 ... H_N | n = int(input())
h_list = list(map(int, input().split()))
h_list.append(10000000000)
h_bigsmall_list = [0 for _ in range(n)]
for i in range(n):
if h_list[i] >= h_list[i + 1]:
h_bigsmall_list[i] += 1
h_bigsmall_str = ""
for i in range(len(h_bigsmall_list)):
h_bigsmall_str += str(h_bigsmall_list[i])
strlist = h_bigsmall_str.split("0")
max_len_element = max(strlist, key=len)
print(len(max_len_element))
| Statement
There are N squares arranged in a row from left to right.
The height of the i-th square from the left is H_i.
You will land on a square of your choice, then repeat moving to the adjacent
square **on the right** as long as the height of the next square is not
greater than that of the current square.
Find the maximum number of times you can move. | [{"input": "5\n 10 4 8 7 3", "output": "2\n \n\nBy landing on the third square from the left, you can move to the right twice.\n\n* * *"}, {"input": "7\n 4 4 5 6 6 5 5", "output": "3\n \n\nBy landing on the fourth square from the left, you can move to the right three\ntimes.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s607580536 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n = input()
print("Yes" if n[0]=n[2] else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s502995286 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("YNeos"[s:=input()==s[::-1]]::2) | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s231635796 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | N = input()
print("Yes" if N = N[::-1] else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s594793903 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("Yes" if input() == reversed((input()) else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s604221793 | Accepted | p03631 | Input is given from Standard Input in the following format:
N | import sys
import heapq, math
from itertools import (
zip_longest,
permutations,
combinations,
combinations_with_replacement,
)
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N = int(input())
print("Yes" if N // 100 == N % 10 else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s836769654 | Accepted | p03631 | Input is given from Standard Input in the following format:
N | # region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import (
accumulate,
groupby,
product,
permutations,
combinations,
combinations_with_replacement,
)
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float("inf")
MOD = 10**9 + 7
# endregion
N = rs()
print("Yes" if N == N[::-1] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s118099435 | Accepted | p03631 | Input is given from Standard Input in the following format:
N | import functools
import os
INF = float("inf")
def inp():
return int(input())
def inpf():
return float(input())
def inps():
return input()
def inl():
return list(map(int, input().split()))
def inlf():
return list(map(float, input().split()))
def inls():
return input().split()
def inpm(line):
return [inp() for _ in range(line)]
def inpfm(line):
return [inpf() for _ in range(line)]
def inpsm(line):
return [inps() for _ in range(line)]
def inlm(line):
return [inl() for _ in range(line)]
def inlfm(line):
return [inlf() for _ in range(line)]
def inlsm(line):
return [inls() for _ in range(line)]
def debug(fn):
if not os.getenv("LOCAL"):
return fn
@functools.wraps(fn)
def wrapper(*args, **kwargs):
print(
"DEBUG: {}({}) -> ".format(
fn.__name__,
", ".join(
list(map(str, args))
+ ["{}={}".format(k, str(v)) for k, v in kwargs.items()]
),
),
end="",
)
ret = fn(*args, **kwargs)
print(ret)
return ret
return wrapper
s = input()
if s == s[::-1]:
print("Yes")
else:
print("No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s570667242 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | import heapq
class Graph:
def __init__(self, v, edgelist, w_v=None, directed=False):
super().__init__()
self.v = v
self.w_e = [{} for _ in [0] * self.v]
self.neighbor = [[] for _ in [0] * self.v]
self.w_v = w_v
self.directed = directed
for i, j, w in edgelist:
self.w_e[i][j] = w
self.neighbor[i].append(j)
def dijkstra(self, v_n):
d = [float("inf")] * self.v
d[v_n] = 0
prev = [-1] * self.v
queue = []
for i, d_i in enumerate(d):
heapq.heappush(queue, (d_i, i))
while len(queue) > 0:
d_u, u = queue.pop()
if d[u] < d_u:
continue
for v in self.neighbor[u]:
alt = d[u] + self.w_e[u][v]
if d[v] > alt:
d[v] = alt
prev[v] = u
heapq.heappush(queue, (alt, v))
return d, prev
def warshallFloyd(self):
d = [[10**18] * self.v for _ in [0] * self.v]
for i in range(self.v):
d[i][i] = 0
for i in range(self.v):
for j in self.neighbor[i]:
d[i][j] = self.w_e[i][j]
for i in range(self.v):
for j in self.neighbor[i]:
d[i][j] = self.w_e[i][j]
for k in range(self.v):
for i in range(self.v):
for j in range(self.v):
check = d[i][k] + d[k][j]
if d[i][j] > check:
d[i][j] = check
return d
def prim(self):
gb = GraphBuilder(self.v, self.directed)
queue = []
for i, w in self.w_e[0].items():
heapq.heappush(queue, (w, 0, i))
rest = [True] * self.v
rest[0] = False
v = 1
while len(queue) > 0:
w, i, j = heapq.heappop(queue)
if rest[j]:
gb.addEdge(i, j, w)
rest[j] = False
for k, w in self.w_e[j].items():
if rest[k]:
heapq.heappush(queue, (w, j, k))
return gb
class Tree:
def __init__(self, v, e):
pass
class GraphBuilder:
def __init__(self, v, directed=False):
self.v = v
self.directed = directed
self.edge = []
def addEdge(self, i, j, w=1):
if not self.directed:
self.edge.append((j, i, w))
self.edge.append((i, j, w))
def addEdges(self, edgelist, weight=True):
if weight:
if self.directed:
for i, j, w in edgelist:
self.edge.append((i, j, w))
else:
for i, j, w in edgelist:
self.edge.append((i, j, w))
self.edge.append((j, i, w))
else:
if self.directed:
for i, j, w in edgelist:
self.edge.append((i, j, 1))
else:
for i, j, w in edgelist:
self.edge.append((i, j, 1))
self.edge.append((j, i, 1))
def addAdjMat(self, mat):
for i, mat_i in enumerate(mat):
for j, w in enumerate(mat_i):
self.edge.append((i, j, w))
def buildTree(self):
pass
def buildGraph(self):
return Graph(self.v, self.edge, directed=self.directed)
def main():
n = int(input())
edge = []
for _ in range(n - 1):
a, b, w = tuple([int(t) for t in input().split()])
edge.append((a - 1, b - 1, w))
gb = GraphBuilder(n)
gb.addEdges(edge)
g = gb.buildGraph()
q, k = tuple([int(t) for t in input().split()])
dijk = g.dijkstra(k - 1)[0]
ans = []
for _ in range(q):
x, y = tuple([int(t) - 1 for t in input().split()])
ans.append(dijk[x] + dijk[y])
for a_i in ans:
print(a_i)
if __name__ == "__main__":
main()
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s418695967 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | A, B, C, D = map(int, input().split())
if A <= C:
if B <= C:
print("0")
elif D <= B:
print("{}".format(D - C))
else:
print("{}".format(B - C))
else:
if D <= A:
print("0")
elif B <= D:
print("{}".format(B - A))
else:
print("{}".format(D - A))
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s740818879 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | # その13
# A - Palindromic Number
N = int(input())
if N[0] = N[2]:
print('Yes')
else:
print('No')
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s249380366 | Wrong Answer | p03631 | Input is given from Standard Input in the following format:
N | K = list(input())
print("YES" if K[0] == K[2] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s615811632 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | tmp = input().split(" ")
print("Yes") if tmp[0] == tmp[2] else print("No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s559203651 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a = (input())
b = a[0]
c = a[2]
if b = c:
print("Yes")
else:
print("No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s350947002 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c = input()
print("Yes" if a=c else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s819541107 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n = input()
print("Yes" if n[0] == n[2] else "No) | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s922263928 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | A=input()
print('Yes' if A==sorted(A) else 'No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s567997788 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c=input()
print("yes" if a==c, else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s736931833 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | N = input()
print (["No","Yes"][N[0] == N[2]) | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s232905184 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a=input()
print(["No","Yes"][a[0]==a[2]) | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s551500808 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a, b, c = input().split()
print(["Yes", "No"][a != c])
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s505429899 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("Yes" if input()[0] == input()[2] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s033833025 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | s=input();if(s[0]==s[2] and s[0]<s[1]) | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s763087183 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print(["No", "Yes"][input()[0] == input()[2]])
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s738680799 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c=input()
if a == c: print('Yes') else: print('No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s395579655 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("YNeos"[input() != input()[::-1] :: 2])
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s793942671 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("YES" if input()[0] == input()[2] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s859552034 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n = input()
print('YES' if n==::n else 'NO') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s102091207 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("Yes" if input()[0] == input()[1] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s001478387 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | print("Yes" if input() == reversed(input()) else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s641851663 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c=input()
print('yes' if a==c,else 'no') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s025392829 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c=input()
if a==c, print('Yes')
else print('No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s487515563 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c = input()
print("Yes" if a == c else: "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s934560747 | Wrong Answer | p03631 | Input is given from Standard Input in the following format:
N | print("Yes" if int(input()) % 101 % 10 == 0 else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s405419430 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a,b,c = input()
print('Yes' if a==c else ;'No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s913584955 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n=input()
if("Yes" if n[0]==n[2] else "No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s524120491 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | # coding: utf-8
n = int(input())
t = sorted([int(input()) for i in range(n)])
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
def nlcm(list):
if len(list) > 2:
lcm_num = lcm(list[0], list[1])
for i in range(2, len(list)):
lcm_num = lcm(lcm_num, list[i])
print(lcm_num)
elif len(list) == 2:
print(lcm(list[0], list[1]))
else:
print(len[-1])
nlcm(t)
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s467360773 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | sorted(a) = list[map(int, input().split())]
if a[0] == a[1]:
print("Yes")
els:
print("No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s116412853 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | N=int (input())
if N[0]==N[-1]:
print('Yes')
else:
print('No')
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s195508628 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n=int(input())
h=n//100
t=(n-h*100)//10
o=(n-h*100-t*10)
if h=o:
print("Yes")
else:
print("No") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s981672710 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n=input()
n=int(n)
og=n
rev=0
while(n>0):
d=n%10
n=n/10
rev=rev+d
if(og==rev):
print("Yes)
else:
print("No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s876919206 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n=input()
for i in range(len(n)//2)
if n[i]!=n[-1-i]:
print("No")
exit()
print("Yes") | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s035048302 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n=int(input())
a=n%10
b=n%100
c=n-a-(10*b)
if a=c:
print('Yes')
else:
print('No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s032731544 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | sec = input().split(" ")
# sec = ['0','75','25','100']
# sec = ['0','33','66','99']
# print(sec[0],sec[1],sec[2],sec[3])
# 開始時間選定
start = max(sec[0], sec[2])
# print('開始:' + start)
# 終了時間選定
end = min(sec[1], sec[3])
# print('終了:' + end)
kekka = int(end) - int(start)
if kekka < 1:
kekka = 0
print(kekka)
else:
print(kekka)
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s782674608 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | num = input().split()
for r, i in enumerate(num):
num[r] = int(i)
start = num[0]
if num[0] < num[2]:
start = num[2]
finish = num[3]
if num[1] < num[3]:
finish = num[1]
print(finish - start)
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s040745461 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | l = list(map(int, input().split()))
ans = min(l[1], l[3]) - max(l[0], l[2])
print(ans if ans > 0 else 0)
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s544299641 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | n = input()
for i in range(len(n)//2){
if n[i] != n[-(i+1)]:
print('No')
exit(0)
print('Yes') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s702697745 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | a = input().split()
ast = int(a[0])
aen = int(a[1])
bst = int(a[2])
ben = int(a[3])
if ast > ben or bst > aen:
print("0")
elif ast < bst and aen < ben:
print(aen - bst)
elif ast < bst and aen > ben:
print(ben - bst)
elif bst < ast and ben < aen:
print(ben - ast)
elif bst < ast and ben > aen:
print(aen - ast)
elif ast == bst and aen < ben:
print(aen - ast)
elif ast == bst and aen > ben:
print(ben - ast)
elif ast < bst and aen == ben:
print(ben - bst)
elif ast > bst and aen == ben:
print(aen - ast)
elif ast == bst and aen == ben:
print(aen - ast)
else:
print("0")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s090104300 | Runtime Error | p03631 | Input is given from Standard Input in the following format:
N | N = int(input())
N_reverse = N[::-1]
if N = N_reverse:
print('Yes')
else:
print('No') | Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
If N is a palindromic number, print `Yes`; otherwise, print `No`.
* * * | s434683021 | Accepted | p03631 | Input is given from Standard Input in the following format:
N | i = list(input())
print("Yes" if i[0] == i[2] else "No")
| Statement
You are given a three-digit positive integer N.
Determine whether N is a _palindromic number_.
Here, a palindromic number is an integer that reads the same backward as
forward in decimal notation. | [{"input": "575", "output": "Yes\n \n\nN=575 is also 575 when read backward, so it is a palindromic number. You\nshould print `Yes`.\n\n* * *"}, {"input": "123", "output": "No\n \n\nN=123 becomes 321 when read backward, so it is not a palindromic number. You\nshould print `No`.\n\n* * *"}, {"input": "812", "output": "No"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.