url stringlengths 49 92 | description stringlengths 22 4.78k | cases listlengths 0 6 |
|---|---|---|
https://atcoder.jp/contests/arc138/tasks/arc138_e | Problem Statement
You are given integers
N
and
K
.
Let us call an integer sequence
A=(A_1,A_2,\cdots,A_N)
good
when it satisfies all of the conditions below.
0 \leq A_i \leq i
(
1 \leq i \leq N
)
For every integer
v=1,2,\cdots,N
, there is at most one index
i
such that
A_i=v
.
Find the sum, modulo
(10^9+7)
, of the an... | [
{
"input": "3 2\n",
"output": "1\n"
},
{
"input": "6 2\n",
"output": "660\n"
},
{
"input": "10 3\n",
"output": "242595\n"
},
{
"input": "100 10\n",
"output": "495811864\n"
}
] |
https://atcoder.jp/contests/arc138/tasks/arc138_f | Problem Statement
There are
N
points in a plane, the
i
-th (
1 \leq i \leq N
) of which is
(i,P_i)
.
Here,
(P_1,P_2,\cdots,P_N)
is a permutation of
(1,2,\cdots,N)
.
You can
arrange
a non-empty set
s
of points, which is a recursive operation defined as follows.
If
s
contains exactly one point, arranging it creates a se... | [
{
"input": "3\n3 1 2\n",
"output": "3\n"
},
{
"input": "5\n1 2 3 4 5\n",
"output": "1\n"
},
{
"input": "10\n3 6 4 8 7 2 10 5 9 1\n",
"output": "1332\n"
},
{
"input": "30\n7 11 8 26 4 13 28 5 14 1 16 27 10 2 23 25 17 6 3 18 24 15 9 22 21 29 12 20 19 30\n",
"output": "64191... |
https://atcoder.jp/contests/abc246/tasks/abc246_a | Problem Statement
There is a rectangle in the
xy
-plane. Each edge of this rectangle is parallel to the
x
- or
y
-axis, and its area is not zero.
Given the coordinates of three of the four vertices of this rectangle,
(x_1, y_1)
,
(x_2, y_2)
, and
(x_3, y_3)
, find the coordinates of the other vertex. | [
{
"input": "-1 -1\n-1 2\n3 2\n",
"output": "3 -1\n"
},
{
"input": "-60 -40\n-60 -80\n-20 -80\n",
"output": "-20 -40\n"
}
] |
https://atcoder.jp/contests/abc246/tasks/abc246_b | Problem Statement
From the point
(0,0)
in a two-dimensional plane, let us move the distance of
1
toward the point
(A, B)
. Find our coordinates after the move.
Here, after moving the distance of
d
from a point
X
to a point
Y
(
d \le
length of the segment
XY
), we are at the point on the segment
XY
whose distance from
X... | [
{
"input": "3 4\n",
"output": "0.600000000000 0.800000000000\n"
},
{
"input": "1 0\n",
"output": "1.000000000000 0.000000000000\n"
},
{
"input": "246 402\n",
"output": "0.521964870245 0.852966983083\n"
}
] |
https://atcoder.jp/contests/abc246/tasks/abc246_c | Problem Statement
There are
N
items in a shop. For each
i = 1, 2, \ldots, N
, the price of the
i
-th item is
A_i
yen (the currency of Japan).
Takahashi has
K
coupons.
Each coupon can be used on one item. You can use any number of coupons, possibly zero, on the same item. Using
k
coupons on an item with a price of
a
yen... | [
{
"input": "5 4 7\n8 3 10 5 13\n",
"output": "12\n"
},
{
"input": "5 100 7\n8 3 10 5 13\n",
"output": "0\n"
},
{
"input": "20 815 60\n2066 3193 2325 4030 3725 1669 1969 763 1653 159 5311 5341 4671 2374 4513 285 810 742 2981 202\n",
"output": "112\n"
}
] |
https://atcoder.jp/contests/abc246/tasks/abc246_d | Problem Statement
Given an integer
N
, find the smallest integer
X
that satisfies all of the conditions below.
X
is greater than or equal to
N
.
There is a pair of non-negative integers
(a, b)
such that
X=a^3+a^2b+ab^2+b^3
. | [
{
"input": "9\n",
"output": "15\n"
},
{
"input": "0\n",
"output": "0\n"
},
{
"input": "999999999989449206\n",
"output": "1000000000000000000\n"
}
] |
https://atcoder.jp/contests/abc246/tasks/abc246_e | Problem Statement
We have an
N \times N
chessboard. Let
(i, j)
denote the square at the
i
-th row from the top and
j
-th column from the left of this board.
The board is described by
N
strings
S_i
.
The
j
-th character of the string
S_i
,
S_{i,j}
, means the following.
If
S_{i,j}=
.
, the square
(i, j)
is empty.
If
S_{... | [
{
"input": "5\n1 3\n3 5\n....#\n...#.\n.....\n.#...\n#....\n",
"output": "3\n"
},
{
"input": "4\n3 2\n4 2\n....\n....\n....\n....\n",
"output": "-1\n"
},
{
"input": "18\n18 1\n1 18\n..................\n.####.............\n.#..#..####.......\n.####..#..#..####.\n.#..#..###...#....\n.#..#.... |
https://atcoder.jp/contests/abc246/tasks/abc246_f | Problem Statement
We have a typewriter with
N
rows. The keys in the
i
-th row from the top can type the characters in a string
S_i
.
Let us use this keyboard to enter a string, as follows.
First, choose an integer
1 \le k \le N
.
Then, start with an empty string and only use the keys in the
k
-th row from the top to en... | [
{
"input": "2 2\nab\nac\n",
"output": "7\n"
},
{
"input": "4 3\nabcdefg\nhijklmnop\nqrstuv\nwxyz\n",
"output": "1352\n"
},
{
"input": "5 1000000000\nabc\nacde\ncefg\nabcfh\ndghi\n",
"output": "346462871\n"
}
] |
https://atcoder.jp/contests/abc246/tasks/abc246_g | Problem Statement
There is a rooted tree with
N
vertices, Vertex
1
being the root.
For each
i = 1, 2, \ldots, N-1
, the
i
-th edge connects Vertex
u_i
and Vertex
v_i
.
Each vertex other than the root has a positive integer written on it: for each
i = 2, 3, \ldots, N
, the integer written on Vertex
i
is
A_i
.
Takahas... | [
{
"input": "7\n2 4 6 5 6 10\n1 2\n1 3\n2 4\n2 5\n5 6\n5 7\n",
"output": "5\n"
},
{
"input": "30\n29 27 79 27 30 4 93 89 44 88 70 75 96 3 78 39 97 12 53 62 32 38 84 49 93 53 26 13 25\n13 15\n14 22\n17 24\n12 3\n4 3\n5 8\n26 15\n3 2\n2 9\n4 25\n4 13\n2 10\n28 15\n6 4\n2 5\n19 9\n2 7\n2 14\n23 30\n17 2... |
https://atcoder.jp/contests/abc246/tasks/abc246_h | Problem Statement
You are given a string
S
of length
N
consisting of
0
,
1
, and
?
.
You are also given
Q
queries
(x_1, c_1), (x_2, c_2), \ldots, (x_Q, c_Q)
.
For each
i = 1, 2, \ldots, Q
,
x_i
is an integer satisfying
1 \leq x_i \leq N
and
c_i
is one of the characters
0
,
1
, and
?
.
For
i = 1, 2, \ldots, Q
in this or... | [
{
"input": "3 3\n100\n2 1\n2 ?\n3 ?\n",
"output": "5\n7\n10\n"
},
{
"input": "40 10\n011?0??001??10?0??0?0?1?11?1?00?11??0?01\n5 0\n2 ?\n30 ?\n7 1\n11 1\n3 1\n25 1\n40 0\n12 1\n18 1\n",
"output": "746884092\n532460539\n299568633\n541985786\n217532539\n217532539\n217532539\n573323772\n483176957\n... |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_a | 問題文
今年のパ研合宿には、外部から
4
人の講師が参加しています。
運営長であるペンギンくんは、パ研合宿のスケジュールを管理するにあたり、合宿の日程すべてに参加する講師の数を把握したいです。
今年のパ研合宿は
4
日間からなり、
i
人目の講師は文字列
S_i
の
j
文字目が
1
なら合宿の
j
日目に参加し、
0
なら合宿の
j
日目には欠席します。遅刻や早退は考慮しません。
ペンギンくんの代わりに、合宿の日程すべてに参加する講師の数を数えてあげてください。 | [
{
"input": "1111\n0101\n0000\n1111\n",
"output": "2\n"
},
{
"input": "1111\n1111\n1111\n1111\n",
"output": "4\n"
},
{
"input": "0010\n1000\n0110\n0010\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_b | 問題文
N
人のパ研部員が、円環上に配置されています。そしてまた彼らには、時計回りに
1
から
N
までの番号が振られています。
各パ研部員にはレートと呼ばれる値が定まっており、部員
i
のレートは
A_i
です。
パ研部長であるペンギンくんは、
N
人のパ研部員を円環上で連続した
2
つのグループに分け、片方のグループに含まれるパ研部員のレートの総和を
X
に、もう片方のグループに含まれるパ研部員のレートの総和を
Y
にしたいと考えています。
これが可能かを判定してください。 | [
{
"input": "5 6 11\n3 4 2 3 5\n",
"output": "Yes\n"
},
{
"input": "4 4 8\n1 2 3 4\n",
"output": "No\n"
},
{
"input": "10 191 376\n72 6 62 98 90 61 36 82 9 51\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_c | 問題文
正整数
n,k
に対して
f_k(n)
を、
n
の
10
進法での下
k
桁の桁和で定義します。例えば、
f_2(314)=5,f_1(100)=0,f_{100}(1)=1
です。
正整数
L,R,M
が与えられるので、
\displaystyle \sum_{k=L}^R f_M(5^k)
を求めてください。 | [
{
"input": "2 4\n3\n",
"output": "28\n"
},
{
"input": "333 4444\n5\n",
"output": "77100\n"
},
{
"input": "12 998244353\n5\n",
"output": "18717081408\n"
},
{
"input": "12321 123456787654321\n16\n",
"output": "8395076630065056\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_d | 問題文
20XX年、高校教師となったペンギンくんは期末試験の作成に勤しんでいます。
N
個の問題があり、この中から
1
問以上を選んで期末試験を作成します。試験時間は
T
分と決まっていますが、選ぶ問題の数は自由です。
期末試験はペンギンくんの教え子たちによって解かれますが、その中には太郎くんと次郎くんの
2
人がいます。各
i\ (1 \leq i \leq N)
について、太郎くんが
i
問目の問題を解くのにかかる時間は
A_i
分、次郎くんがかかる時間は
B_i
分であることが分かっています。
太郎くんを贔屓したいペンギンくんは、なるべく太郎くんに有利になるような試験を作ろうとしています。使用する問題をうまく選ぶことで、(太郎... | [
{
"input": "4 8\n3 4\n5 3\n3 4\n4 5\n",
"output": "1\n"
},
{
"input": "6 10\n1 2\n2 3\n2 5\n4 7\n4 8\n5 10\n",
"output": "2\n"
},
{
"input": "10 100\n95 5\n85 70\n8 44\n71 66\n74 11\n39 2\n26 81\n29 23\n92 70\n52 57\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_e | 問題文
Paken 王国には
N
校の学校があり、
1, 2, \ldots, N
の番号が付けられています。学校
i
には最初、
A_i
人の生徒が所属しています。もちろん学校である以上、同じ人が永遠に学校に所属し続けることはできません。生徒の人数は途中で変わることがあります。
Paken 王国では毎日のように王国主催の大会が開催されており、それぞれの大会では、招待する学校の候補を表す整数組
(l, r)
を定め、学校
l, l+1, \ldots, r
のうちから 1 校のみを選び、その学校の生徒を全員招待することになっています。
さて、大会では頭を使うため、糖分補給用に参加者にお菓子が配られます。しかし、このお菓子の個数には次... | [
{
"input": "4 3\n1 2 3 4\n3 12\n1 1 3\n3 12\n",
"output": "3\n4\n"
},
{
"input": "10 5\n10 1 8 3 10 10 6 3 3 7\n3 30\n3 7\n3 4\n3 10\n3 1\n",
"output": "11\n1\n0\n5\n1\n"
},
{
"input": "20 20\n13 5 30 10 15 22 30 4 11 18 10 23 9 1 27 8 5 6 16 26\n3 60\n3 90\n2 19 11\n2 7 6\n2 5 6\n3 1287... |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_f | 問題文
define 君は 4 月にオープンする遊園地「パ研ランド」の設計をしています。この遊園地は東西に細長いことが特徴で、その入口は遊園地の最も西にあります。以下、入口から東に
k
m 進んだ場所を地点
k
と呼ぶことにします。
この遊園地にはアトラクションが
N
基 あり、
1, 2, \dots, N
の番号が振られています。アトラクション
i
は地点
i
にあります。
define 君はパ研ランドのオープン日にぺんぎん君を招待しています。ぺんぎん君は
1
m 進むのに
1
秒掛かります。ぺんぎん君は
M
回に渡ってアトラクションに乗る計画を立てており、
i
番目に乗るのはアトラクション
A_i
と決めています。
この計画... | [
{
"input": "5 6\n3 5 2 1 5 3\n2\n1 3\n2 5\n",
"output": "11\n8\n"
},
{
"input": "10 10\n3 1 4 1 2 9 3 2 7 10 \n10\n1 7\n1 4\n3 8\n6 9\n3 4\n1 8\n7 10\n4 10\n3 5\n6 9\n",
"output": "24\n27\n21\n27\n31\n23\n29\n25\n28\n27\n"
},
{
"input": "100 20\n6 97 94 50 96 51 94 86 92 77 9 73 21 9 46 ... |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_g | 問題文
パ研王国は
1
から
N
までの番号が付けられた
N
個の都市と、
1
から
M
までの番号が付けられた
M
本の道路からなります。各
i\ (1 \leq i \leq M)
について、辺
i
は都市
u_i
と都市
v_i
を双方向に結んでいます。
ペンギンくんは今、パ研王国の中を旅行する計画を立てています。彼はその計画を立てるにあたって、以下の情報を知りたがっています。
1 \leq l \leq r \leq M
を満たす整数対
(l,r)
であって、以下の条件を満たすものはいくつあるか。
ある都市
X
を出発し、道路
l
、道路
l+1
、
\cdots
、道路
r
を
好きな順番でちょうど一度ずつ
通って
都市
... | [
{
"input": "4 4\n1 2\n2 3\n3 4\n2 4\n",
"output": "1\n"
},
{
"input": "5 8\n2 3\n3 1\n2 3\n3 2\n2 5\n3 2\n1 5\n2 1\n",
"output": "3\n"
},
{
"input": "6 10\n2 6\n6 1\n1 2\n2 6\n6 4\n4 3\n3 2\n2 5\n5 3\n3 5\n",
"output": "6\n"
},
{
"input": "8 12\n7 1\n7 1\n3 7\n3 7\n6 3\n6 3\n... |
https://atcoder.jp/contests/pakencamp-2021-day3/tasks/pakencamp_2021_day3_h | 問題文
パ研王国は
1
から
N
までの番号が振られた
N
個の都市と、それらの都市間を結ぶ
M
本の道路からなります。
i
本目の道路は、都市
u_i
と都市
v_i
を双方向に結んでおり、その長さは
l_i
メートルです。
あなたの属するペンギン株式会社は、パ研王国内において貨物の輸送を行うという仕事を
K
個受注しました。
i
番目の仕事(仕事
i
とする)では、都市
s_i
にある貨物を都市
g_i
に移動させる必要があり、仕事に成功した場合
m_i
円の利益が生まれます。
ただしこの
K
個の仕事には時間制限があり、ある時刻
T
までに仕事を行うことができなかった場合得られる利益は
0
円になります。
あなたは、ペンギン株... | [
{
"input": "4 5 3 10\n1 3 4\n2 4 3\n1 4 4\n2 3 2\n3 4 2\n2 4 7\n3 1 8\n2 4 3\n",
"output": "2\n2 0 1\n3 1 \n3 7 1\n2 4\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_b | 問題文
パケンくんは、パソコン力を高めたいです。
ある日、パケンくんは問題を解くことでパソコン力を得られることに気づきました。
具体的には、難易度
x
の問題を解くと、
x^2 \times b
のパソコン力が得られます。
2
整数
a,b
が与えられるので、パケンくんが難易度
a
の問題を解いたときにいくつのパソコン力が得られるかを求め、出力してください。 | [
{
"input": "3 4\n",
"output": "36\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_c | 問題文
パ研くんは
2
日間にわたってプログラミングコンテストを開催しました。
1
日目のコンテストには
N
人が参加し、
2
日目のコンテストには
M
人が参加しました。
コンテストの参加者にはそれぞれ ID と呼ばれる整数が割り当てられていました。
1
日目の参加者の ID は順に
A_1, A_2, \ldots, A_N
で、
2
日目の参加者の ID は順に
B_1, B_2, \ldots, B_M
でした。異なる人に同じ ID が割り当てられたことはありません。
パ研くんは次の条件を満たす人の ID の一覧を欲しがっています。
1
日目のコンテストには参加しなかったが、
2
日目のコンテストには参加した。
パ研くんのか... | [
{
"input": "3 4\n1 3 4\n6 8 3 1\n",
"output": "2\n6\n8\n"
},
{
"input": "4 3\n8 4 2 1\n1 4 2\n",
"output": "0\n"
},
{
"input": "3 2\n1234 312 999\n888 519\n",
"output": "2\n519\n888\n"
},
{
"input": "10 8\n14 9 3 8 11 18 20 12 16 17\n6 4 5 18 11 14 19 20\n",
"output": "4\... |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_d | 問題文
筑駒 72 期 高校 1 年 3 学期の漢文の期末試験では、表紙に「選択問題の正答はすべて同じ選択肢で統一しています。この注意事項に気づいても試験終了までは声に出さずに秘密裡にすること。」という注意書きがなされていました。
仮にこの試験が
N
問の選択問題のみからなり、各問題は
1
から
M
までの選択肢から
1
つを選ばせるような出題形式になっていたとしましょう。
この注意書きに気づかなかったペンギンくんは、各
i\ (1 \leq i \leq N)
について
i
問目の答えを
A_i
と書いてしまいました。
ペンギンくんの正答数として考えられる値の最小値および最大値は、それぞれいくらになりますか? | [
{
"input": "3 2\n1 1 2\n",
"output": "1 2\n"
},
{
"input": "4 5\n5 1 1 5\n",
"output": "0 2\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_e | 問題文
正整数
N,M
が与えられます。すべての要素が
1
以上
M
以下である長さ
N
の正整数列
a
であって、以下の条件を満たすものの個数を
998244353
で割った余りを求めてください。
a
の長さ
2
以上の連続部分列であって、回文であるようなものが存在しない。 | [
{
"input": "2 2\n",
"output": "2\n"
},
{
"input": "3 3\n",
"output": "6\n"
},
{
"input": "314 159\n",
"output": "809839613\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_f | 問題文
正整数
N
が与えられます。
\dfrac{a}{b} < \dfrac{c}{d} < \dfrac{e}{f}
を満たす整数の組
(a,b,c,d,e,f)\ (1 \le a,b,c,d,e,f \le N)
のうち、
\dfrac{e}{f}-\dfrac{a}{b}
が最小になるものを一つ構築してください。
この問題の制約下で、
\dfrac{a}{b} < \dfrac{c}{d} < \dfrac{e}{f}
を満たす整数の組
(a,b,c,d,e,f)
は必ず存在します。 | [
{
"input": "2\n",
"output": "1 2 1 1 2 1\n"
},
{
"input": "3\n",
"output": "1 3 1 2 2 3\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_g | 問題文
パ研部長のぺんぎんくんは、パ研の部室を増やしたいと思いました。
ぺんぎんくんのいる学校には
N
個の部屋があり、部屋
1
から部屋
N
までの番号が付けられています。
また、
M
本の廊下があり、
i
番目の廊下は部屋
U_i
と部屋
V_i
を双方向に結んでいます。これらの廊下を使って移動することで、どの部屋からどの部屋にも行くことができます。
現在、パ研の部室は部屋
1
のみです。ぺんぎんくんは今日を
1
日目として、
1
日
1
回以下の操作を行うことで、
N-1
日目に全ての部屋がパ研の部室となっているようにします。
現時点でパ研の部室である部屋のいずれかと直接廊下で結ばれていてかつ現時点ではパ研の部室ではない部屋を... | [
{
"input": "3 3\n1 2\n1 3\n2 3\n0 2 3\n0 4 3\n",
"output": "7\n"
},
{
"input": "4 5\n1 3\n2 3\n3 4\n2 4\n1 4\n0 1 2 3\n0 31 41 59\n0 1 6 82\n",
"output": "115\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_h | 問題文
プラプライムくんは、以下の条件をすべて満たす整数
N
が存在するか気になっています。
1 \leq N \leq 10^{18}
N
は与えられる
M
個の情報に矛盾しない。
i
個目の情報は素数
P_i
と正整数
S_i
の組
(P_i,S_i)
からなり、
N!
は
P_i^{S_i}
で割り切れるが、
P_i^{S_i+1}
で割り切れないことを表す。
プラプライムくんのために条件を満たす
N
を
1
つ見つけてあげるか、あるいはそのような
N
が存在しないことを教えてあげてください。 | [
{
"input": "2\n2 3\n5 1\n",
"output": "5\n"
},
{
"input": "3\n2 4\n5 1\n3 5\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_i | 問題文
長さ
N-1
の正整数
A=(A_2,A_3,\ldots,A_N),B=(B_2,B_3,\ldots,B_N)
が与えられます。(添字が
2
から始まることに注意してください)
数列
A
に対して以下の操作を
10^6
回以下行って
A=B
にする方法があるか判定し、あるならば
1
つ構築してください。
整数
i\ (2 \le i)
とその倍数
j
を選び、
A_i
の値と
A_j
の値を交換する。なお、このとき
i=j
であってもよい。 | [
{
"input": "4\n3 2 4\n4 2 3\n",
"output": "1\n2 4\n"
},
{
"input": "2\n3\n4\n",
"output": "-1\n"
},
{
"input": "6\n4 1 3 2 5\n1 5 4 2 3\n",
"output": "3\n3 6\n2 4\n2 6\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_j | 問題文
正整数
N,M
と長さ
N
の整数列
T=(T_1,T_2,\ldots,T_N),A=(A_1,A_2,\ldots,A_N)
が与えられます。
すべての要素が
1
以上
M
以下である長さ
N+1
の正整数列
b=(b_1,b_2,\ldots,b_{N+1})
であって、すべての
i\ (1 \le i \le N)
について以下の条件を満たすものの個数を
998244353
で割った余りを求めてください。
T_i=0
のとき、
\min(b_i,b_{i+1})=A_i
T_i=1
のとき、
\max(b_i,b_{i+1})=A_i | [
{
"input": "2 2\n0 0\n1 2\n",
"output": "1\n"
},
{
"input": "2 4\n0 1\n1 2\n",
"output": "6\n"
},
{
"input": "15 509\n1 0 1 1 1 1 0 1 1 1 1 1 1 0 0\n367 241 241 160 160 156 156 459 395 288 288 408 505 270 270\n",
"output": "684062245\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_k | 問題文
かめ君は、文字列で遊ぶのが好きです。今日は、空文字列
s
を用意し、以下の操作を
N
回行いました。
s
を文字列
l,r
に分割する。
s
を
l\ +
()
+\ r
に置き換える。
N
回の操作後の
s
の値が
T
として与えられるので、 操作の方法として考えられるものの個数を
998244353
で割った余りを求めてください。
ただし、ある正整数
k\ (1 \le k \le N)
が存在して
k
回目の操作における
(l,r)
の組
が異なるとき、またその時に限り
2
つの操作の方法を異なるとみなします。
また、かめ君は嘘をつかないので、必ず
s=T
となる操作の方法が
1
つは存在するような
T
のみが与えられ... | [
{
"input": "3\n(())()\n",
"output": "3\n"
},
{
"input": "1\n()\n",
"output": "1\n"
},
{
"input": "7\n(()(()(())()))\n",
"output": "72\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_l | 問題文
N
頂点
M
辺の単純連結重み付き無向グラフが与えられます。頂点には
1
から
N
までの番号が、辺には
1
から
M
までの番号が振られています。辺
i
は頂点
U_i
と頂点
V_i
を結び、重みは
W_i
です。辺の重みは全て互いに異なることが保証されます。
頂点
1
から頂点
N
への、頂点の重複を許した道を考えます。通った辺の重みを順に並べた数列を
C = (C_1, C_2, \ldots, C_k)
として、次の条件を満たす道を
ジグザグ道
と定義します。
C_1 < C_2 > C_3 < \cdots
または
C_1 > C_2 < C_3 > \cdots
である。つまり、次の条件のいずれかを満たす。
任... | [
{
"input": "5 5\n1 4 4\n3 5 2\n2 3 6\n2 5 1\n3 4 3\n",
"output": "14\n"
},
{
"input": "4 3\n1 2 4\n2 3 6\n3 4 8\n",
"output": "-1\n"
},
{
"input": "7 12\n2 5 657831697\n5 6 925940778\n1 2 749029915\n2 4 237755672\n3 6 60634766\n6 7 65418621\n1 4 194639839\n4 7 411656898\n3 7 367905753\n3... |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_m | 問題文
正の整数
N
が与えられます。Natsubi くんは、空の数列
Q
を用意したうえで、
(1,2,\dots,N)
を並び替えた数列
P=(P_1, P_2, \dots, P_N)
を自由に選んで、以下の一連の操作を
N
回行います。
P
の先頭の要素を
x
として、
Q
の先頭または末尾に
x
を追加する。
P
から
x
を削除する。
Natsubi くんは、最終的な
Q
の転倒数が最小となるように適切に操作を行います。
P
として考えられるものは
N!
通りありますが、それらすべてについて操作後の
Q
の転倒数の最小値を求め、その総和を
998244353
で割ったあまりを出力してください。
転倒数とは?
(1,2,\... | [
{
"input": "4\n",
"output": "20\n"
},
{
"input": "220328\n",
"output": "192799865\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_n | 問題文
T
個のケースについて、以下の問題を解いてください。
整数
k
と
N
次の整数係数多項式
f(x)=a_Nx^N+a_{N-1}x^{N-1}+\ldots+a_0
、
M
次の整数係数多項式
g(x)=b_Mx^M+b_{M-1}x^{M-1}+\ldots+b_0
が与えられます。
f(k)
と
g(k)
の大小関係を求めてください。 | [
{
"input": "3\n2 1 3\n2 0 1\n4 5\n0 0 0\n2\n2\n5 7 -89401\n-79604 56304 -25588 -4414 73961 28352\n-6628 -12831 6978 373 -36054 82166 30928 50750\n",
"output": ">\n=\n<\n"
}
] |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_o | 問題文
文字列
S
が与えられます。
S[i:j]
で
S
の
i
文字目から
j
文字目までを取り出した文字列を表すことにします。
文字列
T
が次の条件を全て満たすとき、
T
は
良い文字列
であると定義します。
1 \leq |T| \leq |S|
S[i:i+|T|-1] = T
を満たす整数
i
はちょうど
1
つだけ存在する
例えば
S
が
abcbabc
のとき、
cb
や
abcb
、
abcbabc
は
良い文字列
ですが、
abc
や
zyx
は
良い文字列
ではありません。
Q
個のクエリが与えられるので処理してください。
i
番目のクエリでは
1 \leq L_i \leq R_i \leq |S|
を満た... | [
{
"input": "abcbabc\n5\n2 3\n2 5\n1 7\n4 4\n6 6\n",
"output": "3\n4\n7\n2\n3\n"
},
{
"input": "yyxxzzyyxx\n5\n3 3\n1 1\n10 10\n5 5\n7 7\n",
"output": "3\n5\n5\n2\n2\n"
},
{
"input": "qprrrrrpprqrrppq\n20\n7 8\n6 8\n4 7\n7 12\n6 7\n5 5\n6 8\n4 6\n4 4\n2 3\n7 11\n8 9\n6 7\n11 12\n11 15\n5 ... |
https://atcoder.jp/contests/pakencamp-2021-day2/tasks/pakencamp_2021_day2_p | 問題文
T
個のケースについて、以下の問題を解いてください。
正整数
A,M
が与えられます。
A^k \equiv k \pmod M
を満たす非負整数
k\ (k < M \times \varphi (M))
の個数を求め(
ans
とします)、条件を満たす
k
を
\min(ans,1000)
個構築してください。
ただし、
\varphi(M)
は
オイラーのファイ関数
を表します。 | [
{
"input": "1\n2 4\n",
"output": "1\n4\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_a | 問題文
4
種類の文字
U
,
T
,
P
,
C
からなる長さ
N
の文字列
S
が与えられます。
あなたは、次の操作を好きな回数行うことが出来ます。
整数
i, j \, (1 \leq i < j \leq N)
を選ぶ。
S
の
i
番目の文字と
j
番目の文字を入れ替える。
文字列
S
が以下の条件を満たすようにするために必要な操作回数の最小値を求めてください。
S
は連続部分文字列として
UTPC
を含む。
ただし、
S
は
U
,
T
,
P
,
C
をそれぞれ
1
つ以上含むことが保証されます。 | [
{
"input": "5\nUTCUP\n",
"output": "2\n"
},
{
"input": "4\nUTPC\n",
"output": "0\n"
},
{
"input": "20\nPTPUTPTUCPTUPTUPCTPC\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_b | 問題文
長さ
N
の数列
A =(A_1,A_2,\ldots,A_N), B=(B_1,B_2,\ldots,B_N)
が与えられます。
あなたは次の操作を
0
回以上好きな回数行うことができます。
整数
i\ (1 \le i \le N)
を選ぶ。
A_i
と
B_i
を入れ替える。
数列のスコアを
\displaystyle\sum_{i=1}^N \sum_{j=1}^N \mathrm{min} (A_i,B_j)
で定めます。
あなたの目標は操作後の数列のスコアを最大化することです。
スコアの最大値を達成するような操作後の数列を一つ出力してください。
そのような数列が複数存在する場合、どれを出力しても構いません。
... | [
{
"input": "2\n3\n1 2 3 \n4 5 6\n2\n1 2\n2 1\n",
"output": "4 2 6\n1 5 3\n1 2\n2 1\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_c | 問題文
赤いボールと青いボールがそれぞれ
N
個あります。
i
個目の赤いボールには整数
A_i
が、
i
個目の青いボールには整数
B_i
が書かれています。
あなたは次の操作を
0
回以上
N
回以下の好きな回数行えます。
赤いボールと青いボールを
1
個ずつ選び、食べる。
i
回目の操作では、食べたボールに書かれていた整数がそれぞれ
X, Y
であるとして、
XY + C_i
点を得る。
獲得可能な合計点数の最大値を求めてください。 | [
{
"input": "4\n6 -2 3 8\n-1 -1 7 -8\n3 2 5 4\n",
"output": "79\n"
},
{
"input": "10\n-809372 563575 -351229 -20556 -309920 85426 -952799 739479 -66554 -296504\n735902 631932 -407775 895728 302156 -968417 -963982 -894325 -804784 78537\n282707723857 731189330739 1910286918 339802329211 611404539679 29... |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_d | 問題文
以下の性質を持つ有向グラフを
Chain Graph
と呼ぶことにします。
相異なる頂点
i, j, k
について、
i \rightarrow j
と
j \rightarrow k
の辺があるとき、
i \rightarrow k
の辺も存在する。
無向グラフとしてみたときに、自己ループや多重辺が存在しない。
無向辺からなる
N
頂点の完全グラフが与えられます。頂点には
1
から
N
の番号がついています。はじめ、
N-1
本の辺が赤で塗られており、木をなしています。
i
番目の赤色の辺は
A_i
と
B_i
を結ぶ辺です。残りの辺は白色です。
あなたは、以下の操作を順番に行い、グラフの辺の色と向きを定めます。
全ての白... | [
{
"input": "3\n1 2\n2 3\n",
"output": "10\n"
},
{
"input": "5\n1 2\n1 3\n2 4\n5 2\n",
"output": "1304\n"
},
{
"input": "10\n1 2\n1 3\n4 2\n2 5\n3 6\n6 7\n8 7\n9 5\n5 10\n",
"output": "793075136\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_e | 問題文
座標平面上に
N
個の点があります。
i
個目の点は、座標
(x_i, y_i)
に位置しており、その価値は
c_i
です。
あなたの仕事は、
N
個の点からちょうど
K
個の点を選ぶことです。その後、以下のように変数を定めます。
X_{\max}
\coloneqq
選んだ点の
x
座標の最大値
X_{\min}
\coloneqq
選んだ点の
x
座標の最小値
Y_{\max}
\coloneqq
選んだ点の
y
座標の最大値
Y_{\min}
\coloneqq
選んだ点の
y
座標の最小値
S
\coloneqq
選んだ点の価値の総和
点を選び終えた後、あなたは報酬として
(X_{\max} - X_{\min}) ... | [
{
"input": "3 2\n1 3 1\n3 1 1\n3 3 2\n",
"output": "6\n"
},
{
"input": "12 5\n79 29 4\n47 96 11\n31 100 13\n89 67 13\n28 45 9\n66 70 12\n18 12 9\n21 57 14\n67 17 6\n91 12 9\n79 11 8\n67 50 6\n",
"output": "220\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_f | 問題文
あなたは、魔物の群れに遭遇しました。魔物の群れは
N
匹の魔物で構成されており、あなたの目の前に縦一列に並んでいます。前から
i
番目の魔物の体力は
h_i
です。
あなたは、以下の
2
種類の攻撃を使い分けることによって、全ての魔物を倒すことにしました。
剣で攻撃する。一番前の生き残っている魔物に、その魔物の残りの体力と同じ分のダメージを与える。
槍で攻撃する。全ての生き残っている魔物に、
1
ダメージずつ与える。
体力が
0
となった魔物は消滅します。
あなたには、直属の上官が
2
人居ます。攻撃を行うたびに、その
1
回の攻撃で与えたダメージ量に応じて上官からボーナスとして勲章が与えられます。
1
人目の上官からは、魔... | [
{
"input": "4 2 3\n3 2 1 1\n",
"output": "4\n"
},
{
"input": "5 4 5\n2 2 2 2 2\n",
"output": "4\n"
},
{
"input": "15 4 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n",
"output": "16\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_g | 問題文
あなたは
H
行
W
列の行列を持っています。行列の
i
行目、
j
列目の成分は
1
桁の正整数
S_{i, j}
です。
あなたは次の
2
種類の操作を好きな順序で、合計
H + W - 2
回行えます。
隣接する
2
行 (
i, i + 1
行目) を選び、
2
行の成分の総和の点数を得る。そして、
2
行を圧縮する。すなわち、(存在すれば)
i - 1
行目以前、
i
行目と
i + 1
行目の行ベクトルとしての和、(存在すれば)
i + 2
行目以降、をこの順に縦に連結したものに行列全体を置き換える。この操作は、行列が
2
行以上である場合に行える。
隣接する
2
列 (
j, j + 1
列目) を選び、
2
... | [
{
"input": "3 3\n314\n159\n265\n",
"output": "130\n"
},
{
"input": "10 8\n82974679\n74744362\n34499984\n86891758\n56419363\n76176864\n78392791\n71539599\n44588446\n71227999\n",
"output": "4555\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_h | 問題文
数列内の隣接する二項の差の絶対値が全て
1
であるとき、その数列を
良い数列
と呼ぶことにします。
良い数列
X
のスコアを次のように定めます。
X_{i} - X_{i-1} = 1
となる全ての
i
について
X_i
をかけあわせた値
そのような
i
が存在しない場合は
1
長さが
N
、初項が
A
、 末項が
B
であるような
良い数列
全てに対するスコアの総和を
998244353
で割った余りを出力してください。 | [
{
"input": "3 0 2\n",
"output": "2\n"
},
{
"input": "5 0 2\n",
"output": "12\n"
},
{
"input": "1877 4 12\n",
"output": "672408519\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_i | 問題文
1
から
M
までの数が一つずつ書かれた
M
枚のカードからなる山札が
N
個あります。
i
個目の山札の上から
j
枚目には、
a_{i, j}
が書かれています。
あなたはこれらの山札に対して、以下の
2
種類の操作をそれぞれ好きな順に何度でも行うことができます。
操作
1
:山札を
1
つ選び、一番上のカードを、同じ山札の一番下に移動させる。
操作
2
:
N
個の山札の一番上のカードに書かれている数が全て同じなら、それらを全て取って食べる。
全てのカードを食べるために必要な操作
1
の回数の最小値はいくつですか? | [
{
"input": "4 3\n2 3 1\n1 2 3\n2 1 3\n3 2 1\n",
"output": "4\n"
},
{
"input": "7 6\n1 2 3 4 5 6\n3 5 6 1 4 2\n2 5 4 3 6 1\n5 1 2 4 6 3\n3 2 6 5 4 1\n4 1 2 5 3 6\n6 5 4 3 1 2\n",
"output": "35\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_j | 問題文
マコトくんは以下の問題を考えました。 | [
{
"input": "2\n",
"output": "8\n"
},
{
"input": "4\n",
"output": "4944\n"
},
{
"input": "2021\n",
"output": "383310824\n"
},
{
"input": "100000\n",
"output": "143469183\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_k | 問題文
P
を素数
998244353
とします。
多項式
f(x)
に対して次の一連の操作を定めます。
f(x)
と
(1 + x^k)g(x)
の各次数の係数を
P
で割った余りが等しくなるような正の整数
k
と有限次の多項式
g(x)\neq 0
を選択する。
その後、
f(x)
を上記の
g(x)
に置き換えて
2^k
のスコアを得る。
ある多項式に対して、この操作を好きな回数行って得られるスコアの総和の最大値を多項式の
美しさ
と定めます。
数列
A=(A_0,\ldots,A_{N - 1})
と
Q
個のクエリが与えられます。
i
番目のクエリでは整数
l_i,r_i
が与えられるので、多項式
\displaysty... | [
{
"input": "6 3\n1 2 1 1 1 1\n0 2\n2 5\n2 4\n",
"output": "4\n6\n0\n"
},
{
"input": "11 2\n1 1 0 0 0 0 0 0 0 1 1\n0 10\n4 5\n",
"output": "514\n0\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_l | 問題文
縦
H
行、横
W
列のグリッド状の迷路があります。
各マスには
S
,
G
,
#
,
.
のいずれかの文字が書かれています。
i
行目
j
列目のマスに書かれている文字は
c_{i,j}
です。
#
と書かれたマスは壁になっており、そうでないマスは壁ではありません。
また、
S
と
G
は
1
つずつで、上下左右に隣接していないことが保証されます。
迷路が次の条件を満たす時、
到達可能な状態
と呼ぶことにします。
S
と書かれたマスから、
G
と書かれたマスに、上下左右に隣接する壁でないマス (つまり
#
と書かれてないマス) のみを通って到達できる。
ただし、迷路の外に出るような移動はできない。
最初、迷路は
到達... | [
{
"input": "2\n2 2\nS.\n.G\n2 3\n#G#\nS.#\n",
"output": "Bob\nAlice\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_m | 問題文
あなたの前に鍵のかかった扉が一つあります。鍵屋さんは
N
個の鍵を所有しており、その中にちょうど一つだけ正しい鍵が存在します。
i
番目の鍵が正しい鍵である確率は
p_i
%であることが分かっています。
扉は建付けが悪く、正しい鍵を選んでも扉が開くとは限りません。
i
番目の鍵を用いて扉を開こうとした場合、扉が開く確率は以下の通りです。
i
番目の鍵が正しい鍵である場合:
q_i
% の確率で扉が開く。複数回開こうとした場合は独立に判定される。
i
番目の鍵が正しい鍵でない場合:扉は開かない 。
あなたは 最初
K
円持っています。
扉が開くか、所持金が
0
円になるまで、以下の操作を行います。
鍵屋さんに
1
円支払う。... | [
{
"input": "2 2\n50 50\n50 50\n",
"output": "0.25\n"
},
{
"input": "1 2\n100\n100\n",
"output": "1\n"
},
{
"input": "10 20\n10 10 10 20 6 5 4 8 12 15\n10 20 30 40 50 60 70 80 90 10\n",
"output": "8.2045400000000000031\n"
}
] |
https://atcoder.jp/contests/utpc2021/tasks/utpc2021_n | 問題文
N
頂点の木の辺の列
E = \left(\left(X_1, Y_1\right), \ldots, \left(X_{N-1}, Y_{N-1}\right) \right)
から以下のような手順で生成される順列を
f(E)
とします。
順列
Q = (1, \ldots, N)
を準備する。
i = 1, \ldots, N - 1
の順に
Q
の
X_i
番目と
Y_i
番目の要素を入れ替える。
最終的な
Q
を
f(E)
とする。
\left(1, \ldots, N \right)
の順列
P
と
M
個の辺
(A_i, B_i)
が与えられます。
M
個の辺をすべて含み、木をなすような辺の列
E
であって、
f... | [
{
"input": "3 1\n2 3 1\n3 2\n",
"output": "Yes\n1 2\n2 3\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_a | Problem Statement
One day, Takahashi got up at exactly
B
minutes past
A
o'clock (in
24
-hour clock), and Aoki got up at exactly
D
minutes and
1
second past
C
o'clock.
If Takahashi got up earlier than Aoki, print
Takahashi
; otherwise, print
Aoki
. | [
{
"input": "7 0 6 30\n",
"output": "Aoki\n"
},
{
"input": "7 30 7 30\n",
"output": "Takahashi\n"
},
{
"input": "0 0 23 59\n",
"output": "Takahashi\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_b | Problem Statement
You are given a sequence of length
N
consisting of integers:
A=(A_1,\ldots,A_N)
.
Find the smallest non-negative integer not in
(A_1,\ldots,A_N)
. | [
{
"input": "8\n0 3 2 6 2 1 0 0\n",
"output": "4\n"
},
{
"input": "3\n2000 2000 2000\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_c | Problem Statement
You are given two sequences, each of length
N
, consisting of integers:
A=(A_1, \ldots, A_N)
and
B=(B_1, \ldots, B_N)
.
Determine whether there is a sequence of length
N
,
X=(X_1, \ldots, X_N)
, satisfying all of the conditions below.
X_i = A_i
or
X_i = B_i
, for every
i(1\leq i\leq N)
.
|X_i - X_{i+1... | [
{
"input": "5 4\n9 8 3 7 2\n1 6 2 9 5\n",
"output": "Yes\n"
},
{
"input": "4 90\n1 1 1 100\n1 2 3 100\n",
"output": "No\n"
},
{
"input": "4 1000000000\n1 1 1000000000 1000000000\n1 1000000000 1 1000000000\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_d | Problem Statement
We have a polynomial of degree
N
,
A(x)=A_Nx^N+A_{N-1}x^{N-1}+\cdots +A_1x+A_0
,
and another of degree
M
,
B(x)=B_Mx^M+B_{M-1}x^{M-1}+\cdots +B_1x+B_0
.
Here, each coefficient of
A(x)
and
B(x)
is an integer whose absolute value is at most
100
, and the leading coefficients are not
0
.
Also, let the pr... | [
{
"input": "1 2\n2 1\n12 14 8 2\n",
"output": "6 4 2\n"
},
{
"input": "1 1\n100 1\n10000 0 -1\n",
"output": "100 -1\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_e | Problem Statement
Takahashi has
N
pieces of chocolate. The
i
-th piece has a rectangular shape with a width of
A_i
centimeters and a length of
B_i
centimeters.
He also has
M
boxes. The
i
-th box has a rectangular shape with a width of
C_i
centimeters and a length of
D_i
centimeters.
Determine whether it is possible to ... | [
{
"input": "2 3\n2 4\n3 2\n8 1 5\n2 10 5\n",
"output": "Yes\n"
},
{
"input": "2 2\n1 1\n2 2\n100 1\n100 1\n",
"output": "No\n"
},
{
"input": "1 1\n10\n100\n100\n10\n",
"output": "No\n"
},
{
"input": "1 1\n10\n100\n10\n100\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_f | Problem Statement
We have a simple directed graph
G
with
N
vertices and
M
edges. The vertices are labeled as Vertex
1
, Vertex
2
,
\ldots
, Vertex
N
.
The
i
-th edge
(1\leq i\leq M)
goes from Vertex
U_i
to Vertex
V_i
.
Takahashi will start at a vertex and repeatedly travel on
G
from one vertex to another along a direc... | [
{
"input": "5 5\n1 2\n2 3\n3 4\n4 2\n4 5\n",
"output": "4\n"
},
{
"input": "3 2\n1 2\n2 1\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_g | Problem Statement
There are
N
people and
K
nations, labeled as Person
1
, Person
2
,
\ldots
, Person
N
and Nation
1
, Nation
2
,
\ldots
, Nation
K
, respectively.
Each person belongs to exactly one nation: Person
i
belongs to Nation
A_i
.
Additionally, there are
L
popular people among them: Person
B_1
, Person
B_2
,
\... | [
{
"input": "4 4 2 2\n1 1 2 2\n2 3\n1 2 15\n2 3 30\n3 4 40\n1 4 10\n",
"output": "45 30 30 25\n"
},
{
"input": "3 1 3 1\n1 2 3\n1\n1 2 1000000000\n",
"output": "-1 1000000000 -1\n"
}
] |
https://atcoder.jp/contests/abc245/tasks/abc245_h | Problem Statement
Among the sequences of length
K
consisting of integers,
A=(A_1, \ldots, A_K)
, how many satisfy all of the conditions below?
Find the count modulo
998244353
.
0\leq A_i \leq M-1
for every
i(1\leq i\leq K)
.
\displaystyle\prod_{i=1}^{K} A_i \equiv N \pmod M
. | [
{
"input": "2 3 6\n",
"output": "5\n"
},
{
"input": "10 0 2\n",
"output": "1023\n"
},
{
"input": "1000000000 20220326 1000000000000\n",
"output": "561382653\n"
}
] |
https://atcoder.jp/contests/ahc009/tasks/ahc009_a | Problem Statement
You are given a map consisting of
20\times 20
squares.
The outside of the map is surrounded by walls.
There may also be walls between adjacent squares.
Let
(0,0)
denote the top-left square, and
(i,j)
denote the square at the
i
-th row from the top and
j
-th column from the left.
Takahashi's home i... | [
{
"input": "1 2 19 16 0.10\n0010000100110011100\n1000001000001000001\n0000000000000000010\n0100000000000110100\n0000000000000000100\n1000101100000101010\n0010001011000110000\n0000001001000000000\n0000000100010001001\n0010010000100000001\n0001000010000100000\n0011010000000001000\n0000000101010100000\n00000010000... |
https://atcoder.jp/contests/abc244/tasks/abc244_a | Problem Statement
Given a string
S
of length
N
consisting of lowercase English alphabets, print the last character of
S
. | [
{
"input": "5\nabcde\n",
"output": "e\n"
},
{
"input": "1\na\n",
"output": "a\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_b | Problem Statement
Consider an
xy
-plane. The positive direction of the
x
-axis is in the direction of east, and the positive direction of the
y
-axis is in the direction of north.
Takahashi is initially at point
(x, y) = (0, 0)
and facing east (in the positive direction of the
x
-axis).
You are given a string
T = t_1t... | [
{
"input": "4\nSSRS\n",
"output": "2 -1\n"
},
{
"input": "20\nSRSRSSRSSSRSRRRRRSRR\n",
"output": "0 1\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_c | Problem Statement
Takahashi and Aoki will play the following game against each other.
Starting from Takahashi, the two alternatingly declare an integer between
1
and
2N+1
(inclusive) until the game ends.
Any integer declared by either player cannot be declared by either player again.
The player who is no longer able ... | [] |
https://atcoder.jp/contests/abc244/tasks/abc244_d | Problem Statement
There are three Takahashis numbered
1
,
2
and
3
, and three hats colored red, green, and blue. Each Takahashi is wearing one hat. The color of the hat that Takahashi
i
is currently wearing is represented by a character
S_i
. Here,
R
corresponds to red,
G
to green, and
B
to blue. Now, they will do ... | [
{
"input": "R G B\nR G B\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_e | Problem Statement
You are given a simple undirected graph with
N
vertices and
M
edges. The vertices are numbered from
1
through
N
, and the edges are numbered from
1
through
M
. Edge
i
connects Vertex
U_i
and Vertex
V_i
.
You are given integers
K, S, T
, and
X
. How many sequences
A = (A_0, A_1, \dots, A_K)
are ther... | [
{
"input": "4 4 4 1 3 2\n1 2\n2 3\n3 4\n1 4\n",
"output": "4\n"
},
{
"input": "6 5 10 1 2 3\n2 3\n2 4\n4 6\n3 6\n1 5\n",
"output": "0\n"
},
{
"input": "10 15 20 4 4 6\n2 6\n2 7\n5 7\n4 5\n2 4\n3 7\n1 7\n1 4\n2 9\n5 10\n1 3\n7 8\n7 9\n1 6\n1 2\n",
"output": "952504739\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_f | Problem Statement
You are given a simple connected undirected graph with
N
vertices and
M
edges. (A graph is said to be simple if it has no multi-edges and no self-loops.)
For
i = 1, 2, \ldots, M
, the
i
-th edge connects Vertex
u_i
and Vertex
v_i
.
A sequence
(A_1, A_2, \ldots, A_k)
is said to be a
path
of length
k
i... | [
{
"input": "3 2\n1 2\n2 3\n",
"output": "14\n"
},
{
"input": "5 5\n4 2\n2 3\n1 3\n2 1\n1 5\n",
"output": "108\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_g | Problem Statement
You are given a simple connected undirected graph with
N
vertices and
M
edges. (A graph is said to be simple if it has no multi-edges and no self-loops.)
For
i = 1, 2, \ldots, M
, the
i
-th edge connects Vertex
u_i
and Vertex
v_i
.
A sequence
(A_1, A_2, \ldots, A_k)
is said to be a
path
of length
k
i... | [
{
"input": "6 6\n6 3\n2 5\n4 2\n1 3\n6 5\n3 2\n110001\n",
"output": "9\n2 5 6 5 6 3 1 3 6\n"
},
{
"input": "3 3\n3 1\n3 2\n1 2\n000\n",
"output": "0\n\n"
}
] |
https://atcoder.jp/contests/abc244/tasks/abc244_h | Problem Statement
There is a set
S
of points on a two-dimensional plane.
S
is initially empty.
For each
i = 1, 2, \dots, Q
in this order, process the following query.
You are given integers
X_i, Y_i, A_i
, and
B_i
. Add point
(X_i, Y_i)
to
S
, and then find
\displaystyle \max_{(x,y) \in S}\left\{A_ix + B_iy\right\}
. | [
{
"input": "4\n1 0 -1 -1\n0 1 2 0\n-1 0 1 1\n0 -1 1 -2\n",
"output": "-1\n2\n1\n2\n"
},
{
"input": "9\n-1 4 -8 -2\n9 -9 -7 7\n4 1 6 7\n-4 -1 -4 -5\n-9 3 -2 -6\n-1 0 -8 5\n-8 -5 0 0\n8 3 0 -4\n2 -5 2 5\n",
"output": "0\n35\n31\n21\n36\n87\n0\n36\n31\n"
}
] |
https://atcoder.jp/contests/arc137/tasks/arc137_a | Problem Statement
You are given integers
L,R
(
L < R
).
Snuke is looking for a pair of integers
(x,y)
that satisfy both of the conditions below.
L \leq x < y \leq R
\gcd(x,y)=1
Find the maximum possible value of
(y-x)
in a pair that satisfies the conditions.
It can be proved that at least one such pair exists under th... | [
{
"input": "2 4\n",
"output": "1\n"
},
{
"input": "14 21\n",
"output": "5\n"
},
{
"input": "1 100\n",
"output": "99\n"
}
] |
https://atcoder.jp/contests/arc137/tasks/arc137_b | Problem Statement
You are given an integer sequence of length
N
consisting of
0
and
1
:
A=(A_1,A_2,\cdots,A_N)
.
You will do the operation below exactly once.
Choose a
contiguous
subsequence of
A
and flip the elements in it: convert
0
to
1
and vice versa.
Here, you may choose an empty subsequence, in which case the el... | [
{
"input": "4\n0 1 1 0\n",
"output": "4\n"
},
{
"input": "5\n0 0 0 0 0\n",
"output": "6\n"
},
{
"input": "6\n0 1 0 1 0 1\n",
"output": "3\n"
}
] |
https://atcoder.jp/contests/arc137/tasks/arc137_c | Problem Statement
You are given a non-negative integer sequence of length
N
:
A=(A_1,A_2,\cdots,A_N)
.
Here, all elements of
A
are pairwise distinct.
Alice and Bob will play a game.
They will alternately play a turn, with Alice going first.
In each turn, the player does the operation below.
Choose the largest elemen... | [
{
"input": "2\n2 4\n",
"output": "Alice\n"
},
{
"input": "3\n0 1 2\n",
"output": "Bob\n"
}
] |
https://atcoder.jp/contests/arc137/tasks/arc137_d | Problem Statement
You are given an integer sequence of length
N
:
A=(A_1,A_2,\cdots,A_N)
, and an integer
M
.
For each
k=1,2,\cdots,M
, find the value of
A_N
after doing the operation below
k
times.
For every
i
(
1 \leq i \leq N
), simultaneously, replace the value of
A_i
with
A_1 \oplus A_2 \oplus \cdots \oplus A_i
.
... | [
{
"input": "3 2\n2 1 3\n",
"output": "0 1\n"
},
{
"input": "10 12\n721939838 337089195 171851101 1069204754 348295925 77134863 839878205 89360649 838712948 918594427\n",
"output": "716176219 480674244 678890528 642764255 259091950 663009497 942498522 584528336 364872846 145822575 392655861 84465... |
https://atcoder.jp/contests/arc137/tasks/arc137_e | Problem Statement
Snuke runs a bakery.
He is planning for the next
N
days.
Let us call these days Day
1,2,\cdots,N
.
At the moment, the bakery hires nobody.
There are
M
bakers that Snuke can hire, numbered
1
to
M
.
C_i
yen must be paid to hire Baker
i
.
If Baker
i
is hired, they will work on Day
L_i, L_i+1, \cdots,... | [
{
"input": "7 4 3\n1 1 1 1 1 1 1\n1 2 3\n2 4 5\n4 6 3\n6 7 1\n",
"output": "11\n"
},
{
"input": "3 1 5\n1 1 1\n2 2 10\n",
"output": "0\n"
},
{
"input": "10 10 42\n6 5 1 5 2 4 2 7 10 9\n3 4 4\n3 7 136\n9 9 14\n2 7 152\n3 3 33\n2 4 100\n3 3 38\n1 10 28\n3 5 66\n8 8 15\n",
"output": "54... |
https://atcoder.jp/contests/arc137/tasks/arc137_f | Problem Statement
We have a bar of length
1
.
A point on the bar whose distance from the left end of the bar is
x
is said to have a coordinate
x
.
Snuke will do the operation below
N
times.
Choose two real numbers
x
and
y
uniformly at random from
[0, 1]
.
Put a sticker covering the range from the coordinate
\min(x,y)... | [
{
"input": "2 1\n",
"output": "332748118\n"
},
{
"input": "5 3\n",
"output": "66549624\n"
},
{
"input": "10000 5000\n",
"output": "642557092\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_a | Problem Statement
Three people live in Takahashi's house: Takahashi, his father, and his mother. All of them wash their hair in the bathroom each night.
His father, his mother, and Takahashi take a bath in this order and use
A
,
B
, and
C
milliliters of shampoo, respectively.
This morning, the bottle contained
V
millil... | [
{
"input": "25 10 11 12\n",
"output": "T\n"
},
{
"input": "30 10 10 10\n",
"output": "F\n"
},
{
"input": "100000 1 1 1\n",
"output": "M\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_b | Problem Statement
You are given integer sequences, each of length
N
:
A = (A_1, A_2, \dots, A_N)
and
B = (B_1, B_2, \dots, B_N)
.
All elements of
A
are different. All elements of
B
are different, too.
Print the following two values.
The number of integers contained in both
A
and
B
, appearing at the same position in th... | [
{
"input": "4\n1 3 5 2\n2 3 1 4\n",
"output": "1\n2\n"
},
{
"input": "3\n1 2 3\n4 5 6\n",
"output": "0\n0\n"
},
{
"input": "7\n4 8 1 7 9 5 6\n3 5 1 7 8 2 6\n",
"output": "3\n2\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_c | Problem Statement
There are
N
people in an
xy
-plane. Person
i
is at
(X_i, Y_i)
. The positions of all people are different.
We have a string
S
of length
N
consisting of
L
and
R
.
If
S_i =
R
, Person
i
is facing right; if
S_i =
L
, Person
i
is facing left. All people simultaneously start walking in the direction they a... | [
{
"input": "3\n2 3\n1 1\n4 1\nRRL\n",
"output": "Yes\n"
},
{
"input": "2\n1 1\n2 1\nRR\n",
"output": "No\n"
},
{
"input": "10\n1 3\n1 4\n0 0\n0 2\n0 4\n3 1\n2 4\n4 2\n4 4\n3 3\nRLRRRLRLRR\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_d | Problem Statement
There is a perfect binary tree with
2^{10^{100}}-1
vertices, numbered
1,2,...,2^{10^{100}}-1
.
Vertex
1
is the root. For each
1\leq i < 2^{10^{100}-1}
, Vertex
i
has two children: Vertex
2i
to the left and Vertex
2i+1
to the right.
Takahashi starts at Vertex
X
and performs
N
moves, represented by a st... | [
{
"input": "3 2\nURL\n",
"output": "6\n"
},
{
"input": "4 500000000000000000\nRRUU\n",
"output": "500000000000000000\n"
},
{
"input": "30 123456789\nLRULURLURLULULRURRLRULRRRUURRU\n",
"output": "126419752371\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_e | Problem Statement
You are given a simple connected undirected graph with
N
vertices and
M
edges.
Edge
i
connects Vertex
A_i
and Vertex
B_i
, and has a length of
C_i
.
Let us delete some number of edges while satisfying the conditions below. Find the maximum number of edges that can be deleted.
The graph is still connec... | [
{
"input": "3 3\n1 2 2\n2 3 3\n1 3 6\n",
"output": "1\n"
},
{
"input": "5 4\n1 3 3\n2 3 9\n3 5 3\n4 5 3\n",
"output": "0\n"
},
{
"input": "5 10\n1 2 71\n1 3 9\n1 4 82\n1 5 64\n2 3 22\n2 4 99\n2 5 1\n3 4 24\n3 5 18\n4 5 10\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_f | Problem Statement
Takahashi is participating in a lottery.
Each time he takes a draw, he gets one of the
N
prizes available. Prize
i
is awarded with probability
\frac{W_i}{\sum_{j=1}^{N}W_j}
. The results of the draws are independent of each other.
What is the probability that he gets exactly
M
different prizes from
K
... | [
{
"input": "2 1 2\n2\n1\n",
"output": "221832079\n"
},
{
"input": "3 3 2\n1\n1\n1\n",
"output": "0\n"
},
{
"input": "3 3 10\n499122176\n499122175\n1\n",
"output": "335346748\n"
},
{
"input": "10 8 15\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"output": "755239064\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_g | Problem Statement
We have a sequence of length
1
:
A=(X)
. Let us perform the following operation on this sequence
10^{100}
times.
Operation: Let
Y
be the element at the end of
A
. Choose an integer between
1
and
\sqrt{Y}
(inclusive), and append it to the end of
A
.
How many sequences are there that can result from
10^... | [
{
"input": "4\n16\n1\n123456789012\n1000000000000000000\n",
"output": "5\n1\n4555793983\n23561347048791096\n"
}
] |
https://atcoder.jp/contests/abc243/tasks/abc243_h | Problem Statement
There is a grid with
H \times W
squares. Let
(i,j)
denote the square at the
i
-th row from the top and
j
-th column from the left.
C_{i,j}
represents the state of each square. Each square is in one of the following four states.
S
: The starting point. The grid has exactly one starting point.
G
: The g... | [
{
"input": "4 3\nS..\nO..\n..O\n..G\n",
"output": "Yes\n3 6\n"
},
{
"input": "3 2\n.G\n.O\n.S\n",
"output": "No\n"
},
{
"input": "2 2\nS.\n.G\n",
"output": "Yes\n2 1\n"
},
{
"input": "10 10\nOOO...OOO.\n.....OOO.O\nOOO.OO.OOO\nOOO..O..S.\n....O.O.O.\n.OO.O.OOOO\n..OOOG.O.O\n.... |
https://atcoder.jp/contests/abc242/tasks/abc242_a | Problem Statement
In a certain programming contest, T-shirts are awarded to participants according to the following rules.
All participants who ranked
A
-th or higher get a T-shirt.
Additionally, from the participants who ranked between
(A+1)
-th and
B
-th (inclusive),
C
participants chosen uniformly at random get a T-... | [
{
"input": "30 500 20 103\n",
"output": "0.042553191489\n"
},
{
"input": "50 500 100 1\n",
"output": "1.000000000000\n"
},
{
"input": "1 2 1 1000\n",
"output": "0.000000000000\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_b | Problem Statement
You are given a string
S
. Find the lexicographically smallest string
S'
obtained by permuting the characters of
S
.
Here, for different two strings
s = s_1 s_2 \ldots s_n
and
t = t_1 t_2 \ldots t_m
,
s \lt t
holds lexicographically when one of the conditions below is satisfied.
There is an integer
i\... | [
{
"input": "aba\n",
"output": "aab\n"
},
{
"input": "zzzz\n",
"output": "zzzz\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_c | Problem Statement
Given an integer
N
, find the number of integers
X
that satisfy all of the following conditions, modulo
998244353
.
X
is an
N
-digit positive integer.
Let
X_1,X_2,\dots,X_N
be the digits of
X
from top to bottom. They satisfy all of the following:
1 \le X_i \le 9
for all integers
1 \le i \le N
;
|X_i-X... | [
{
"input": "4\n",
"output": "203\n"
},
{
"input": "2\n",
"output": "25\n"
},
{
"input": "1000000\n",
"output": "248860093\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_d | Problem Statement
You are given a string
S
consisting of
A
,
B
,
C
.
Let
S^{(0)}:=S
. For
i=1,2,3,\ldots
, let
S^{(i)}
be the result of simultaneously replacing the characters of
S^{(i-1)}
as follows:
A
→
BC
,
B
→
CA
,
C
→
AB
.
Answer
Q
queries. The
i
-th query is as follows.
Print the
k_i
-th character from the beginn... | [
{
"input": "ABC\n4\n0 1\n1 1\n1 3\n1 6\n",
"output": "A\nB\nC\nB\n"
},
{
"input": "CBBAACCCCC\n5\n57530144230160008 659279164847814847\n29622990657296329 861239705300265164\n509705228051901259 994708708957785197\n176678501072691541 655134104344481648\n827291290937314275 407121144297426665\n",
"o... |
https://atcoder.jp/contests/abc242/tasks/abc242_e | Problem Statement
Solve the following problem for
T
test cases.
Given an integer
N
and a string
S
, find the number of strings
X
that satisfy all of the conditions below, modulo
998244353
.
X
is a string of length
N
consisting of uppercase English letters.
X
is a palindrome.
X \le S
in lexicographical order.
That is,
X... | [
{
"input": "5\n3\nAXA\n6\nABCZAZ\n30\nQWERTYUIOPASDFGHJKLZXCVBNMQWER\n28\nJVIISNEOXHSNEAAENSHXOENSIIVJ\n31\nKVOHEEMSOZZASHENDIGOJRTJVMVSDWW\n",
"output": "24\n29\n212370247\n36523399\n231364016\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_f | Problem Statement
Consider placing
B
black rooks and
W
white rooks on a grid with
N
horizontal rows and
M
vertical columns.
A placement of the rooks satisfying all of the following conditions is called a
good placement
.
All
B+W
rooks are placed on the grid.
At most one rook is placed in the same square.
There is no pa... | [
{
"input": "2 2 1 1\n",
"output": "4\n"
},
{
"input": "1 2 1 1\n",
"output": "0\n"
},
{
"input": "40 40 30 30\n",
"output": "467620384\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_g | Problem Statement
N
people numbered
1,2,\dots,N
are standing in a row. Person
i
wears Color
A_i
.
Answer
Q
queries of the format below.
You are given integers
l
and
r
. Considering only Person
l,l+1,\dots,r
, how many pairs of people wearing the same color can be formed at most? | [
{
"input": "10\n1 2 3 2 3 1 3 1 2 3\n6\n6 10\n5 8\n3 6\n4 4\n1 6\n1 10\n",
"output": "2\n2\n1\n0\n3\n4\n"
}
] |
https://atcoder.jp/contests/abc242/tasks/abc242_h | Problem Statement
There are
N
squares numbered
1
to
N
. Initially, all squares are painted white.
Additionally, there are
M
balls numbered
1
to
M
in a box.
We repeat the procedure below until all squares are painted black.
Pick up a ball from a box uniformly at random.
Let
x
be the index of the ball. Paint Squares
L_x,... | [
{
"input": "3 3\n1 1\n1 2\n2 3\n",
"output": "499122180\n"
},
{
"input": "13 10\n3 5\n5 9\n3 12\n1 13\n9 11\n12 13\n2 4\n9 12\n9 11\n7 11\n",
"output": "10\n"
},
{
"input": "100 11\n22 43\n84 93\n12 71\n49 56\n8 11\n1 61\n13 80\n26 83\n23 100\n80 85\n9 89\n",
"output": "499122193\n"
... |
https://atcoder.jp/contests/past202203-open/tasks/past202203_a | Problem Statement
There are
3
cards.
The
1
-st card has an integer
A
written on it; the
2
-nd has an integer
B
; the
3
-rd has an integer
C
.
When choosing
2
cards out of these
3
cards, find the minimum and maximum possible products of the integers written on the chosen
2
cards. | [
{
"input": "5 -2 4\n",
"output": "-10 20\n"
},
{
"input": "0 0 0\n",
"output": "0 0\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_b | Problem Statement
Takahashi wants to make many bouquets. Each bouquet should consist of
A
red flowers and
B
blue flowers.
Takahashi has
X
red flowers and
Y
blue flowers. How many bouquets can he make at most? | [
{
"input": "3 2 6 4\n",
"output": "2\n"
},
{
"input": "3 3 100 0\n",
"output": "0\n"
},
{
"input": "5 10 30 23\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_c | Problem Statement
A monomial consisting of a number and an English lowercase variable is said to be a
good monomial
if an English lowercase single-letter variable is multiplied from the left by an integer coefficient between
1
and
999
(inclusive). Here, we assume that the coefficient in a good monomial is never omitte... | [
{
"input": "123456789\n",
"output": "123b\n"
},
{
"input": "77777\n",
"output": "77a\n"
},
{
"input": "9982443539982448531000000007\n",
"output": "9i\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_d | Problem Statement
Takahashi took
T
tests of the same format. Each test has
N
subjects numbered
1
to
N
.
In the
i
-th test, he scored
P_{i,j}
points in Subject
j
.
For each
K=1,2,\ldots,T
, answer the following question.
Question:
Let
C_j
be the highest score in Subject
j
in the first
K
tests.
Find
C_1+\ldots+C_N
. | [
{
"input": "2 3\n50 80 60\n60 70 70\n",
"output": "190\n210\n"
},
{
"input": "4 4\n1 2 3 4\n2 3 4 1\n4 1 2 3\n3 4 1 2\n",
"output": "10\n13\n15\n16\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_e | Problem Statement
YYYY/MM/DD format is a notation of date, consisting of the zero-padded
4
-digit year, zero-padded
2
-digit month, and zero-padded
2
-digit day, separated by slashes. For example, January
1
,
2022
is represented as
2022/01/01
.
A date is called
good
when it has two or fewer different digits in YYYY/MM/... | [
{
"input": "2022/01/01\n",
"output": "2022/02/02\n"
},
{
"input": "2002/02/22\n",
"output": "2002/02/22\n"
},
{
"input": "2002/02/23\n",
"output": "2020/02/02\n"
},
{
"input": "2999/12/31\n",
"output": "3000/03/03\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_f | Problem Statement
The Kingdom of Takahashi consists of
N
states numbered
1
to
N
.
The map of the kingdom is a grid with
H
rows and
W
columns. The square at the
i
-th row from the top and
j
-th column from the left belongs to State
A_{i,j}
.
Is the condition below satisfied when painting State
i
in Color
C_i
in this map... | [
{
"input": "2 4 3\n1 1 2 3\n1 2 2 3\n2 3 3\n",
"output": "No\n"
},
{
"input": "3 5 4\n1 1 1 3 2\n1 2 1 3 4\n1 1 1 3 2\n3 1 4 3\n",
"output": "Yes\n"
},
{
"input": "2 2 3\n1 2\n3 1\n1 2 2\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_g | Problem Statement
Assume that the equation
a x^5 + bx + c=0
satisfies the condition below.
It has exactly one solution in the interval
1\lt x \lt 2
.
Find the solution of the equation in the interval
1\lt x \lt 2
. | [
{
"input": "32 2 -246\n",
"output": "1.500000000000000000\n"
},
{
"input": "12 3 -45\n",
"output": "1.279562760087743278\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_h | Problem Statement
There is a graph with
N
vertices, numbered
1, \dots, N
. Initially, there is no edge in this graph.
Process
Q
queries of the format below.
1 u v
: Add an undirected edge connecting Vertex
u
and Vertex
v
.
2 u
: List in ascending order all indices of vertices reachable from Vertex
u
by traversing zero ... | [
{
"input": "5 7\n1 1 2\n2 2\n1 3 4\n2 5\n1 1 4\n2 1\n2 4\n",
"output": "1 2\n5\n1 2 3 4\n1 2 3 4\n"
},
{
"input": "1 2\n2 1\n2 1\n",
"output": "1\n1\n"
},
{
"input": "3 3\n1 1 2\n2 1\n1 1 2\n",
"output": "1 2\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_i | Problem Statement
Consider an infinite
xy
-plane.
You are given two sets of
N
points each:
S = \lbrace (x_1, y_1), (x_2, y_2), \ldots, (x_N, y_N) \rbrace
and
T = \lbrace (X_1, Y_1), (X_2, Y_2), \ldots, (X_N, Y_N) \rbrace
.
You may do exactly one of the two operations below zero or one time.
Choose a line parallel to th... | [
{
"input": "3\n2 3\n0 3\n0 1\n-1 3\n1 1\n1 3\n",
"output": "Yes\n"
},
{
"input": "2\n1 1\n0 0\n0 0\n-1 -1\n",
"output": "No\n"
},
{
"input": "3\n3 1\n4 1\n5 9\n5 9\n3 1\n4 1\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_j | Problem Statement
From
N
integers
A_1,A_2,\ldots,A_N
, we will choose
K
distinct integers. Here, any combination of
K
of the integers is chosen with equal probability.
Let
X
and
Y
be the maximum and minimum values among the chosen integers, respectively. Find the expected value of
X-Y
, modulo
998244353
. | [
{
"input": "3 2\n3 7 5\n",
"output": "665496238\n"
},
{
"input": "3 1\n3 7 5\n",
"output": "0\n"
},
{
"input": "10 5\n384 887 778 916 794 336 387 493 650 422\n",
"output": "621922587\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_k | Problem Statement
You are given a weighted directed graph with
N
vertices and
M
edges.
The vertices are numbered
1
to
N
.
The
i
-th edge
(1 \leq i \leq M)
goes from Vertex
u_i
to Vertex
v_i
and has a weight of
w_i
.
For each
k=1,2,\ldots,N
, solve the problem below.
Determine whether there is a path that starts at Vert... | [
{
"input": "3 3\n1 2 3\n2 3 4\n1 3 2\n",
"output": "2\n7\n2\n"
},
{
"input": "5 10\n2 1 1\n2 5 5\n1 2 6\n2 5 4\n5 3 2\n1 3 1\n1 3 4\n3 5 4\n1 5 3\n5 2 3\n",
"output": "3\n10\n5\n-1\n3\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_l | Problem Statement
Find the remainder when an integer
N
is divided by
M
.
Since
N
is enormous, it is given to you in the format below.
Format: You are given
K
characters
C_i
and
K
positive integers
D_i
. Let
S_i
be the concatenation of
D_i
copies of the character
C_i
.
N
is the concatenation of
S_1,\ldots,S_N
in this or... | [
{
"input": "3 11\n1 4\n2 2\n3 1\n",
"output": "3\n"
},
{
"input": "2 10000\n1 1\n0 1000000000000\n",
"output": "0\n"
},
{
"input": "8 5054049\n1 41421356\n1 7320508075\n2 2360679\n3 141592653589\n0 57721566\n1 644934066848\n2 99792458\n9 192631770\n",
"output": "3689688\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_m | Problem Statement
N
players called Player
1
, Player
2
,
\ldots
, Player
N
are playing a game. The initial score of Player
i
is
P_i
points.
Process
Q
queries in the order they are given.
There are three kinds of queries, as follows.
1 a x
: Change the score of Player
a
to
x
.
2 a
: Print the current rank of Player
a
a... | [
{
"input": "3 5\n10 30 20\n2 1\n3 1\n1 2 0\n2 1\n3 2\n",
"output": "3\n2\n2\n1\n"
}
] |
https://atcoder.jp/contests/past202203-open/tasks/past202203_n | Problem Statement
You are given an integer sequence
A
of length
N
.
In an
N \times N
grid, Takahashi has written the value
A_i-A_j
in the square at the
i
-th row from the top and
j
-th column from the left.
How many different values are written in the grid? | [
{
"input": "3\n5 2 3\n",
"output": "7\n"
},
{
"input": "10\n13 21 34 55 89 1 2 3 5 8\n",
"output": "75\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.