url stringlengths 49 92 | description stringlengths 22 4.78k | cases listlengths 0 6 |
|---|---|---|
https://atcoder.jp/contests/abc288/tasks/abc288_h | Problem Statement
Print the number of integer sequences of length
N
,
A = (A_1, A_2, \ldots, A_N)
, that satisfy both of the following conditions, modulo
998244353
.
0 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq M
A_1 \oplus A_2 \oplus \cdots \oplus A_N = X
Here,
\oplus
denotes bitwise XOR.
What is bitwise XOR?
The bit... | [
{
"input": "3 3 2\n",
"output": "5\n"
},
{
"input": "200 900606388 317329110\n",
"output": "788002104\n"
}
] |
https://atcoder.jp/contests/arc155/tasks/arc155_a | Problem Statement
You are given a string
S
of length
N
consisting of lowercase English letters, and a positive integer
K
.
Determine whether there is a string
S'
of length
K
that satisfies the following conditions.
The concatenation of
S
and
S'
in this order is a palindrome.
The concatenation of
S'
and
S
in this order ... | [
{
"input": "2\n6 2\nabbaab\n5 3\nabcbb\n",
"output": "Yes\nNo\n"
},
{
"input": "3\n12 400378271514996652\nnjvhhvjnnjvh\n10 884633988115575508\nrrhiyvrrur\n36 71630165869626180\nvsxmxajrrduhhudrrjaxmxsvvsxmxajrrduh\n",
"output": "Yes\nNo\nYes\n"
}
] |
https://atcoder.jp/contests/arc155/tasks/arc155_b | Problem Statement
For a set
S
of pairs of non-negative integers, and a non-negative integer
x
, let
f_S(x)
defined as
\displaystyle f_S(x)=\min_{(a, b) \in S} \left| \left| x-a \right| - b \right|
.
We have a set
T
of pairs of non-negative integers. Initially,
T=\lbrace (A, B)\rbrace
.
Process
Q
queries. The
i
-th quer... | [
{
"input": "4 0 5\n1 3 11\n2 7 8\n1 8 2\n2 8 9\n",
"output": "2\n1\n"
},
{
"input": "2 1 2\n1 2 3\n2 2 6\n",
"output": "0\n"
},
{
"input": "20 795629912 123625148\n2 860243184 892786970\n2 645778367 668513124\n1 531411849 174630323\n1 635062977 195695960\n2 382061637 411843651\n1 5859642... |
https://atcoder.jp/contests/arc155/tasks/arc155_c | Problem Statement
You are given integer sequences of length
N
:
A=(A_1, A_2, \dots, A_N)
and
B=(B_1, B_2, \dots, B_N)
.
You may perform the following operation any number of times:
Choose an integer
i\ (1 \leq i \leq N-2)
such that
A_i+A_{i+1}+A_{i+2}
is even. Then, rearrange
A_i
,
A_{i+1}
,
A_{i+2}
as you like.
Determ... | [
{
"input": "5\n1 2 3 4 5\n3 1 2 4 5\n",
"output": "Yes\n"
},
{
"input": "5\n1 2 4 6 5\n5 1 4 2 6\n",
"output": "No\n"
},
{
"input": "9\n2 10 4 3 6 2 6 8 5\n2 4 10 3 8 6 6 2 5\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/arc155/tasks/arc155_d | Problem Statement
For two non-negative integers
x
and
y
, let
\gcd(x,y)
be the greatest common divisor of
x
and
y
(for
x=0
, let
\gcd(x,y)=\gcd(y,x)=y
).
There are
N
integers on the blackboard, and the
i
-th integer is
A_i
. The greatest common divisor of these
N
integers is
1
.
Takahashi and Aoki will play a game agai... | [
{
"input": "4\n2 3 4 6\n",
"output": "Takahashi\nAoki\nTakahashi\nAoki\n"
},
{
"input": "4\n2 155 155 155\n",
"output": "Takahashi\nTakahashi\nTakahashi\nTakahashi\n"
},
{
"input": "20\n2579 25823 32197 55685 73127 73393 74033 95252 104289 114619 139903 144912 147663 149390 155806 169494... |
https://atcoder.jp/contests/arc155/tasks/arc155_e | Problem Statement
For a set
X
of non-negative integers, let
f(X)
denote the set of non-negative integers that can be represented as the bitwise
\mathrm{XOR}
of two integers (possibly the same) in
X
. As an example, for
X=\lbrace 1, 2, 4\rbrace
, we have
f(X)=\lbrace 0, 3, 5, 6\rbrace
.
You are given a set of
N
non-nega... | [
{
"input": "4 2\n00\n01\n10\n11\n",
"output": "2\n"
},
{
"input": "1 8\n10011011\n",
"output": "1\n"
},
{
"input": "1 2\n00\n",
"output": "0\n"
},
{
"input": "20 20\n10011011111101101111\n10100111100001111100\n10100111100110001111\n10011011100011011111\n11001000001110011010\n... |
https://atcoder.jp/contests/arc155/tasks/arc155_f | Problem Statement
You are given a sequence of
N
non-negative integers:
D=(D_1, D_2, \dots, D_N)
.
Find the number of labeled trees with
N
vertices numbered
1
to
N
that satisfy the following condition, modulo
998244353
.
There is a way to direct the
N-1
edges so that the outdegree of each vertex
i\ (1\leq i \leq N)
is
D... | [
{
"input": "4\n0 1 0 2\n",
"output": "5\n"
},
{
"input": "5\n0 1 1 1 1\n",
"output": "125\n"
},
{
"input": "15\n0 0 0 0 0 0 0 1 1 1 1 1 2 3 4\n",
"output": "63282877\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_a | Problem Statement
There are
N
people. Each of them agrees or disagrees with a proposal. Here,
N
is an odd number.
The
i
-th
(i = 1, 2, \dots, N)
person's opinion is represented by a string
S_i
: the person agrees if
S_i =
For
and disagrees if
S_i =
Against
.
Determine whether the majority agrees with the proposal. | [
{
"input": "3\nFor\nAgainst\nFor\n",
"output": "Yes\n"
},
{
"input": "5\nAgainst\nAgainst\nFor\nAgainst\nFor\n",
"output": "No\n"
},
{
"input": "1\nFor\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_b | Problem Statement
You are given
N
strings of length six each, consisting of digits. Let
S_i
be the
i
-th
(i = 1, 2, \dots, N)
of them.
You are also given
M
strings of length three each, consisting of digits. Let
T_j
be the
j
-th
(j = 1, 2, \dots, M)
of them.
Find the number of strings among
S_1, S_2, \dots, S_N
whose... | [
{
"input": "3 3\n142857\n004159\n071028\n159\n287\n857\n",
"output": "2\n"
},
{
"input": "5 4\n235983\n109467\n823476\n592801\n000333\n333\n108\n467\n983\n",
"output": "3\n"
},
{
"input": "4 4\n000000\n123456\n987111\n000000\n000\n111\n999\n111\n",
"output": "3\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_c | Problem Statement
You are given a simple undirected graph with
N
vertices and
M
edges. The vertices are numbered
1, 2, \dots, N
, and the edges are numbered
1, 2, \dots, M
.
Edge
i \, (i = 1, 2, \dots, M)
connects vertices
u_i
and
v_i
.
Determine if this graph is a path graph.
What is a simple undirected graph?
A
simp... | [
{
"input": "4 3\n1 3\n4 2\n3 2\n",
"output": "Yes\n"
},
{
"input": "2 0\n",
"output": "No\n"
},
{
"input": "5 5\n1 2\n2 3\n3 4\n4 5\n5 1\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_d | Problem Statement
You are given strings
S
and
T
consisting of lowercase English letters and
?
. Here,
|S| \gt |T|
holds (for a string
X
,
|X|
denotes the length of
X
).
Two strings
X
and
Y
such that
|X|=|Y|
is said to
match
if and only if:
one can make
X
equal
Y
by replacing each
?
in
X
and
Y
with any English letter i... | [
{
"input": "a?c\nb?\n",
"output": "Yes\nNo\nNo\n"
},
{
"input": "atcoder\n?????\n",
"output": "Yes\nYes\nYes\nYes\nYes\nYes\n"
},
{
"input": "beginner\ncontest\n",
"output": "No\nNo\nNo\nNo\nNo\nNo\nNo\nNo\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_e | Problem Statement
You are given
N
strings consisting of lowercase English letters. Let
S_i
be the
i
-th
(i = 1, 2, \dots, N)
of them.
For two strings
x
and
y
,
\mathrm{LCP}(x, y)
is defined to be the maximum integer
n
that satisfies all of the following conditions:
The lengths of
x
and
y
are both at least
n
.
For all ... | [
{
"input": "3\nabc\nabb\naac\n",
"output": "2\n2\n1\n"
},
{
"input": "11\nabracadabra\nbracadabra\nracadabra\nacadabra\ncadabra\nadabra\ndabra\nabra\nbra\nra\na\n",
"output": "4\n3\n2\n1\n0\n1\n0\n4\n3\n2\n1\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_f | Problem Statement
You are given a tree with
N
vertices. The vertices are numbered
1
through
N
, and the
i
-th edge connects vertex
a_i
and vertex
b_i
.
Solve the following problem for each
x=1,2,\ldots,N
:
There are
(2^N-1)
non-empty subsets
V
of the tree's vertices. Find the number, modulo
998244353
, of such
V
that... | [
{
"input": "4\n1 2\n2 3\n3 4\n",
"output": "10\n5\n0\n0\n"
},
{
"input": "2\n1 2\n",
"output": "3\n0\n"
},
{
"input": "10\n3 4\n3 6\n6 9\n1 3\n2 4\n5 6\n6 10\n1 8\n5 7\n",
"output": "140\n281\n352\n195\n52\n3\n0\n0\n0\n0\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_g | Problem Statement
Takahashi has
10^{100}
cards of each of
N
kinds. Initially, the score and quota of the
i
-th kind of card are set to
a_i
and
b_i
, respectively.
Given
Q
queries in the following formats, process them in order.
1 x y
: set the score of the
x
-th kind of card to
y
.
2 x y
: set the quota of the
x
-th k... | [
{
"input": "3\n1 1\n2 2\n3 3\n7\n3 4\n1 1 10\n3 4\n2 1 0\n2 3 0\n3 4\n3 2\n",
"output": "11\n19\n-1\n4\n"
}
] |
https://atcoder.jp/contests/abc287/tasks/abc287_h | Problem Statement
There is a directed graph with
N
vertices and
M
edges. The vertices are numbered
1
through
N
, and the
i
-th directed edge goes from vertex
a_i
to vertex
b_i
.
The cost of a path on this graph is defined as:
the maximum index of a vertex on the path (including the initial and final vertices).
Solve t... | [
{
"input": "4 4\n1 2\n2 3\n3 1\n4 3\n3\n1 2\n2 1\n1 4\n",
"output": "2\n3\n-1\n"
}
] |
https://atcoder.jp/contests/ahc017/tasks/ahc017_a | Problem Statement
Given an edge-weighted undirected planar graph with
N
vertices, we want to perform repair work on each edge exactly once in
D
days.
We can complete the repair work on each edge in a single day, and at most
K
edges can be repaired simultaneously on the same day.
Edges that are not under repair work ar... | [] |
https://atcoder.jp/contests/arc154/tasks/arc154_a | Problem Statement
You are given
N
-digit positive integers
A
and
B
whose topmost digits are not
0
.
You can repeat the following operation any number of times (possibly zero).
Choose an integer
i
such that
1 \le i \le N
and swap the
i
-th lowest digits of
A
and
B
.
Find the smallest possible value of
A \times B
after y... | [
{
"input": "2\n13\n22\n",
"output": "276\n"
},
{
"input": "8\n20220122\n21002300\n",
"output": "54558365\n"
}
] |
https://atcoder.jp/contests/arc154/tasks/arc154_b | Problem Statement
You are given strings
S
and
T
of length
N
consisting of lowercase English letters.
You can repeat the following operation any number of times (possibly zero).
Erase the
first
character of
S
and insert the same character at any position of
S
.
Determine whether it is possible to make
S
equal
T
, and if... | [
{
"input": "4\nabab\nabba\n",
"output": "2\n"
},
{
"input": "3\narc\ncra\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/arc154/tasks/arc154_c | Problem Statement
You are given sequences of positive integers of length
N
:
A=(A_1,A_2,\dots,A_N)
and
B=(B_1,B_2,\dots,B_N)
.
You can repeat the following operation any number of times (possibly zero).
Choose an integer
i
such that
1 \le i \le N
and replace
A_i
with
A_{i+1}
.
Here, regard
A_{N+1}
as
A_1
.
Determine wh... | [
{
"input": "3\n2\n1 2\n2 2\n4\n2 3 1 1\n2 1 1 2\n2\n1 1\n2 2\n",
"output": "Yes\nYes\nNo\n"
}
] |
https://atcoder.jp/contests/arc154/tasks/arc154_d | Problem Statement
PCT has a permutation
(P_1,P_2,\dots,P_N)
of
(1,2,\dots,N)
. You are only informed of
N
.
You can ask him at most
25000
questions of the following form.
Specify a triple of integers
(i,j,k)
such that
1 \le i,j,k \le N
and ask whether
P_i + P_j > P_k
.
Find all of
P_1,P_2,\dots,P_N
. | [] |
https://atcoder.jp/contests/arc154/tasks/arc154_e | Problem Statement
For a permutation
Q=(Q_1,Q_2,\dots,Q_N)
of
(1,2,\dots,N)
, let
f(Q)
be the following value:
the sum of
j-i
over all pairs of integers
(i,j)
such that
1 \le i < j \le N
and
Q_i > Q_j
.
You are given a permutation
P=(P_1,P_2,\dots,P_N)
of
(1,2,\dots,N)
.
Let us repeat the following operation
M
times.
Ch... | [
{
"input": "2 1\n1 2\n",
"output": "1\n"
},
{
"input": "3 2\n3 2 1\n",
"output": "90\n"
},
{
"input": "10 2023\n5 8 1 9 3 10 4 7 2 6\n",
"output": "543960046\n"
}
] |
https://atcoder.jp/contests/arc154/tasks/arc154_f | Problem Statement
We have an
N
-sided die where all sides have the same probability to show up. Let us repeat rolling this die until every side has shown up.
For integers
i
such that
1 \le i \le M
, find the expected value, modulo
998244353
, of the
i
-th power of the number of times we roll the die.
Definition of expe... | [
{
"input": "3 3\n",
"output": "499122182\n37\n748683574\n"
},
{
"input": "7 8\n",
"output": "449209977\n705980975\n631316005\n119321168\n62397541\n596241562\n584585746\n378338599\n"
},
{
"input": "2023 7\n",
"output": "442614988\n884066164\n757979000\n548628857\n593993207\n780067557\... |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_a | 問題文
JOI 高校の生徒である葵は,文字列
JOIG
が,文字列
JOI
の末尾に文字
G
を付け加えてできることに気が付いた.
そこから葵は,様々な文字列について,末尾に文字
G
を付け加えたり,末尾の文字
G
を取り除いて遊ぶようになった.
具体的には,葵は文字列を見ると次のように遊ぶ.
見た文字列の末尾の文字が
G
のとき,末尾の文字
G
を取り除いた文字列を思い浮かべる.取り除く文字は末尾の
1
文字のみである.
見た文字列の末尾の文字が
G
でないとき,文字列の末尾に文字
G
を付け加えた文字列を思い浮かべる.
長さ
N
の文字列
S
が与えられる.葵が文字列
S
を見たとき思い浮かべる文字列を求めるプログラムを作成せよ... | [
{
"input": "4\nJOIG\n",
"output": "JOI\n"
},
{
"input": "3\nJOI\n",
"output": "JOIG\n"
},
{
"input": "3\nEGG\n",
"output": "EG\n"
}
] |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_b | 問題文
JOI 高校の葵さんは,数列に対して,隣り合う各項の差の絶対値を順に並べた数列を考えるのが好きである.
はじめ,黒板には長さ
N
の数列
A_1,A_2,\ldots,A_N
が書かれている.
葵さんは以下の操作を
N-1
回繰り返す.
黒板に書かれている数列の長さが
m
であり,その数列が
b_1,b_2,\ldots,b_m
であるとする.
黒板に書かれている数列
b_1,b_2,\ldots,b_m
を消し,長さ
m-1
の数列
|b_1-b_2|,|b_2-b_3|,\ldots,|b_{m-1}-b_m|
を新たに黒板に書く.ただし,
|x|
は
x
の絶対値を表す.
N-1
回の操作が終了した後,黒板には
1
つ... | [
{
"input": "4\n3 1 4 1\n",
"output": "1\n"
},
{
"input": "2\n2 4\n",
"output": "2\n"
},
{
"input": "6\n2 7 5 3 3 11\n",
"output": "3\n"
},
{
"input": "10\n3 1 4 1 5 9 2 6 5 3\n",
"output": "0\n"
},
{
"input": "2\n0 0\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_c | 問題文
JOI 市には
1
本の十分に長い道路がある.この道路は数直線とみなすことができ,各地点は
1
個の実数による座標で表される.
また,JOI 市にはこの道路に沿って
N
個の鐘があり,座標の小さい順に
1
から
N
までの番号が付けられている.鐘
i
(
1 ≦ i ≦ N
) は座標
A_i
にある.
JOI 市では,
1
年の終わりにこれらの鐘を一斉に鳴らすのが一大イベントとなっている.
どの鐘も,鳴らすとその鐘と同じ地点では強さ
K
の音で聞こえるが,距離が
1
離れるごとに聞こえる音の強さは
1
小さくなり,距離が
K
以上離れると
0
になる.すなわち,鐘
i
を鳴らしたとき,座標
x
で聞こえる鐘
i
の音の強さ... | [
{
"input": "1 5 10\n20\n20 15 28 10 32\n",
"output": "10\n5\n2\n0\n0\n"
},
{
"input": "3 4 100\n116 194 258\n57 155 222 360\n",
"output": "41\n61\n72\n0\n"
},
{
"input": "10 10 10000\n589 2398 6567 28817 29177 31636 45468 66751 82282 97509\n2196 54498 80474 61644 18007 38759 85590 72172 ... |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_d | 問題文
机の上に,縦
H
行,横
W
列の長方形状にコインが並べられている.
最初,上から
i
行目 (
1 \leqq i \leqq H
),左から
j
列目 (
1 \leqq j \leqq W
) のコインは,
S_{i,j}=
#
のとき表面,
S_{i,j}=
.
のとき裏面が見えている状態である.
葵と凛は,これらのコインを用いてゲームを行うことにした.ゲームは以下のような流れで行われる.
葵がどれか
1
つの行を選び,その行のコインをすべてひっくり返す.
凛がどれか
1
つの列を選び,その列のコインをすべてひっくり返す.
葵が,表面が見えるコインをすべて獲得する.また凛が,裏面が見えるコインをすべて獲得する.
葵... | [
{
"input": "1 1\n#\n",
"output": "1 0\n"
},
{
"input": "5 5\n#####\n####.\n###..\n##...\n#....\n",
"output": "13 12\n"
},
{
"input": "1 40\n..........##########..........##########\n",
"output": "19 21\n"
},
{
"input": "7 1\n#\n#\n#\n#\n#\n#\n#\n",
"output": "1 6\n"
},
... |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_e | 問題文
JOIG 王国は
H
行
W
列のマス目に区切られた長方形の形をしている.上から
i
行目 (
1 \leqq i \leqq H
),左から
j
列目 (
1 \leqq j \leqq W
) のマスをマス
(i,j)
と呼ぶ.
各マスには標高と呼ばれる整数が定まっている.マス
(i,j)
の標高は
A_{i,j}
である.
JOIG 王国では,王国を縦断する運河を建設することにした.運河の建設は,以下のように行われる.
ある整数
k
(
1 \leqq k < W
) を定める.左から
k
列目と
k+1
列目の間に,王国の上端から下端まで縦断する運河を建設する.
運河を横切らず,辺で接している標高が同じマスへの移動を... | [
{
"input": "4 4\n1 1 1 3\n2 2 1 3\n2 1 1 3\n2 2 2 2\n",
"output": "4\n"
},
{
"input": "5 8\n1 2 2 5 5 5 5 5\n1 1 2 2 5 6 5 6\n1 1 1 1 6 6 5 6\n1 1 3 1 1 6 7 6\n1 4 1 1 1 6 6 6\n",
"output": "8\n"
},
{
"input": "1 6\n1 1 2 2 3 3\n",
"output": "3\n"
},
{
"input": "2 10\n1 1 1 1... |
https://atcoder.jp/contests/joig2023-open/tasks/joig2023_f | 問題文
JOIG 国では JOIG 語が使用されており,JOIG 語では文字
A
,
B
,
C
,
D
,
E
,
F
,
G
,
H
,
I
,
J
,
K
,
L
,
M
,
N
,
O
の
15
種類の文字が用いられる.
来月 JOIG 国で開催されるタイピング大会では,JOIG 語で用いられる
15
種類の文字からなる長さ
N
の文字列
S
を入力するのにかかる時間を競う.この大会では,参加者は以下の条件でタイピングを行う.
参加者は,
1
本の指を使ってタイピングをする.
参加者は,
15
種類の文字のキー
1
つずつを
1
列に並べた,左右に細長いキーボードを使用する.なお,どの位置にどの文字のキーを配置するかは,各参... | [
{
"input": "6\nABAABB\n1\n100 150 210\n",
"output": "1110\n"
},
{
"input": "6\nCBACAB\n1\n150 240 220\n",
"output": "2260\n"
},
{
"input": "20\nAAAAAAAAAAAAAAAAAAAA\n1\n230000000 80000000 80000000\n",
"output": "4600000000\n"
},
{
"input": "7\nEACHBAG\n5\n130 104 162\n107 219... |
https://atcoder.jp/contests/abc286/tasks/abc286_a | Problem Statement
You are given a sequence
A=(A_1,A_2,\ldots,A_N)
of length
N
and positive integers
P,Q,R
, and
S
.
Here,
P,Q,R
, and
S
satisfy
1\leq P\leq Q<R\leq S \leq N
and
Q-P=S-R
.
Let
B=(B_1, B_2,\ldots, B_N)
be the sequence obtained by swapping the
P
-th through
Q
-th terms and the
R
-th through
S
-th terms of
... | [
{
"input": "8 1 3 5 7\n1 2 3 4 5 6 7 8\n",
"output": "5 6 7 4 1 2 3 8\n"
},
{
"input": "5 2 3 4 5\n2 2 1 1 1\n",
"output": "2 1 1 2 1\n"
},
{
"input": "2 1 1 2 2\n50 100\n",
"output": "100 50\n"
},
{
"input": "10 2 4 7 9\n22 75 26 45 72 81 47 29 97 2\n",
"output": "22 47 ... |
https://atcoder.jp/contests/abc286/tasks/abc286_b | Problem Statement
You are given a string
S
of length
N
.
Find the string obtained by replacing all contiguous occurrences of
na
in
S
with
nya
. | [
{
"input": "4\nnaan\n",
"output": "nyaan\n"
},
{
"input": "4\nnear\n",
"output": "near\n"
},
{
"input": "8\nnational\n",
"output": "nyationyal\n"
}
] |
https://atcoder.jp/contests/abc286/tasks/abc286_c | Problem Statement
You are given a string
S
of length
N
. Let
S_i\ (1\leq i \leq N)
be the
i
-th character of
S
from the left.
You may perform the following two kinds of operations zero or more times in any order:
Pay
A
yen (the currency in Japan). Move the leftmost character of
S
to the right end. In other words, ch... | [
{
"input": "5 1 2\nrrefa\n",
"output": "3\n"
},
{
"input": "8 1000000000 1000000000\nbcdfcgaa\n",
"output": "4000000000\n"
}
] |
https://atcoder.jp/contests/abc286/tasks/abc286_d | Problem Statement
Takahashi has
N
kinds of coins;
specifically, for
1\leq i\leq N
, he has
B_i
coins worth
A_i
yen (the currency in Japan) each.
Determine if Takahashi can pay exactly
X
yen (without change) with the coins he currently has. | [
{
"input": "2 19\n2 3\n5 6\n",
"output": "Yes\n"
},
{
"input": "2 18\n2 3\n5 6\n",
"output": "No\n"
},
{
"input": "3 1001\n1 1\n2 1\n100 10\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc286/tasks/abc286_e | Problem Statement
There are
N
cities. There are also one-way direct flights that connect different cities.
The availability of direct flights is represented by
N
strings
S_1,S_2,\ldots,S_N
of length
N
each.
If the
j
-th character of
S_i
is
Y
, there is a direct flight from city
i
to city
j
;
if it is
N
, there is no... | [
{
"input": "5\n30 50 70 20 60\nNYYNN\nNNYNN\nNNNYY\nYNNNN\nYNNNN\n3\n1 3\n3 1\n4 5\n",
"output": "1 100\n2 160\n3 180\n"
},
{
"input": "2\n100 100\nNN\nNN\n1\n1 2\n",
"output": "Impossible\n"
}
] |
https://atcoder.jp/contests/abc286/tasks/abc286_f | Problem Statement
This is an
interactive task
, where your and the judge's programs interact via Standard Input and Output.
You and the judge will follow the procedure below.
The procedure consists of phases
1
and
2
; phase
1
is immediately followed by phase
2
.
(Phase
1
)
The judge decides an integer
N
between
1
and
... | [] |
https://atcoder.jp/contests/abc286/tasks/abc286_g | Problem Statement
You are given a simple connected undirected graph
G
with
N
vertices and
M
edges.
The vertices of
G
are numbered vertex
1
, vertex
2
,
\ldots
, and vertex
N
, and its edges are numbered edge
1
, edge
2
,
\ldots
, and edge
M
.
Edge
i
connects vertex
U_i
and vertex
V_i
.
You are also given a subset of t... | [
{
"input": "6 6\n1 3\n2 3\n3 4\n4 5\n4 6\n5 6\n4\n1 2 4 5\n",
"output": "Yes\n"
},
{
"input": "6 5\n1 2\n1 3\n1 4\n1 5\n1 6\n3\n1 2 3\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc286/tasks/abc286_h | Problem Statement
On a two-dimensional plane, there is a convex polygon
C
with
N
vertices, and points
S=(s_x, s_y)
and
T=(t_x,t_y)
. The vertices of
C
are
(x_1,y_1),(x_2,y_2),\ldots
, and
(x_N,y_N)
in counterclockwise order. It is guaranteed that
S
and
T
are outside the polygon.
Find the shortest distance that needs ... | [
{
"input": "4\n1 1\n3 1\n3 3\n1 3\n0 2\n5 2\n",
"output": "5.65028153987288474496\n"
},
{
"input": "3\n0 0\n2 0\n1 10\n3 7\n10 3\n",
"output": "8.06225774829854965279\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_a | Problem Statement
Determine if there is a segment that directly connects the points numbered
a
and
b
in the figure below. | [
{
"input": "1 2\n",
"output": "Yes\n"
},
{
"input": "2 8\n",
"output": "No\n"
},
{
"input": "14 15\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_b | Problem Statement
You are given a string
S
of length
N
consisting of lowercase English letters. The
x
-th
(1 \le x \le N)
character of
S
is
S_x
.
For each
i=1,2,\dots,N-1
, find the maximum non-negative integer
l
that satisfies all of the following conditions:
l+i \le N
, and
for all integers
k
such that
1 \le k \le l... | [
{
"input": "6\nabcbac\n",
"output": "5\n1\n2\n0\n1\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_c | Problem Statement
In a parallel universe, AtCoder holds AtCoder Big Contest, where
10^{16}
problems are given at once.
The IDs of the problems are as follows, from the
1
-st problem in order:
A
,
B
, ...,
Z
,
AA
,
AB
, ...,
ZZ
,
AAA
, ...
In other words, the IDs are given in the following order:
the strings of length
1... | [
{
"input": "AB\n",
"output": "28\n"
},
{
"input": "C\n",
"output": "3\n"
},
{
"input": "BRUTMHYHIIZP\n",
"output": "10000000000000000\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_d | Problem Statement
You run a web service with
N
users.
The
i
-th user with a current handle
S_i
wants to change it to
T_i
.
Here,
S_1,\ldots
, and
S_N
are pairwise distinct, and so are
T_1,\ldots
, and
T_N
.
Determine if there is an appropriate order to change their handles to fulfill all of their requests subject to th... | [
{
"input": "2\nb m\nm d\n",
"output": "Yes\n"
},
{
"input": "3\na b\nb c\nc a\n",
"output": "No\n"
},
{
"input": "5\naaa bbb\nyyy zzz\nccc ddd\nxxx yyy\nbbb ccc\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_e | Problem Statement
In the world where Takahashi lives, a week has
N
days.
Takahashi, the king of the Kingdom of AtCoder, assigns "weekday" or "holiday" to each day of week. The assignments should be the same for all weeks. At least one day of week should be assigned "holiday".
Under such conditions, the productivity o... | [
{
"input": "7\n10 10 1 1 1 1 1\n",
"output": "50\n"
},
{
"input": "10\n200000000 500000000 1000000000 800000000 100000000 80000000 600000 900000000 1 20\n",
"output": "5100000000\n"
},
{
"input": "20\n38 7719 21238 2437 8855 11797 8365 32285 10450 30612 5853 28100 1142 281 20537 15921 89... |
https://atcoder.jp/contests/abc285/tasks/abc285_f | Problem Statement
You are given a string
S
of length
N
consisting of lowercase English letters, and
Q
queries. Process the queries in order.
Each query is of one of the following two kinds:
1 x c
: replace the
x
-th character of
S
by the character
c
.
2 l r
: let
T
be the string obtained by sorting the characters of
S... | [
{
"input": "6\nabcdcf\n4\n2 1 3\n2 2 6\n1 5 e\n2 2 6\n",
"output": "Yes\nNo\nYes\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_g | Problem Statement
We have a grid with
H
horizontal rows and
W
vertical columns. We denote by square
(i,j)
the square at the
i
-th row from the top and
j
-th column from the left.
We want to cover this grid with
1 \times 1
tiles and
1 \times 2
tiles so that no tiles overlap and everywhere is covered by a tile. (A tile... | [
{
"input": "3 4\n2221\n?1??\n2?21\n",
"output": "Yes\n"
},
{
"input": "3 4\n2?21\n??1?\n2?21\n",
"output": "No\n"
},
{
"input": "5 5\n11111\n11111\n11211\n11111\n11111\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc285/tasks/abc285_h | Problem Statement
You are given integers
N
and
K
, and a sequence
E
of length
K
.
Find the number, modulo
\color{red}{10^9+7}
, of sequences of length
N
consisting of positive integers that satisfy the following conditions:
no element is a square number;
the product of all elements is
\displaystyle \prod_{i=1}^{K} p_i^... | [
{
"input": "3 2\n3 2\n",
"output": "15\n"
},
{
"input": "285 10\n3141 5926 5358 9793 2384 6264 3383 279 5028 8419\n",
"output": "672860525\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_a | Problem Statement
A positive integer
x
is said to be a
beautiful integer
if and only if
x
is a
9
-digit integer whose decimal notation
S_1\ldots S_9
(
S_i
is the
i
-th character) satisfies all of the following conditions:
S_1
is not
0
,
S_1 = S_2
,
S_5 = S_6
, and
S_7 = S_9
.
For instance,
998244353
and
333333333
are b... | [
{
"input": "3\n",
"output": "110000020\n"
},
{
"input": "882436\n",
"output": "998244353\n"
},
{
"input": "2023\n",
"output": "110200222\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_b | Problem Statement
We have a grid with
H
rows from top to bottom and
W
columns from left and right. Initially, the square at the
i
-th row from the top and
j
-th column from the left has a lowercase English letter
A_{i,j}
.
Let us perform
Q
operations on this grid. In the
i
-th operation, we are given integers
a_i
and
b... | [
{
"input": "4 5\nabcde\nfghij\nklmno\npqrst\n1\n3 3\n",
"output": "mlkon\nhgfji\ncbaed\nrqpts\n"
},
{
"input": "3 7\natcoder\nregular\ncontest\n2\n1 1\n2 5\n",
"output": "testcon\noderatc\nularreg\n"
},
{
"input": "2 2\nac\nwa\n3\n1 1\n1 1\n1 1\n",
"output": "ac\nwa\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_c | Problem Statement
You are given a sequence of length
N
,
A = (A_1, \ldots, A_N)
, consisting of
1
and
-1
.
Determine whether there is an integer sequence
x = (x_1, \ldots, x_N)
that satisfies all of the following conditions, and print one such sequence if it exists.
|x_i| \leq 10^{12}
for every
i
(
1\leq i\leq N
).
x
i... | [
{
"input": "5\n-1 1 -1 -1 1\n",
"output": "Yes\n-3 -1 4 5 7\n"
},
{
"input": "1\n-1\n",
"output": "Yes\n0\n"
},
{
"input": "2\n1 -1\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_d | Problem Statement
For a positive integer
x
, let
f(x)
denote the sum of its digits. For instance, we have
f(153) = 1 + 5 + 3 = 9
,
f(2023) = 2 + 0 + 2 + 3 = 7
, and
f(1) = 1
.
You are given a sequence of positive integers
A = (A_1, \ldots, A_N)
. Find the minimum possible value of
\sum_{i=1}^N f(A_i + x)
where
x
is a n... | [
{
"input": "4\n4 13 8 6\n",
"output": "14\n"
},
{
"input": "4\n123 45 678 90\n",
"output": "34\n"
},
{
"input": "3\n1 10 100\n",
"output": "3\n"
},
{
"input": "1\n153153153\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_e | Problem Statement
For a positive integer
X
none of whose digits is
0
, consider obtaining a positive integer
Y
as follows.
Initialize
S
as an empty string.
Let
N
be the number of digits in
X
. For
i = 1, \ldots, N
in this order, do the following: insert the
i
-th character in the decimal notation of
X
at the beginning ... | [
{
"input": "1332\n",
"output": "3\n"
},
{
"input": "3312\n",
"output": "0\n"
},
{
"input": "12234433442\n",
"output": "153\n"
}
] |
https://atcoder.jp/contests/arc153/tasks/arc153_f | Problem Statement
You are given a simple connected undirected graph
G
with
N
vertices and
M
edges. The vertices are numbered
1
to
N
, and the
i
-th edge connects vertices
A_i
and
B_i
.
Find the number of ways to paint each edge of
G
in color
1
,
2
, or
3
so that the following condition is satisfied, modulo
998244353
.
... | [
{
"input": "3 3\n1 2\n1 3\n3 2\n",
"output": "0\n"
},
{
"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"output": "534\n"
},
{
"input": "6 5\n1 3\n4 3\n5 4\n4 2\n1 6\n",
"output": "144\n"
},
{
"input": "6 7\n1 2\n2 3\n3 1\n4 5\n5 6\n6 4\n1 6\n",
"output": "1794\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_a | Problem Statement
You are given
N
strings
S_1,S_2,\ldots,S_N
in this order.
Print
S_N,S_{N-1},\ldots,S_1
in this order. | [
{
"input": "3\nTakahashi\nAoki\nSnuke\n",
"output": "Snuke\nAoki\nTakahashi\n"
},
{
"input": "4\n2023\nYear\nNew\nHappy\n",
"output": "Happy\nNew\nYear\n2023\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_b | Problem Statement
In this problem, an input file contains multiple test cases.
You are first given an integer
T
. Solve the following problem for
T
test cases.
We have
N
positive integers
A_1, A_2, ..., A_N
. How many of them are odd? | [
{
"input": "4\n3\n1 2 3\n2\n20 23\n10\n6 10 4 1 5 9 8 6 5 1\n1\n1000000000\n",
"output": "2\n1\n5\n0\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_c | Problem Statement
You are given a simple undirected graph with
N
vertices numbered
1
to
N
and
M
edges numbered
1
to
M
. Edge
i
connects vertex
u_i
and vertex
v_i
.
Find the number of connected components in this graph. | [
{
"input": "5 3\n1 2\n1 3\n4 5\n",
"output": "2\n"
},
{
"input": "5 0\n",
"output": "5\n"
},
{
"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_d | Problem Statement
You are given a positive integer
N
. It is known that
N
can be represented as
N=p^2q
using two different prime numbers
p
and
q
.
Find
p
and
q
.
You have
T
test cases to solve. | [
{
"input": "3\n2023\n63\n1059872604593911\n",
"output": "17 7\n3 7\n104149 97711\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_e | Problem Statement
You are given a simple undirected graph with
N
vertices numbered
1
to
N
and
M
edges numbered
1
to
M
. Edge
i
connects vertex
u_i
and vertex
v_i
. The degree of each vertex is at most
10
.
Let
K
be the number of simple paths (paths without repeated vertices) starting from vertex
1
. Print
\min(K, 10^6)... | [
{
"input": "4 2\n1 2\n2 3\n",
"output": "3\n"
},
{
"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"output": "16\n"
},
{
"input": "8 21\n2 6\n1 3\n5 6\n3 8\n3 6\n4 7\n4 6\n3 4\n1 5\n2 4\n1 2\n2 7\n1 4\n3 5\n2 5\n2 3\n4 5\n3 7\n6 7\n5 7\n2 8\n",
"output": "2023\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_f | Problem Statement
For a string
S
of length
N
and an integer
i\ (0\leq i\leq N)
, let us define the string
f_i(S)
as the concatenation of:
the first
i
characters of
S
,
the reversal of
S
, and
the last
(N-i)
characters of
S
,
in this order.
For instance, if
S=
abc
and
i=2
, we have
f_i(S)=
abcbac
.
You are given a strin... | [
{
"input": "3\nabcbac\n",
"output": "abc\n2\n"
},
{
"input": "4\nabababab\n",
"output": "abab\n1\n"
},
{
"input": "3\nagccga\n",
"output": "cga\n0\n"
},
{
"input": "4\natcodeer\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_g | Problem Statement
For a sequence of length
N
,
A = (A_1,A_2,\dots,A_N)
, consisting of integers between
1
and
N
, inclusive, and an integer
i\ (1\leq i \leq N)
, let us define a sequence of length
10^{100}
,
B_i=(B_{i,1},B_{i,2},\dots,B_{i,10^{100}})
, as follows.
B_{i,1}=i
.
B_{i,j+1}=A_{B_{i,j}}\ (1\leq j<10^{100})
.... | [
{
"input": "4 100000000\n",
"output": "624\n"
},
{
"input": "7 1000000000\n",
"output": "5817084\n"
},
{
"input": "2023 998244353\n",
"output": "737481389\n"
},
{
"input": "100000 353442899\n",
"output": "271798911\n"
}
] |
https://atcoder.jp/contests/abc284/tasks/abc284_h | Problem Statement
You are to generate a graph by the following procedure.
Choose a simple undirected graph with
N
unlabeled vertices.
Write a positive integer at most
K
in each vertex in the graph. Here, there must not be a positive integer at most
K
that is not written in any vertex.
Find the number of possible graphs... | [
{
"input": "3 1 998244353\n",
"output": "4\n"
},
{
"input": "3 2 998244353\n",
"output": "12\n"
},
{
"input": "5 5 998244353\n",
"output": "1024\n"
},
{
"input": "30 15 202300013\n",
"output": "62712469\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_a | Problem Statement
A string
x
consisting of lowercase English letters is said to be
good
if and only if the following condition is satisfied.
Every (contiguous) substring of
x
whose length is
2
or greater satisfies the following:
no character occupies the majority of that substring.
For example,
acbca
is not good becaus... | [
{
"input": "3\na?b\n",
"output": "24\n"
},
{
"input": "3\na?a\n",
"output": "0\n"
},
{
"input": "20\nugsyakganihodnwmktgi\n",
"output": "1\n"
},
{
"input": "20\n??a???h?m?y?ts???tl?\n",
"output": "444225229\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_b | Problem Statement
We have a grid with
N
rows and
M
columns.
You want to write an integer between
0
and
2^K-1
in each square in the grid to satisfy the following condition.
Consider a path that starts at the top-left square, repeatedly moves right or down to an adjacent square, and ends at the bottom-right square.
Such ... | [
{
"input": "4\n2 2 1\nRD\n4 3 1\nRDDDR\n15 20 18\nDDRRRRRRRDDDDRRDDRDRRRRDDRDRDDRRR\n20 15 7\nDRRDDDDDRDDDRRDDRRRDRRRDDDDDRRRDD\n",
"output": "Yes\nNo\nYes\nNo\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_c | Problem Statement
Consider a permutation
P=(P_1,P_2,\cdots,P_{2^N-1})
of
(1,2,\cdots,2^N-1)
.
P
is said to be
heaplike
if and only if all of the following conditions are satisfied.
P_i < P_{2i}
(
1 \leq i \leq 2^{N-1}-1
)
P_i < P_{2i+1}
(
1 \leq i \leq 2^{N-1}-1
)
You are given integers
A
and
B
.
Let
U=2^A
and
V=2^{B+... | [
{
"input": "2 1 1\n",
"output": "499122177\n"
},
{
"input": "3 1 2\n",
"output": "124780545\n"
},
{
"input": "4 3 2\n",
"output": "260479386\n"
},
{
"input": "2022 12 25\n",
"output": "741532295\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_d | Problem Statement
Find the number of pairs
(P,Q)=((P_1,P_2,\cdots,P_N),(Q_1,Q_2,\cdots,Q_N))
of permutations of
(1,2,\cdots,N)
that satisfy the following condition, modulo
998244353
.
For every
i
(
1 \leq i \leq N-1
), one of the two conditions below holds.
P_i < P_{i+1}
and
Q_i < Q_{i+1}
.
P_i > P_{i+1}
and
Q_i > Q_{i... | [
{
"input": "2\n",
"output": "2\n"
},
{
"input": "3\n",
"output": "10\n"
},
{
"input": "4\n",
"output": "88\n"
},
{
"input": "10\n",
"output": "286574791\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_e | Problem Statement
In this problem, a permutation of
(1,2,\cdots,N)
is occasionally called just a permutation.
For a permutation
a=(a_1,a_2,\cdots,a_N)
, let
f(a)
be the number of cycles in
a
.
More accurately, the value of
f(a)
is defined as follows.
Consider an undirected graph consisting of
N
vertices numbered
1
to
N... | [
{
"input": "3\n3 3\n1 3 2\n2 2\n2 1\n4 8\n1 2 3 4\n",
"output": "Yes\n2 1 3\nNo\nYes\n1 2 3 4\n"
}
] |
https://atcoder.jp/contests/agc060/tasks/agc060_f | Problem Statement
You have a simple undirected graph.
Each vertex in this graph has an integer interval written on it, and there are
C_{i,j}
vertices with the interval
[i,j]
(
1 \leq i \leq j \leq N
).
There are no vertices with other intervals.
For any two vertices, there is an undirected edge between them if and only... | [
{
"input": "2\n1 2\n1\n",
"output": "8\n"
},
{
"input": "3\n1 1 1\n1 1\n1\n",
"output": "99\n"
},
{
"input": "4\n8 3 8 10\n1 5 3\n1 6\n4\n",
"output": "971555314\n"
},
{
"input": "10\n2742 5611 1401 5439 5220 8571 4998 4194 7443 2492\n2393 3201 9106 1649 2456 1984 7159 9679 7... |
https://atcoder.jp/contests/abc283/tasks/abc283_a | Problem Statement
Given integers
A
and
B
,
print the value
A^B
. | [
{
"input": "4 3\n",
"output": "64\n"
},
{
"input": "5 5\n",
"output": "3125\n"
},
{
"input": "8 1\n",
"output": "8\n"
}
] |
https://atcoder.jp/contests/abc283/tasks/abc283_b | Problem Statement
You are given an integer
N
and a sequence
A=(A _ 1,A _ 2,\ldots,A _ N)
of length
N
.
Given
Q
queries, process them in the given order.
Each query is of one of the following two kinds:
1 k x
: set the value
A _ k
to
x
.
2 k
: print the value
A _ k
. | [
{
"input": "3\n1 3 5\n7\n2 2\n2 3\n1 3 0\n2 3\n1 2 8\n2 2\n2 1\n",
"output": "3\n5\n0\n8\n1\n"
},
{
"input": "5\n22 2 16 7 30\n10\n1 4 0\n1 5 0\n2 2\n2 3\n2 4\n2 5\n1 4 100\n1 5 100\n2 3\n2 4\n",
"output": "2\n16\n0\n0\n16\n100\n"
},
{
"input": "7\n478 369 466 343 541 42 165\n20\n2 1\n1 ... |
https://atcoder.jp/contests/abc283/tasks/abc283_c | Problem Statement
Takahashi is a cashier.
There is a cash register with
11
keys:
00
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
, and
9
.
The cash register initially displays
0
.
Whenever he types the key
00
, the displayed number is multiplied by
100
;
whenever he types one of the others, the displayed number is multiplied by... | [
{
"input": "40004\n",
"output": "4\n"
},
{
"input": "1355506027\n",
"output": "10\n"
},
{
"input": "10888869450418352160768000001\n",
"output": "27\n"
}
] |
https://atcoder.jp/contests/abc283/tasks/abc283_d | Problem Statement
A string consisting of lowercase English letters,
(
, and
)
is said to be a
good string
if you can make it an empty string by the following procedure:
First, remove all lowercase English letters.
Then, repeatedly remove consecutive
()
while possible.
For example,
((a)ba)
is a good string, because remo... | [
{
"input": "((a)ba)\n",
"output": "Yes\n"
},
{
"input": "(a(ba))\n",
"output": "No\n"
},
{
"input": "(((())))\n",
"output": "Yes\n"
},
{
"input": "abca\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc283/tasks/abc283_e | Problem Statement
You are given a matrix
A
with
H
rows and
W
columns. The value of each of its elements is
0
or
1
.
For an integer pair
(i, j)
such that
1 \leq i \leq H
and
1 \leq j \leq W
, we denote by
A_{i,j}
the element at the
i
-th row and
j
-th column.
You can perform the following operation on the matrix
A
any... | [
{
"input": "3 3\n1 1 0\n1 0 1\n1 0 0\n",
"output": "1\n"
},
{
"input": "4 4\n1 0 0 0\n0 1 1 1\n0 0 1 0\n1 1 0 1\n",
"output": "2\n"
},
{
"input": "2 3\n0 1 0\n0 1 1\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc283/tasks/abc283_f | Problem Statement
You are given a permutation
P=(P _ 1,P _ 2,\ldots,P _ N)
of
(1,2,\ldots,N)
.
Find the following value for all
i\ (1\leq i\leq N)
:
D _ i=\displaystyle\min_{j\neq i}\left\lparen\left\lvert P _ i-P _ j\right\rvert+\left\lvert i-j\right\rvert\right\rparen
.
What is a permutation?
A permutation of
(1,2,\l... | [
{
"input": "4\n3 2 4 1\n",
"output": "2 2 3 3 \n"
},
{
"input": "7\n1 2 3 4 5 6 7\n",
"output": "2 2 2 2 2 2 2 \n"
},
{
"input": "16\n12 10 7 14 8 3 11 13 2 5 6 16 4 1 15 9\n",
"output": "3 3 3 5 3 4 3 3 4 2 2 4 4 4 4 7 \n"
}
] |
https://atcoder.jp/contests/abc283/tasks/abc283_g | Problem Statement
For a sequence of non-negative integers
(a _ 1,a _ 2,\ldots,a _ n)
, let us define its
\operatorname{xor}
as the integer
X
such that, for all non-negative integer
j
:
the
2^j
s place of
X
is
1
if and only if there is an odd number of elements among
a _ 1,\ldots,a _ n
whose
2^j
s place is
1
.
You are g... | [
{
"input": "4 1 8\n2 21 17 21\n",
"output": "0 2 4 6 17 19 21 23\n"
},
{
"input": "4 3 7\n2 21 17 21\n",
"output": "4 6 17 19 21\n"
},
{
"input": "5 1 1\n0 0 0 0 0\n",
"output": "0\n"
},
{
"input": "6 21 21\n88 44 82 110 121 80\n",
"output": "41\n"
},
{
"input": "... |
https://atcoder.jp/contests/abc283/tasks/abc283_h | Problem Statement
Find the sum of popcounts of all integers between
1
and
N
, inclusive, such that the remainder when divided by
M
equals
R
.
Here, the popcount of a positive integer
X
is the number of
1
s in the binary notation of
X
, that is, the number of non-negative integers
k
such that the
2^k
s place is
1
.
For ... | [
{
"input": "2\n12 5 1\n6 1 0\n",
"output": "6\n9\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_a | 問題文
マーブリングの操作を高々
500
回行うことで,以下の画像に近い画像を作り上げよ.
後述の達成条件を満たしていれば,カラフルな画像にしてもよい. | [] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_b | 問題文
整数
N, K, P
および,文字
A
,
B
からなる長さ
N
の文字列
S
が与えられる.各
k = 1, 2, \ldots, K
に対して以下の問に答えよ (各
k
に関する問は別々に考えよ).
くろうさとしろうさが問題の速解き競争を行う.問題は
1
問ずつ出題され,
i
問目 (
i = 1, 2, \ldots
) は以下のようになる:
i \le N
かつ
S
の
i
文字目が
A
である場合,確率
\frac{P}{100}
でくろうさが先に解き,確率
1 - \frac{P}{100}
でしろうさが先に解く.
i \le N
かつ
S
の
i
文字目が
B
である場合,確率
1 - \frac{P}{100... | [
{
"input": "2 2 25\nAB\n",
"output": "-0\n"
},
{
"input": "10 4 99\nAABBBAABBB\n",
"output": "++-+\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_c | 問題文
(1,2,\ldots,N)
の順列
P=(P_1,P_2,\ldots,P_N)
と
Q=(Q_1,Q_2,\ldots,Q_N)
が与えられる.以下の操作を高々
N^2
回行って
P
を
Q
に一致させられるか判定し,可能な場合はそのような操作列を
1
通り求めよ.
次の条件のうち少なくとも一方を満たす整数
i
を選び,
P_i
と
P_{i+1}
の値を入れ替える.
1 \leq i \leq N-2
かつ
\min(P_i,P_{i+1}) < P_{i+2} < \max(P_i,P_{i+1})
2 \leq i \leq N-1
かつ
\min(P_i,P_{i+1}) < P_{i-1} < \max(P_i... | [
{
"input": "3\n2 1 3\n2 3 1\n",
"output": "1\n2\n"
},
{
"input": "3\n1 2 3\n1 3 2\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_d | 問題文
非負整数
N, A, B, C
が与えられる.
正
整数列
(x_0, x_1, \ldots, x_N)
であって,以下の条件をすべて満たすものの個数を
998244353
で割った余りを求めよ:
x_0 = 2^A \times 2^B
.
x_N = ((2^A + 1) \times 2^C) - 1
.
各
i = 0, 1, \ldots, N - 1
に対し,
x_{i+1} \in \{ \lfloor x_i/2 \rfloor, 2 x_i, 2 x_i + 1 \}
. | [
{
"input": "4 1 1 1\n",
"output": "7\n"
},
{
"input": "9 2 0 1\n",
"output": "1164\n"
},
{
"input": "1 0 2 4\n",
"output": "0\n"
},
{
"input": "2022 12 24 14\n",
"output": "426021617\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_e | 問題文
整数
P_1, P_2, \ldots, P_N
が与えられる.
N
枚のコインがあり,それぞれ
1, 2, \ldots, N
の番号が付いている.どの
2
枚のコインも区別できる.うさぎがこれからある特殊な方法でこれらのコインを一斉に投げ,各コインが表または裏のいずれか一方になる.
コイン
i
は確率
\frac{P_i}{100}
で表になり,確率
1 - \frac{P_i}{100}
で裏になることがわかっている (
1 \le i \le N
).また,どの異なる
2
枚のコイン
i, j
についても,コイン
i
が表になる事象とコイン
j
が表になる事象は独立であることがわかっている (
1 \le i, j ... | [
{
"input": "2\n13 77\n",
"output": "0.1001\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_f | 問題文
無向グラフ
G
は
1, 2, \ldots, N
を頂点とし,頂点
u
と頂点
v
を結ぶ辺はちょうど
A_{u,v}
本ある (
1 \le u, v \le N
).すべての辺は区別される.
各
k = 0, 1, \ldots, \lfloor N/2 \rfloor
に対し,
G
の大きさ
k
のマッチングの個数を
2^{64}
で割った余りを求めよ.
(
G
の大きさ
k
のマッチングとは,
G
の辺
k
本からなる集合であって,それらの端点
2 k
個が相異なるようなものを指す.) | [
{
"input": "4\n0 10 300 0\n10 0 5 400\n300 5 0 20\n0 400 20 0\n",
"output": "1 735 120200\n"
},
{
"input": "7\n0 1 1 1 1 1 1\n1 0 1 1 1 1 1\n1 1 0 1 1 1 1\n1 1 1 0 1 1 1\n1 1 1 1 0 1 1\n1 1 1 1 1 0 1\n1 1 1 1 1 1 0\n",
"output": "1 21 105 105\n"
},
{
"input": "10\n0 8629318490492529455 1... |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_g | 問題文
1
個の入力ファイルにつき
T
個のテストケースが与えられる.各テストケースで整数
N, S
が与えられるので,以下の問に答えよ.
整数
A_0, A_1, \ldots, A_{4N-1}
を以下のように定める.数式および C++ コード片で示す:
変数
s
を
s \gets S
とする.
i = 0, 1, \ldots, 4 N - 1
に対しこの順で,
A_i \gets \lfloor i/4 \rfloor + 1
とする.
i = 0, 1, \ldots, 4 N - 1
に対しこの順で,
s \gets (s \times 2022) \bmod 998244353
としてから,
s \not\equiv... | [
{
"input": "2\n3 1\n4 20221224\n",
"output": "++-\n+--+\n"
}
] |
https://atcoder.jp/contests/xmascon22/tasks/xmascon22_h | 問題文
1
個の入力ファイルにつき
T
個のテストケースが与えられる.各テストケースで次のようなグラフ
G
が与えられるので,以下の問に答えよ.
G
は
N
頂点
M
辺からなる連結な単純無向グラフである.頂点には
1
から
N
までの番号がついており,
i
番目の辺は頂点
A_i
と
B_i
を結んでいる (
1 \le i \le M
).
今,
G
の頂点はすべて白色で塗られている.これから,くろうさとしろうさが次のゲームを行う.
まず,くろうさが好きな頂点を
1
個選び,黒色で塗る.
その後,白色に塗られている頂点が存在する限り,しろうさが以下の操作を繰り返す:
黒色で塗られている頂点に隣接しているような頂点を
1
個または... | [
{
"input": "2\n3 2\n1 2\n2 3\n4 4\n1 2\n2 3\n3 4\n4 1\n",
"output": "2\n2\n"
},
{
"input": "2\n5 8\n5 1\n2 3\n2 4\n5 2\n1 3\n3 5\n1 4\n4 5\n20 40\n13 10\n13 19\n12 15\n14 7\n1 17\n8 17\n13 7\n10 7\n16 2\n5 20\n12 1\n3 12\n19 7\n8 20\n20 16\n2 5\n14 13\n3 9\n13 6\n5 16\n4 1\n2 4\n8 16\n14 10\n8 2\n11... |
https://atcoder.jp/contests/abc282/tasks/abc282_a | Problem Statement
You are given an integer
K
.
Print a string that is a concatenation of the first
K
uppercase English letters in ascending order, starting from
A
. | [
{
"input": "3\n",
"output": "ABC\n"
},
{
"input": "1\n",
"output": "A\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_b | Problem Statement
N
participants, numbered
1
to
N
, will participate in a contest with
M
problems, numbered
1
to
M
.
For an integer
i
between
1
and
N
and an integer
j
between
1
and
M
, participant
i
can solve problem
j
if the
j
-th character of
S_i
is
o
, and cannot solve it if that character is
x
.
The participants mu... | [
{
"input": "5 5\nooooo\noooxx\nxxooo\noxoxo\nxxxxx\n",
"output": "5\n"
},
{
"input": "3 2\nox\nxo\nxx\n",
"output": "1\n"
},
{
"input": "2 4\nxxxx\noxox\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_c | Problem Statement
You are given a string
S
of length
N
consisting of lowercase English letters,
,
, and
"
. It is guaranteed that
S
contains an even number of
"
.
Let
2K
be the number of
"
in
S
. For each
i=1,2,\ldots,K
, the characters from the
(2i-1)
-th
"
through the
(2i)
-th
"
are said to be
enclosed
.
Your task is... | [
{
"input": "8\n\"a,b\"c,d\n",
"output": "\"a,b\"c.d\n"
},
{
"input": "5\n,,,,,\n",
"output": ".....\n"
},
{
"input": "20\na,\"t,\"c,\"o,\"d,\"e,\"r,\n",
"output": "a.\"t,\"c.\"o,\"d.\"e,\"r.\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_d | Problem Statement
You are given a simple undirected graph
G
with
N
vertices and
M
edges (a simple graph does not contain self-loops or multi-edges).
For
i = 1, 2, \ldots, M
, the
i
-th edge connects vertex
u_i
and vertex
v_i
.
Print the number of pairs of integers
(u, v)
that satisfy
1 \leq u \lt v \leq N
and both of ... | [
{
"input": "5 4\n4 2\n3 1\n5 2\n3 2\n",
"output": "2\n"
},
{
"input": "4 3\n3 1\n3 2\n1 2\n",
"output": "0\n"
},
{
"input": "9 11\n4 9\n9 1\n8 2\n8 3\n9 2\n8 4\n6 7\n4 6\n7 5\n4 5\n7 8\n",
"output": "9\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_e | Problem Statement
A box contains
N
balls, each with an integer between
1
and
M-1
written on it.
For
i = 1, 2, \ldots, N
, the integer written on the
i
-th ball is
A_i
.
While the box has two or more balls remaining, Takahashi will repeat the following.
First, choose two balls arbitrarily.
Then, get a score equal to th... | [
{
"input": "4 10\n4 2 3 2\n",
"output": "20\n"
},
{
"input": "20 100\n29 31 68 20 83 66 23 84 69 96 41 61 83 37 52 71 18 55 40 8\n",
"output": "1733\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_f | Problem Statement
This is an
interactive task
, where your and the judge's programs interact via Standard Input and Output.
You and the judge will follow the procedure below.
The procedure consists of phases
1
and
2
; phase
1
is immediately followed by phase
2
.
(Phase
1
)
The judge gives you an integer
N
.
You print a... | [] |
https://atcoder.jp/contests/abc282/tasks/abc282_g | Problem Statement
Below, a permutation of
(1,2,\ldots,N)
is simply called a permutation.
For two permutations
A=(A_1,A_2,\ldots,A_N),B=(B_1,B_2,\ldots,B_N)
, let us define their
similarity
as the number of integers
i
between
1
and
N-1
such that:
(A_{i+1}-A_i)(B_{i+1}-B_i)>0
.
Find the number, modulo a prime number
P
, ... | [
{
"input": "3 1 282282277\n",
"output": "16\n"
},
{
"input": "50 25 998244353\n",
"output": "131276976\n"
}
] |
https://atcoder.jp/contests/abc282/tasks/abc282_h | Problem Statement
You are given two sequences of integers of length
N
:
A = (A_1, A_2, \ldots, A_N)
and
B = (B_1, B_2, \ldots, B_N)
.
Print the number of pairs of integers
(l, r)
that satisfy
1 \leq l \leq r \leq N
and the following condition.
\min\lbrace A_l, A_{l+1}, \ldots, A_r \rbrace + (B_l + B_{l+1} + \cdots + B_... | [
{
"input": "4 15\n9 2 6 5\n3 5 8 9\n",
"output": "6\n"
},
{
"input": "15 100\n39 9 36 94 40 26 12 26 28 66 73 85 62 5 20\n0 0 7 7 0 5 5 0 7 9 9 4 2 5 2\n",
"output": "119\n"
}
] |
https://atcoder.jp/contests/joi2023yo2/tasks/joi2023_yo2_a | 問題文
JOI 市には
1
から
N
までの番号が付けられた
N
人の住民がおり,住民
i
(
1 \leqq i \leqq N
) の年齢は
A_i
歳である.
JOI 市の住民の年齢
A_1, A_2, \dots, A_N
が与えられる.
i = 1, 2, \dots, N
に対して,住民
i
と他の住民との年齢の差の最大値を求めるプログラムを作成せよ. | [
{
"input": "3\n13 15 20\n",
"output": "7\n5\n7\n"
},
{
"input": "2\n100 100\n",
"output": "0\n0\n"
},
{
"input": "10\n440894064 101089692 556439322 34369336 98417847 216265879 623843484 554560874 247445405 718003331\n",
"output": "406524728\n616913639\n522069986\n683633995\n619585484... |
https://atcoder.jp/contests/joi2023yo2/tasks/joi2023_yo2_b | 問題文
JOI 中学校には
4N
人の一年生が在籍しており,
4
つのクラスに分かれている.各クラスの情報は以下の通りである.
1 年 A 組:
N
人の生徒がいる.それぞれの生徒の身長は
A_1, A_2, \ldots, A_N
である.
1 年 B 組:
N
人の生徒がいる.それぞれの生徒の身長は
B_1, B_2, \ldots, B_N
である.
1 年 C 組:
N
人の生徒がいる.それぞれの生徒の身長は
C_1, C_2, \ldots, C_N
である.
1 年 D 組:
N
人の生徒がいる.それぞれの生徒の身長は
D_1, D_2, \ldots, D_N
である.
来月,JOI 中学校では体育祭が開催されることに... | [
{
"input": "1\n169\n173\n152\n200\n",
"output": "48\n"
},
{
"input": "7\n7 9 9 4 6 3 5\n1 1 1 1 1 1 1\n1 1 1 1 1 1 1\n1 1 1 1 1 1 1\n",
"output": "2\n"
},
{
"input": "7\n1 1 1 1 2 1 1\n1 2 1 1 1 1 1\n1 1 1 1 2 1 1\n1 1 1 1 1 1 2\n",
"output": "0\n"
},
{
"input": "5\n287 690 4... |
https://atcoder.jp/contests/joi2023yo2/tasks/joi2023_yo2_c | 問題文
JOI くんはお絵かきソフトで遊んでいる.
お絵かきソフトでは,縦
H
行,横
W
列の長方形のマス目に絵を描くことができる.それぞれのマスには色が定められており,色は
1
以上
10^9
以下の整数で表される.
上から
i
行目 (
1 \leqq i \leqq H
),左から
j
列目 (
1 \leqq j \leqq W
) のマスをマス
(i,j)
と呼ぶ.現在,マス
(i,j)
の色は
A_{i,j}
である.
マス
(i,j)
から辺で接しているマスへの移動を繰り返し,マス
(i,j)
と色が異なるマスに入ることなく移動できるマスの集まりを,ここでは
マス
(i,j)
の領域
と呼ぶ.
お絵かきソフトには,... | [
{
"input": "4 4\n1 2 3 1\n2 2 3 1\n1 2 3 1\n3 3 2 2\n",
"output": "9\n"
},
{
"input": "2 10\n1 2 2 1 3 3 3 3 1 1\n1 1 1 1 1 1 1 3 3 3\n",
"output": "18\n"
},
{
"input": "5 5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n",
"output": "25\n"
}
] |
https://atcoder.jp/contests/joi2023yo2/tasks/joi2023_yo2_d | 問題文
IOI 鉄道は
1
本の鉄道路線を運営している.IOI 鉄道線には一直線上に並んだ
N
個の駅があり,順に
1
から
N
までの番号が付けられている.各
i
(
1 \leqq i \leqq N - 1
) に対して,駅
i
と駅
i + 1
の間は線路で結ばれており,その長さは
1
である.
IOI 鉄道は貨物を取り扱っている.駅
2, 3, \ldots, N
には貨物が
1
つずつ置かれており,駅
i
(
2 \leqq i \leqq N
) に置かれている貨物の価値は
A_i
である.
IOI 鉄道は貨物列車を
1
編成所有している.この列車は最初駅
1
におり,IOI 鉄道線上を双方向に走行できる.それぞれの駅... | [
{
"input": "4 1 10\n1 1 1\n",
"output": "2\n"
},
{
"input": "7 3 16\n1 1 1 1 1 1\n",
"output": "5\n"
},
{
"input": "5 2 12\n40 30 20 10\n",
"output": "100\n"
},
{
"input": "5 1 11\n2 7 1 8\n",
"output": "10\n"
},
{
"input": "9 3 14\n54640 754112 604290 105866 5919... |
https://atcoder.jp/contests/joi2023yo2/tasks/joi2023_yo2_e | 問題文
日本列島は東西に細長い列島である.日本列島は南北方向の境界線により
N
個の区画に分けられている.区画には西から順に
1
から
N
までの番号が付けられている.現在,区画
i
(
1 \leqq i \leqq N
) の標高は
A_i \: \mathrm{m}
である.
日本列島ではたびたび嵐が起きている.嵐が起きると波による浸食で各区画の標高が以下のように減少する.
強さ
x
の
西風の
嵐では,西から数えて
x
個以内の区画のうち,「それより西に自身より標高の高い区画が存在しない」ようなすべての区画の標高が
1 \: \mathrm{m}
減少する.すなわち,嵐の前の区画
i
の標高を
a_i
で表すと,
i \le... | [
{
"input": "5 7\n7 7 7 7 7\n1 3\n1 1\n3 1\n2 1\n2 5\n3 2\n3 4\n",
"output": "5\n6\n6\n"
},
{
"input": "5 7\n10 13 14 7 12\n1 5\n2 5\n3 3\n3 4\n2 5\n3 1\n3 2\n",
"output": "12\n7\n9\n11\n"
},
{
"input": "5 6\n8 6 7 8 9\n1 1\n3 1\n3 5\n1 3\n3 2\n3 3\n",
"output": "7\n9\n6\n6\n"
},
... |
https://atcoder.jp/contests/abc281/tasks/abc281_a | Problem Statement
Print all non-negative integers less than or equal to
N
in descending order. | [
{
"input": "3\n",
"output": "3\n2\n1\n0\n"
},
{
"input": "22\n",
"output": "22\n21\n20\n19\n18\n17\n16\n15\n14\n13\n12\n11\n10\n9\n8\n7\n6\n5\n4\n3\n2\n1\n0\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_b | Problem Statement
You are given a string
S
consisting of uppercase English letters and digits. Determine whether
S
satisfies the following condition.
S
is a concatenation of the following characters and string in the order listed.
An uppercase English letter
A string of length
6
that is a decimal representation of an i... | [
{
"input": "Q142857Z\n",
"output": "Yes\n"
},
{
"input": "AB912278C\n",
"output": "No\n"
},
{
"input": "X900000\n",
"output": "No\n"
},
{
"input": "K012345K\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_c | Problem Statement
We have a playlist with
N
songs numbered
1, \dots, N
.
Song
i
lasts
A_i
seconds.
When the playlist is played, song
1
, song
2
,
\ldots
, and song
N
play in this order. When song
N
ends, the playlist repeats itself, starting from song
1
again. While a song is playing, the next song does not play; when ... | [
{
"input": "3 600\n180 240 120\n",
"output": "1 60\n"
},
{
"input": "3 281\n94 94 94\n",
"output": "3 93\n"
},
{
"input": "10 5678912340\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n",
"output": "6 678912340\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_d | Problem Statement
You are given a sequence of non-negative integers
A=(a_1,a_2,\ldots,a_N)
.
Let
S
be the set of non-negative integers that can be the sum of
K
terms in
A
(with distinct indices).
Find the greatest multiple of
D
in
S
. If there is no multiple of
D
in
S
, print
-1
instead. | [
{
"input": "4 2 2\n1 2 3 4\n",
"output": "6\n"
},
{
"input": "3 1 2\n1 3 5\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_e | Problem Statement
You are given an integer sequence
A = (A_1, \dots, A_N)
of length
N
, and integers
M
and
K
.
For each
i = 1, \dots, N - M + 1
, solve the following independent problem.
Find the sum of the first
K
values in the sorted list of the
M
integers
A_i, A_{i + 1}, \dots, A_{i + M - 1}
in ascending order. | [
{
"input": "6 4 3\n3 1 4 1 5 9\n",
"output": "5 6 10\n"
},
{
"input": "10 6 3\n12 2 17 11 19 8 4 3 6 20\n",
"output": "21 14 15 13 13\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_f | Problem Statement
You are given a sequence of non-negative integers
A=(a_1,\ldots,a_N)
.
Let us perform the following operation on
A
just once.
Choose a non-negative integer
x
. Then, for every
i=1, \ldots, N
, replace the value of
a_i
with the bitwise XOR of
a_i
and
x
.
Let
M
be the maximum value in
A
after the operat... | [
{
"input": "3\n12 18 11\n",
"output": "16\n"
},
{
"input": "10\n0 0 0 0 0 0 0 0 0 0\n",
"output": "0\n"
},
{
"input": "5\n324097321 555675086 304655177 991244276 9980291\n",
"output": "805306368\n"
}
] |
https://atcoder.jp/contests/abc281/tasks/abc281_g | Problem Statement
You are given positive integers
N
and
M
.
Find the number, modulo
M
, of simple connected undirected graphs with
N
vertices numbered
1, \dots, N
that satisfy the following condition.
For every
u = 2, \dots, N-1
, the shortest distance from vertex
1
to vertex
u
is strictly smaller than the shortest dis... | [
{
"input": "4 1000000000\n",
"output": "8\n"
},
{
"input": "3 100000000\n",
"output": "1\n"
},
{
"input": "500 987654321\n",
"output": "610860515\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.