提出 #76872708
ソースコード 拡げる
##pypyですよー
#iiiiiiiiiiiiiiiiiiiiiiiiiiiiyasassa
##kusawww
##kusawww
##kusawww
##kusawww
##kusawww
import sys
sys.setrecursionlimit(10**5)##再帰対策
import math
import random
import itertools
import platform
import collections
import heapq
import bisect
from bisect import bisect_right
from collections import deque
from heapq import heappush, heappop
#from heapq import *だと多分実行環境のせいでREでるんだけど。うざい
from functools import reduce
from itertools import zip_longest, accumulate
import operator
import copy
from collections import Counter
import sys
input = lambda: sys.stdin.readline().rstrip()
"""
input = sys.stdin.readlineだとelseでinputにはないのにこいつに"\n"が含まれるから反応しちゃう。
(else:)で改行のせいで読み込まれて処理が行われる
なのでこうして、改行しないようにする
"""
###############################n
#numpyがpypyだと遅いので脳筋で
"""
本来npは.だが_で代用"""
# 基本プロパティ
_is_array_like = lambda a: isinstance(a, tuple) or isinstance(a, list)
np_shape = lambda a: (len(a), *np_shape(a[0])) if _is_array_like(a) else ()
math_prod = lambda a: reduce(operator.mul, a, 1)
np_size = lambda a: math_prod(np_shape(a))
np_ndim = lambda a: len(np_shape(a))
np_strides = lambda a: tuple(accumulate((1, *(np_shape(a)[:0:-1])), operator.mul))[::-1] # 要素のサイズは1
# 変形
np_flatten = lambda a: np_flatten([a for a in a for a in a]) if np_ndim(a) > 1 else a if np_ndim(a) == 1 else [a]
def _np_shape_complement(shape, size): # -1を含むshapeをsizeをもとに補完する
shape0 = shape[0] if shape[0] > 0 else abs(size // math_prod(shape))
return (shape0,) if len(shape) == 1 else (shape0, *_np_shape_complement(shape[1:], size // shape0))
_np_reshape = lambda a, newshape: [_np_reshape(a[n: n + len(a) // newshape[0]], newshape[1:]) for n in range(0, len(a), len(a) // newshape[0])] if len(newshape) > 1 else a
np_reshape = lambda a, newshape: _np_reshape(np_flatten(a), _np_shape_complement(newshape, np_size(a)))
_np_tile = lambda a, reps2: _np_tile([[copy.deepcopy(a[n + m % reps2[-1][0]]) for m in range(math_prod(reps2[-1]))] for n in range(0, len(a), reps2[-1][0])], reps2[:-1]) if len(reps2) > 0 else a
np_tile = lambda a, reps: _np_tile(np_flatten(a), list(zip_longest(np_shape(a)[::-1], reps[::-1], fillvalue=1))[::-1])[0]
np_broadcast_to = lambda a, shape: np_tile(a, [n // m for m, n in zip_longest(np_shape(a)[::-1], shape[::-1], fillvalue=1)][::-1])
np_broadcast_shapes = lambda *args: tuple(map(max, *[(1,) * (max([len(shape) for shape in args]) - len(shape)) + shape for shape in args]))
np_broadcast_arrays = lambda *args: [np_broadcast_to(a, np_broadcast_shapes(*map(np_shape, args))) for a in args]
# スライス
_np_slice = lambda x, k: x[k] if not _is_array_like(k) else [_np_slice(x, k[1:]) for x in x][k[0]] if len(k) > 1 else x[k[0]] # sはsliceのリスト
##kusawwwすぎる
##一次元
# 最大値のインデックス
np_argmax = lambda x: max([(x, i) for i, x in enumerate(x)])[-1]
# 最小値のインデックス
np_argmin = lambda x: min([(x, i) for i, x in enumerate(x)])[-1]
# ソート順のインデックス
np_argsort = lambda x: [x[-1] for x in sorted([(x, i) for i, x in enumerate(x)])]
##二次元
# 生成
np_zeros = lambda shape: np_reshape([0] * math_prod(shape), shape) # 任意のn(>= 1)次元に適用可能
np_ones = lambda shape: np_reshape([1] * math_prod(shape), shape) # 任意のn(>= 1)次元に適用可能
np_identity = lambda n: [[1 if i == j else 0 for j in range(n)] for i in range(n)] # 2次元のみ
np_arange = lambda *args: list(range(*args)) # 1次元のみ
# 転置・反転・回転 # 2次元のみ
np_T = lambda x: [list(x) for x in zip(*x)]
np_flip = lambda x, axis=None: np_flip(np_flip(x, axis=0), axis=1) if axis == None else [x for x in reversed(x)] if axis == 0 else [list(reversed(x)) for x in x]
np_rot90 = lambda x, k=1: np_flip(np_T(x), axis=0) if k % 4 == 1 else np_rot90(np_rot90(x, k=(k + 3) % 4))
# 単項演算(opにはoperatorを入れる)
# ※ axisは2次元のみ、axis指定なしは任意のn(>= 1)次元に適用可能。
# ただし、1次元は標準の組み込み関数で代用可能
_np_unary = lambda op, x, axis=None: [op(x) for x in zip(*x)] if axis == 0 else [op(x) for x in x] if axis == 1 or axis == -1 else op(np_flatten(x))
np_sum = lambda x, axis=None: _np_unary(sum, x, axis)
np_max = lambda x, axis=None: _np_unary(max, x, axis)
np_min = lambda x, axis=None: _np_unary(min, x, axis)
np_all = lambda x, axis=None: _np_unary(lambda x: reduce(operator.and_, x) != 0, x, axis)
np_any = lambda x, axis=None: _np_unary(lambda x: reduce(operator.or_, x) != 0, x, axis)
# 二項演算(opにはoperatorを入れる) ※ 任意のn(>= 1)次元に適用可能
_np_binomial = lambda op, x, y: [_np_binomial(op, x, y) if _is_array_like(x) else op(x, y) for x, y in zip(*np_broadcast_arrays(x, y))] # ブロードキャスト可
_np_binomial2 = lambda op, x, y: [_np_binomial2(op, x, y) if _is_array_like(x) else op(x, y) for x, y in zip(x, y)] # ブロードキャスト不可だが高速
np_add = lambda x, y: _np_binomial(operator.add, x, y)
np_sub = lambda x, y: _np_binomial(operator.sub, x, y)
np_mul = lambda x, y: _np_binomial(operator.mul, x, y)
np_floordiv = lambda x, y: _np_binomial(operator.floordiv, x, y)
np_mod = lambda x, y: _np_binomial(operator.mod, x, y)
np_eq = lambda x, y: _np_binomial(operator.eq, x, y)
np_ne = lambda x, y: _np_binomial(operator.ne, x, y)
np_lt = lambda x, y: _np_binomial(operator.lt, x, y)
np_le = lambda x, y: _np_binomial(operator.le, x, y)
np_gt = lambda x, y: _np_binomial(operator.gt, x, y)
np_ge = lambda x, y: _np_binomial(operator.ge, x, y)
np_array_equal = lambda x, y: np_shape(x) == np_shape(y) and np_all(_np_binomial2(operator.eq, x, y))
# インデックス
np_ravel_multi_index = lambda multi_index, shape: np_sum(np_mul(np_T(multi_index), np_strides(np_zeros(shape))), axis=1)
_np_unravel_index = lambda indices, strides: indices[:-1] if len(strides) == 0 else _np_unravel_index(indices[:-1] + [indices[-1] // strides[0], indices[-1] % strides[0]], strides[1:])
np_unravel_index = lambda indices, shape: np_T([_np_unravel_index([x], np_strides(np_zeros(shape))) for x in indices])
np_nonzero = lambda x: tuple(np_unravel_index([i for i, x in enumerate(np_flatten(x)) if x != 0], np_shape(x)))
# 行列積 ※ 2次元のみ
from itertools import product
np_matmul = lambda x, y: np_reshape([sum(map(operator.mul, x, y)) for x, y in product(x, np_T(y))], (len(x), -1))
###np.zeros のようにするため、ちょっと処理遅くなるので注意
class np:
@classmethod
def array(cls, a): return ndarray(a)
@classmethod
def zeros(cls, shape): return cls.array(np_zeros(shape))
@classmethod
def ones(cls, shape): return cls.array(np_ones(shape))
@classmethod
def identity(cls, n): return cls.array(np_identity(n))
@classmethod
def arange(cls, *args): return cls.array(np_arange(*args))
class ndarray(list):
def _rc(self, a): return ndarray(a) if _is_array_like(a) else a
@property
def shape(self): return np_shape(self)
@property
def size(self): return np_size(self)
@property
def ndim(self): return np_ndim(self)
@property
def T(self): return ndarray(np_T(self))
def flatten(self): return ndarray(np_flatten(self))
def reshape(self, *newshape): return ndarray(np_reshape(self, newshape))
def sum(self, axis=None): return np_sum(self, axis) if axis is None else ndarray(np_sum(self, axis))
def max(self, axis=None): return np_max(self, axis) if axis is None else ndarray(np_max(self, axis))
def min(self, axis=None): return np_min(self, axis) if axis is None else ndarray(np_min(self, axis))
def __add__(self, other): return ndarray(np_add(self, other))
def __sub__(self, other): return ndarray(np_sub(self, other))
def __mul__(self, other): return ndarray(np_mul(self, other))
def __floordiv__(self, other): return ndarray(np_floordiv(self, other))
def __mod__(self, other): return ndarray(np_mod(self, other))
def __radd__(self, other): return ndarray(np_add(other, self))
def __rsub__(self, other): return ndarray(np_sub(other, self))
def __rmul__(self, other): return ndarray(np_mul(other, self))
def __rfloordiv__(self, other): return ndarray(np_floordiv(other, self))
def __rmod__(self, other): return ndarray(np_mod(other, self))
def __matmul__(self, other): return ndarray(np_matmul(self, other))
def __getitem__(self, k): return self._rc(_np_slice(list(self), k))
#####################################
#####################################
#####################################
#####################################
YN = lambda x: print(("No", "Yes")[x]) ### YN(a == b)
INF = 10**18
II = lambda: int(input()) ##II() にする必要あり!!!!!!!!!!!!!!
IMI = lambda: map(int, input().split())
SI = lambda: input() # 文字列1行
SMI = lambda: input().split()
# 文字列リスト banana manngo gorira -->a,b,c=SMI -->a==banana....
HITOTU = lambda: list(input()) # 1文字ずつリスト化
LII = lambda: list(map(int, input().split()))
LSI = lambda: list(map(str, input().split()))
INF = 10**18
PL = lambda a: print(*a) ##a = [1, 2, 3, 4, 5]
##PL(a) --> 1 2 3 4 5
dame = lambda: print("-1")
PIF = lambda c, *a: c and print(*a) # PIF(x>0,"a")
#####################################
#####################################
#####################################
#####################################
# ==========================
# 数学
# ==========================
def is_prime(n: int) -> bool:
"""素数判定"""
if n <= 1:
return False
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
def eratosthenes(n: int) -> list[int]:
"""n以下の素数列挙"""
prime = [True] * (n + 1)
prime[0] = prime[1] = False
for i in range(2, int(n**0.5) + 1):
if prime[i]:
for j in range(i * i, n + 1, i):
prime[j] = False
return [i for i in range(n + 1) if prime[i]]
def calc_divisors(n: int) -> list[int]:
"""約数列挙"""
res = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return sorted(res)
def factorization(n: int):
"""素因数分解"""
res = []
d = 2
while d * d <= n:
cnt = 0
while n % d == 0:
cnt += 1
n //= d
if cnt:
res.append((d, cnt))
d += 1
if n > 1:
res.append((n, 1))
return res
def factorization_plural(arr):
"""複数素因数分解"""
return [factorization(x) for x in arr]
def simple_sigma(n):
"""1~nの和"""
return n * (n + 1) // 2
def comb(n, r):
"""nCr"""
from math import comb
return comb(n, r)
def mod_add(a, b, mod):
return (a + b) % mod
def mod_sub(a, b, mod):
return (a - b) % mod
def mod_mul(a, b, mod):
return (a * b) % mod
def mod_div(a, b, mod):
return a * pow(b, mod - 2, mod) % mod
class ModInt:
def __init__(self, value, mod=998244353):
self.mod = mod
self.value = value % mod
def __add__(self, other):
if isinstance(other, ModInt):
other = other.value
return ModInt(self.value + other, self.mod)
def __sub__(self, other):
if isinstance(other, ModInt):
other = other.value
return ModInt(self.value - other, self.mod)
def __mul__(self, other):
if isinstance(other, ModInt):
other = other.value
return ModInt(self.value * other, self.mod)
def __truediv__(self, other):
if isinstance(other, ModInt):
other = other.value
return ModInt(
self.value * pow(other, self.mod - 2, self.mod),
self.mod
)
def __pow__(self, n):
return ModInt(pow(self.value, n, self.mod), self.mod)
def __repr__(self):
return str(self.value)
def __int__(self):
return self.value
def sigma(A):
return sum(A)
def prod(A):##総積
ans = 1
for x in A:
ans *= x
return ans
def average(A):
return sum(A) / len(A)
# ==========================
# bit
# ==========================
def bitcount(x):
return bin(x).count("1")
def kth_bit(x, k):
return (x >> k) & 1
def bit_on(x, k):
return x | (1 << k)
def bit_off(x, k):
return x & ~(1 << k)
# ==========================
# coordinate
# ==========================
def inside(x, y, h, w):
return 0 <= x < h and 0 <= y < w
def pos2id(x, y, w):
return x * w + y
def id2pos(id, w):
return id // w, id % w
# ==========================
# Stack (入口入れて、入口から)
# ==========================
class Stack:
def __init__(self):
self.data = []
def push(self, x):
"""要素追加"""
self.data.append(x)
def pop(self):
"""一番上を取り出して削除"""
return self.data.pop()
def top(self):
"""一番上を見る"""
return self.data[-1]
def empty(self):
"""空か判定"""
return len(self.data) == 0
def size(self):
"""要素数"""
return len(self.data)
def clear(self):
"""全削除"""
self.data.clear()
def contains(self, x):
"""xが存在するか"""
return x in self.data
def count(self, x):
"""xの個数"""
return self.data.count(x)
def freq(self):
"""各値の出現回数"""
return Counter(self.data)
def to_list(self):
"""リスト化"""
return self.data[:]
# ==========================
# Queue (入口に入れ、出口から出てくる)
# ==========================
class Queue:
def __init__(self):
self.data = deque()
def push(self, x):
"""末尾に追加"""
self.data.append(x)
def pop(self):
"""先頭を取り出して削除"""
return self.data.popleft()
def front(self):
"""先頭を見る"""
return self.data[0]
def back(self):
"""末尾を見る"""
return self.data[-1]
def empty(self):
"""空か判定"""
return len(self.data) == 0
def size(self):
"""要素数"""
return len(self.data)
def clear(self):
"""全削除"""
self.data.clear()
def contains(self, x):
"""xが存在するか"""
return x in self.data
def count(self, x):
"""xの個数"""
return self.data.count(x)
def freq(self):
"""各値の出現回数"""
return Counter(self.data)
def to_list(self):
"""リスト化"""
return list(self.data)
# ==========================
# PriorityQueue (
# ==========================
class PQ:#最小値
def __init__(self):
self.data = []
def push(self, x):
"""要素追加"""
heappush(self.data, x)
def pop(self):
"""最小値を取り出して削除"""
return heappop(self.data)
def top(self):
"""最小値を見る"""
return self.data[0]
def empty(self):
"""空か判定"""
return len(self.data) == 0
def size(self):
"""要素数"""
return len(self.data)
def clear(self):
"""全削除"""
self.data.clear()
def contains(self, x):
"""xが存在するか"""
return x in self.data
def count(self, x):
"""xの個数"""
return self.data.count(x)
def freq(self):
"""各値の出現回数"""
return Counter(self.data)
def to_list(self):
"""小さい順のリストを返す"""
return sorted(self.data)
"""
pq = PQ()
pq.push(10)
pq.push(3)
pq.push(7)
pq.push(3)
print(pq.top()) # 3
print(pq.count(3)) # 2
print(pq.size()) # 4
print(pq.freq()) # Counter({3:2,10:1,7:1})
print(pq.pop()) # 3
print(pq.pop()) # 3
print(pq.pop()) # 7
print(pq.pop()) # 10
"""
##heapのみの時
###heapq.heappush(h, 5)
##heapq.heappush(h, 1)
##heapq.heappush(h, 10)
class MaxPQ:#最大値
def __init__(self):
self.data = []
def push(self, x):
"""要素追加(最大ヒープ)"""
heappush(self.data, -x)
def pop(self):
"""最大値を取り出して削除"""
return -heappop(self.data)
def top(self):
"""最大値を見る"""
return -self.data[0]
def empty(self):
"""空か判定"""
return len(self.data) == 0
def size(self):
"""要素数"""
return len(self.data)
def clear(self):
"""全削除"""
self.data.clear()
def contains(self, x):
"""xが存在するか"""
return -x in self.data
def count(self, x):
"""xの個数"""
return self.data.count(-x)
def freq(self):
"""各値の出現回数"""
return Counter(-x for x in self.data)
def to_list(self):
"""大きい順のリストを返す"""
return sorted((-x for x in self.data), reverse=True)
# ==========================
# マルチリスト
# ==========================
class MultiSet:
def __init__(self):
self.cnt = Counter()
def add(self, x):
self.cnt[x] += 1
def remove(self, x):
if self.cnt[x]:
self.cnt[x] -= 1
if self.cnt[x] == 0:
del self.cnt[x]
def count(self, x):
return self.cnt[x]
def contains(self, x):
return x in self.cnt
def size(self):
return sum(self.cnt.values())
"""
ms.add(5)
ms.add(5)
ms.count(5)
-> 2
"""
# ==========================
# 累積和
# ==========================
def prefix_sum(arr):
N = len(arr)
S = [0] * (N + 1) # S[0] = 0 として扱う
for i in range(N):
S[i + 1] = S[i] + arr[i]
return S
def build_2d_prefix_sum(grid):
H, W = len(grid), len(grid[0])
S = [[0] * (W + 1) for _ in range(H + 1)]
for i in range(H):
for j in range(W):
S[i+1][j+1] = S[i][j+1] + S[i+1][j] - S[i][j] + grid[i][j]
return S##https://qiita.com/Midori_M/items/5475061656f562dd675c引用
# ==========================
# min max
# ==========================
"""
dq = deque()
dq.append(1)
dq.appendleft(2)
dq.pop()
dq.popleft()"""
# ==========================
# min max
# ==========================
def argmin(A): ##最小値の位置 intをかえす
return min(range(len(A)), key=lambda i: A[i])
def argmax(A):
return max(range(len(A)), key=lambda i: A[i])
# ==========================
# ランレングス圧縮
# ==========================
"""
aaabbccccー>
[('a',3), ('b',2), ('c',4)]
"""
def rle(s):
if not s:
return []
res = []
cur = s[0]
cnt = 1
for c in s[1:]:
if c == cur:
cnt += 1
else:
res.append((cur, cnt))
cur = c
cnt = 1
res.append((cur, cnt))
return res
# ==========================
# インデックスに変換
# ==========================
def compress(A):
S = sorted(set(A))
mp = {x:i for i,x in enumerate(S)}
return [mp[x] for x in A]
"""
A = [100, 500, 100, 1000]
print(compress(A))->[0, 1, 0, 2]
"""
# ==========================
# グラフ
# ==========================
def make_graph(n, edges):#無向用
G = [[] for _ in range(n)]
for u, v in edges:
G[u].append(v)
G[v].append(u)
return G
# ==========================
# 配列
# ==========================
def list1di(n, default=0):
return [default] * n
def list2di(h, w, default=0):
return [[default] * w for _ in range(h)]
def list3di(x, y, z, default=0):
return [[[default] * z for _ in range(y)] for _ in range(x)]
"""
A = crar1(5)
print(A)->[0, 0, 0, 0, 0]
A = crar1(4, -1)
print(A)->[-1, -1, -1, -1]
"""
# ==========================
# list,文字列
# ==========================
def flatten(A):
"""2次元→1次元"""
return [x for row in A for x in row]
def unique(A):
"""重複削除(順序維持)"""
return list(dict.fromkeys(A))
def chunks(A, k):
"""k個ずつ分割"""
return [A[i:i+k] for i in range(0, len(A), k)]
def is_palindrome(s):
"""回文か"""
return s == s[::-1]###print(is_palindrome("level")) -> True
def reverse_str(s):
return s[::-1]
def rotate_str(s,k):
"""k回分左に"""
k %= len(s)
return s[k:] + s[:k]##rotate_str("abcdef",2)->cdefab
# ==========================
# ChMin ChMax
# ==========================
class ChangeMin:
def __init__(self, x):
self.x = x
def set(self, v):
self.x = min(self.x, v)
def val(self):
return self.x
class ChangeMax:
def __init__(self, x):
self.x = x
def set(self, v):
self.x = max(self.x, v)
def val(self):
return self.x
####以下のように====
"""
A = [7, 2, 9, 1, 5]
mn = ChangeMin(float("inf"))
for x in A:
mn.set(x)
print(mn.val()) -> 1
"""
# ==========================
# alpha,num
# ==========================
LOWER = "abcdefghijklmnopqrstuvwxyz"
UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
DIGIT = "0123456789"
ALPHA = LOWER + UPPER
ALNUM = ALPHA + DIGIT
# ==========================
# 距離
# ==========================
def euclid(x1, y1, x2, y2):
"""ユークリッド距離"""
return ((x1-x2)**2 + (y1-y2)**2) ** 0.5
def euclid_nosq(x1, y1, x2, y2):
"""ユークリッド距離sqなし"""
return (x1-x2)**2 + (y1-y2)**2
def manhattan(x1, y1, x2, y2):
"""マンハッタン距離"""
return abs(x1-x2) + abs(y1-y2)
def chebyshev(x1, y1, x2, y2):
"""チェビシェフ距離"""
return max(abs(x1-x2), abs(y1-y2))
# ==========================
# grid
# ==========================
MOVE4 = [
(1, 0),
(-1, 0),
(0, 1),
(0, -1)
]
MOVE8 = [
(1, 0), (-1, 0),
(0, 1), (0, -1),
(1, 1), (1, -1),
(-1, 1), (-1, -1)
]
# ==========================
# sort
# ==========================
def quick_sort(A):
if len(A) <= 1:
return A
pivot = A[len(A)//2]
left = [x for x in A if x < pivot]
mid = [x for x in A if x == pivot]
right = [x for x in A if x > pivot]
return quick_sort(left) + mid + quick_sort(right)
def merge_sort(A):
if len(A) <= 1:
return A
mid = len(A)//2
L = merge_sort(A[:mid])
R = merge_sort(A[mid:])
res = []
i = j = 0
while i < len(L) and j < len(R):
if L[i] <= R[j]:
res.append(L[i])
i += 1
else:
res.append(R[j])
j += 1
res.extend(L[i:])
res.extend(R[j:])
return res
"""
昇順ソート
A = [5, 2, 8, 1, 9]
B = quick_sort(A)
print(B)
降順ソート
A = [5,2,8,1,9]
B = quick_sort(A)
print(B[::-1])
"""
# ==========================
# bfs
# ==========================
def bfs(G, s):
dist = [-1] * len(G)
dist[s] = 0
q = deque([s])
while q:
v = q.popleft()
for nv in G[v]:
if dist[nv] != -1:
continue
dist[nv] = dist[v] + 1
q.append(nv)
return dist
# ==========================
# dfs
# ==========================
def dfs(G, s):
seen = [False] * len(G)
def rec(v):
seen[v] = True
for nv in G[v]:
if not seen[nv]:
rec(nv)
rec(s)
return seen
"""
G=[
[1,2], 0に関してつながってるやつ
[0,3],
[0],
[1]
]
print(bfs(G,0))-> [0,1,1,2] 距離0karano
"""
def dfs_stack(G, s):
seen = [False] * len(G)
st = [s]
while st:
v = st.pop()
if seen[v]:
continue
seen[v] = True
for nv in G[v]:
st.append(nv)
return seen
"""
G=[
[1,2], 0に関してつながってるやつ
[0,3],
[0],
[1]
]
print(dfs(G,0))-> [True,True,True,True]
"""
"""
all([])を使うと、全部がTrueの時だけTrueを返すようになる
"""
# ==========================
# output
# ==========================
def YES():
print("Yes")
def NO():
print("No")
"""
PL = lambda a: print(*a) ##a = [1, 2, 3, 4, 5]
##PL(a) --> 1 2 3 4 5
dame = lambda: print("-1")
YN = lambda x: print(("No", "Yes")[x]) ### YN(a == b)
"""
#################################################################
"""
#====必要な分だけの二次元配列====
n = int(input())
a = []
for _ in range(n):
row = list(map(int, input().split()))
a.append(row[1:]) # 必要な長さ分だけ追加すればよい
#(,)とやったら空白になって出るから平気
#タプルにするときは append((1,2))のようににじゅうかっこ
#extend バラバラに投入
#append 1 2 3 4みたいなのを [1 2 3 4]として入れられる
##sorted( ,reverse=True) で降順に。 a.sort()か b = sorted(a) で昇順ソート
#(*b)で中身全部を出す
#整数の出力ほしいなら//で基本的に(/だと2.0とかに
文字数カウントはs.count('abc')
for c, cnt in rle(s):
print(c, cnt)で[(,),(,)]みたいなやつで、タプルの中身とそれぞれ対応させられる
mx[c] = max(mx.get(c, 0), cnt)文字 c の連続長の最大値を更新
"""
"""
def add(a: int, b: int) -> int:
return a + b codon
"""
##II() にする必要あり!!!!!!!!!!!!!!
##II() にする必要あり!!!!!!!!!!!!!!
##list =,int= とかは使えないので気を付けて
##for でスライス使うとき、jがiよりでかくならないためにrange(i,j)とかにする!
#dict.fromkeys,setで重複けせる(list(dict.fromkeys(l))) list(set(my_list)) setは順番変わる可能性ある
#find は文字列、indexはlistだがこれはある前提なので in をつかって、Trueかどうかはんだん
# set は{} append ー>>>add
# komozi islower()
#oomozi isupper() ()を忘れるなあああああああああああああああ
#基本的に、PQなどはすでに関数があるので、selfPQ や PQ1
"""
| 言語 | popの動作 |
| ------------- | ---------- |
| C++ | 消すだけ(返さない) |
| Python(heapq) | 消して値を返す |
"""
N,M,K = IMI()
data = []
data_sw = list2di(N,N,-1)
tennkazu =0
for i in range(N):
row = LSI()
tennkazu +=row.count(".")
data.append([row])
print(int(5))
for i in range(5):
print(int(0),i,int(5),i)
print(int(5))
for i in range(5):
print(int(0),i,int(5),i)
提出情報
ジャッジ結果
| セット名 |
test_ALL |
| 得点 / 配点 |
0 / 3000000000 |
| 結果 |
|
| セット名 |
テストケース |
| test_ALL |
test_0000.txt, test_0001.txt, test_0002.txt, test_0003.txt, test_0004.txt, test_0005.txt, test_0006.txt, test_0007.txt, test_0008.txt, test_0009.txt, test_0010.txt, test_0011.txt, test_0012.txt, test_0013.txt, test_0014.txt, test_0015.txt, test_0016.txt, test_0017.txt, test_0018.txt, test_0019.txt, test_0020.txt, test_0021.txt, test_0022.txt, test_0023.txt, test_0024.txt, test_0025.txt, test_0026.txt, test_0027.txt, test_0028.txt, test_0029.txt, test_0030.txt, test_0031.txt, test_0032.txt, test_0033.txt, test_0034.txt, test_0035.txt, test_0036.txt, test_0037.txt, test_0038.txt, test_0039.txt, test_0040.txt, test_0041.txt, test_0042.txt, test_0043.txt, test_0044.txt, test_0045.txt, test_0046.txt, test_0047.txt, test_0048.txt, test_0049.txt, test_0050.txt, test_0051.txt, test_0052.txt, test_0053.txt, test_0054.txt, test_0055.txt, test_0056.txt, test_0057.txt, test_0058.txt, test_0059.txt, test_0060.txt, test_0061.txt, test_0062.txt, test_0063.txt, test_0064.txt, test_0065.txt, test_0066.txt, test_0067.txt, test_0068.txt, test_0069.txt, test_0070.txt, test_0071.txt, test_0072.txt, test_0073.txt, test_0074.txt, test_0075.txt, test_0076.txt, test_0077.txt, test_0078.txt, test_0079.txt, test_0080.txt, test_0081.txt, test_0082.txt, test_0083.txt, test_0084.txt, test_0085.txt, test_0086.txt, test_0087.txt, test_0088.txt, test_0089.txt, test_0090.txt, test_0091.txt, test_0092.txt, test_0093.txt, test_0094.txt, test_0095.txt, test_0096.txt, test_0097.txt, test_0098.txt, test_0099.txt, test_0100.txt, test_0101.txt, test_0102.txt, test_0103.txt, test_0104.txt, test_0105.txt, test_0106.txt, test_0107.txt, test_0108.txt, test_0109.txt, test_0110.txt, test_0111.txt, test_0112.txt, test_0113.txt, test_0114.txt, test_0115.txt, test_0116.txt, test_0117.txt, test_0118.txt, test_0119.txt, test_0120.txt, test_0121.txt, test_0122.txt, test_0123.txt, test_0124.txt, test_0125.txt, test_0126.txt, test_0127.txt, test_0128.txt, test_0129.txt, test_0130.txt, test_0131.txt, test_0132.txt, test_0133.txt, test_0134.txt, test_0135.txt, test_0136.txt, test_0137.txt, test_0138.txt, test_0139.txt, test_0140.txt, test_0141.txt, test_0142.txt, test_0143.txt, test_0144.txt, test_0145.txt, test_0146.txt, test_0147.txt, test_0148.txt, test_0149.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| test_0000.txt |
WA |
144 ms |
112556 KiB |
| test_0001.txt |
WA |
146 ms |
112780 KiB |
| test_0002.txt |
WA |
147 ms |
112692 KiB |
| test_0003.txt |
WA |
145 ms |
112900 KiB |
| test_0004.txt |
WA |
144 ms |
112780 KiB |
| test_0005.txt |
WA |
145 ms |
112656 KiB |
| test_0006.txt |
WA |
145 ms |
112720 KiB |
| test_0007.txt |
WA |
144 ms |
112680 KiB |
| test_0008.txt |
WA |
145 ms |
112884 KiB |
| test_0009.txt |
WA |
143 ms |
112664 KiB |
| test_0010.txt |
WA |
143 ms |
112780 KiB |
| test_0011.txt |
WA |
143 ms |
112668 KiB |
| test_0012.txt |
WA |
144 ms |
112772 KiB |
| test_0013.txt |
WA |
143 ms |
112968 KiB |
| test_0014.txt |
WA |
145 ms |
112808 KiB |
| test_0015.txt |
WA |
146 ms |
112716 KiB |
| test_0016.txt |
WA |
147 ms |
112784 KiB |
| test_0017.txt |
WA |
148 ms |
112716 KiB |
| test_0018.txt |
WA |
148 ms |
112684 KiB |
| test_0019.txt |
WA |
147 ms |
112540 KiB |
| test_0020.txt |
WA |
145 ms |
113024 KiB |
| test_0021.txt |
WA |
146 ms |
112492 KiB |
| test_0022.txt |
WA |
148 ms |
112668 KiB |
| test_0023.txt |
WA |
147 ms |
112428 KiB |
| test_0024.txt |
WA |
147 ms |
112984 KiB |
| test_0025.txt |
WA |
148 ms |
112784 KiB |
| test_0026.txt |
WA |
147 ms |
113024 KiB |
| test_0027.txt |
WA |
147 ms |
112824 KiB |
| test_0028.txt |
WA |
147 ms |
112504 KiB |
| test_0029.txt |
WA |
147 ms |
113028 KiB |
| test_0030.txt |
WA |
145 ms |
112428 KiB |
| test_0031.txt |
WA |
147 ms |
112880 KiB |
| test_0032.txt |
WA |
147 ms |
112668 KiB |
| test_0033.txt |
WA |
146 ms |
112552 KiB |
| test_0034.txt |
WA |
144 ms |
113024 KiB |
| test_0035.txt |
WA |
144 ms |
112980 KiB |
| test_0036.txt |
WA |
146 ms |
112504 KiB |
| test_0037.txt |
WA |
144 ms |
112664 KiB |
| test_0038.txt |
WA |
144 ms |
112552 KiB |
| test_0039.txt |
WA |
144 ms |
113024 KiB |
| test_0040.txt |
WA |
143 ms |
112720 KiB |
| test_0041.txt |
WA |
144 ms |
112564 KiB |
| test_0042.txt |
WA |
143 ms |
112680 KiB |
| test_0043.txt |
WA |
144 ms |
112640 KiB |
| test_0044.txt |
WA |
143 ms |
112668 KiB |
| test_0045.txt |
WA |
144 ms |
112556 KiB |
| test_0046.txt |
WA |
144 ms |
112716 KiB |
| test_0047.txt |
WA |
148 ms |
112556 KiB |
| test_0048.txt |
WA |
145 ms |
113024 KiB |
| test_0049.txt |
WA |
144 ms |
112808 KiB |
| test_0050.txt |
WA |
143 ms |
112668 KiB |
| test_0051.txt |
WA |
143 ms |
112660 KiB |
| test_0052.txt |
WA |
145 ms |
112880 KiB |
| test_0053.txt |
WA |
145 ms |
112980 KiB |
| test_0054.txt |
WA |
145 ms |
112972 KiB |
| test_0055.txt |
WA |
144 ms |
112716 KiB |
| test_0056.txt |
WA |
144 ms |
112784 KiB |
| test_0057.txt |
WA |
145 ms |
112620 KiB |
| test_0058.txt |
WA |
143 ms |
112556 KiB |
| test_0059.txt |
WA |
144 ms |
112808 KiB |
| test_0060.txt |
WA |
144 ms |
112656 KiB |
| test_0061.txt |
WA |
144 ms |
112716 KiB |
| test_0062.txt |
WA |
144 ms |
112556 KiB |
| test_0063.txt |
WA |
143 ms |
113000 KiB |
| test_0064.txt |
WA |
143 ms |
112660 KiB |
| test_0065.txt |
WA |
145 ms |
112684 KiB |
| test_0066.txt |
WA |
144 ms |
112808 KiB |
| test_0067.txt |
WA |
144 ms |
112784 KiB |
| test_0068.txt |
WA |
144 ms |
112552 KiB |
| test_0069.txt |
WA |
144 ms |
112884 KiB |
| test_0070.txt |
WA |
143 ms |
112664 KiB |
| test_0071.txt |
WA |
143 ms |
112812 KiB |
| test_0072.txt |
WA |
145 ms |
112808 KiB |
| test_0073.txt |
WA |
143 ms |
112720 KiB |
| test_0074.txt |
WA |
145 ms |
112668 KiB |
| test_0075.txt |
WA |
143 ms |
112660 KiB |
| test_0076.txt |
WA |
144 ms |
112704 KiB |
| test_0077.txt |
WA |
144 ms |
112784 KiB |
| test_0078.txt |
WA |
144 ms |
112756 KiB |
| test_0079.txt |
WA |
146 ms |
112812 KiB |
| test_0080.txt |
WA |
144 ms |
112812 KiB |
| test_0081.txt |
WA |
144 ms |
113024 KiB |
| test_0082.txt |
WA |
145 ms |
112700 KiB |
| test_0083.txt |
WA |
143 ms |
112704 KiB |
| test_0084.txt |
WA |
146 ms |
112684 KiB |
| test_0085.txt |
WA |
147 ms |
112980 KiB |
| test_0086.txt |
WA |
146 ms |
112668 KiB |
| test_0087.txt |
WA |
146 ms |
112576 KiB |
| test_0088.txt |
WA |
146 ms |
112776 KiB |
| test_0089.txt |
WA |
146 ms |
112656 KiB |
| test_0090.txt |
WA |
146 ms |
113028 KiB |
| test_0091.txt |
WA |
146 ms |
112656 KiB |
| test_0092.txt |
WA |
147 ms |
112812 KiB |
| test_0093.txt |
WA |
145 ms |
112676 KiB |
| test_0094.txt |
WA |
146 ms |
112664 KiB |
| test_0095.txt |
WA |
145 ms |
113028 KiB |
| test_0096.txt |
WA |
146 ms |
112596 KiB |
| test_0097.txt |
WA |
147 ms |
112900 KiB |
| test_0098.txt |
WA |
148 ms |
112972 KiB |
| test_0099.txt |
WA |
148 ms |
113000 KiB |
| test_0100.txt |
WA |
147 ms |
112692 KiB |
| test_0101.txt |
WA |
146 ms |
112808 KiB |
| test_0102.txt |
WA |
147 ms |
112684 KiB |
| test_0103.txt |
WA |
146 ms |
112712 KiB |
| test_0104.txt |
WA |
145 ms |
112984 KiB |
| test_0105.txt |
WA |
144 ms |
112988 KiB |
| test_0106.txt |
WA |
144 ms |
112428 KiB |
| test_0107.txt |
WA |
143 ms |
112648 KiB |
| test_0108.txt |
WA |
146 ms |
112784 KiB |
| test_0109.txt |
WA |
148 ms |
112552 KiB |
| test_0110.txt |
WA |
144 ms |
112700 KiB |
| test_0111.txt |
WA |
145 ms |
112812 KiB |
| test_0112.txt |
WA |
146 ms |
112644 KiB |
| test_0113.txt |
WA |
144 ms |
112972 KiB |
| test_0114.txt |
WA |
144 ms |
112684 KiB |
| test_0115.txt |
WA |
144 ms |
112812 KiB |
| test_0116.txt |
WA |
143 ms |
112656 KiB |
| test_0117.txt |
WA |
144 ms |
112680 KiB |
| test_0118.txt |
WA |
144 ms |
113032 KiB |
| test_0119.txt |
WA |
144 ms |
112540 KiB |
| test_0120.txt |
WA |
143 ms |
112716 KiB |
| test_0121.txt |
WA |
142 ms |
112660 KiB |
| test_0122.txt |
WA |
146 ms |
112556 KiB |
| test_0123.txt |
WA |
146 ms |
112668 KiB |
| test_0124.txt |
WA |
145 ms |
112616 KiB |
| test_0125.txt |
WA |
143 ms |
112684 KiB |
| test_0126.txt |
WA |
143 ms |
112980 KiB |
| test_0127.txt |
WA |
143 ms |
112656 KiB |
| test_0128.txt |
WA |
143 ms |
112656 KiB |
| test_0129.txt |
WA |
144 ms |
112428 KiB |
| test_0130.txt |
WA |
143 ms |
112660 KiB |
| test_0131.txt |
WA |
143 ms |
112900 KiB |
| test_0132.txt |
WA |
143 ms |
112784 KiB |
| test_0133.txt |
WA |
143 ms |
112772 KiB |
| test_0134.txt |
WA |
146 ms |
112684 KiB |
| test_0135.txt |
WA |
147 ms |
112812 KiB |
| test_0136.txt |
WA |
145 ms |
112612 KiB |
| test_0137.txt |
WA |
142 ms |
112620 KiB |
| test_0138.txt |
WA |
142 ms |
112780 KiB |
| test_0139.txt |
WA |
143 ms |
112776 KiB |
| test_0140.txt |
WA |
143 ms |
112656 KiB |
| test_0141.txt |
WA |
143 ms |
112812 KiB |
| test_0142.txt |
WA |
144 ms |
112612 KiB |
| test_0143.txt |
WA |
145 ms |
112792 KiB |
| test_0144.txt |
WA |
143 ms |
112532 KiB |
| test_0145.txt |
WA |
143 ms |
112808 KiB |
| test_0146.txt |
WA |
144 ms |
112816 KiB |
| test_0147.txt |
WA |
146 ms |
112556 KiB |
| test_0148.txt |
WA |
147 ms |
112808 KiB |
| test_0149.txt |
WA |
144 ms |
112664 KiB |