url stringlengths 49 92 | description stringlengths 22 4.78k | cases listlengths 0 6 |
|---|---|---|
https://atcoder.jp/contests/past202209-open/tasks/past202209_a | Problem Statement
There is a traffic light with a button.
In principle, if you press the button when the light is red, it turns green
X
seconds later.
However, if it would turn green earlier than
Y
seconds after it turned red last time, it turns green
Y
seconds after it turned red last time instead.
Now, the button has... | [
{
"input": "10 20 5\n",
"output": "20\n"
},
{
"input": "10 20 15\n",
"output": "25\n"
},
{
"input": "36 49 73\n",
"output": "109\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_b | Problem Statement
You are given an integer
N
.
Truncate
\displaystyle\frac{N}{100}
by discarding the fractional part and print the resulting integer. | [
{
"input": "9876\n",
"output": "98\n"
},
{
"input": "99\n",
"output": "0\n"
},
{
"input": "31415926535897932384626433832795028841971693993\n",
"output": "314159265358979323846264338327950288419716939\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_c | Problem Statement
We have three six-sided dice. When the
i
-th die is thrown, it shows the number
j
with the probability
\frac{P_{i,j}} {100}
.
If we throw these three dice, what is the probability that the sum of the numbers shown is
K
, for each
K=1,2,\ldots,18
? | [
{
"input": "10 10 20 20 20 20\n10 10 20 20 20 20\n10 10 20 20 20 20\n",
"output": "0.000000\n0.000000\n0.001000\n0.003000\n0.009000\n0.019000\n0.036000\n0.060000\n0.086000\n0.114000\n0.132000\n0.140000\n0.132000\n0.108000\n0.080000\n0.048000\n0.024000\n0.008000\n"
},
{
"input": "100 0 0 0 0 0\n100 0... |
https://atcoder.jp/contests/past202209-open/tasks/past202209_d | Problem Statement
Mr. Aoki gave Takahashi, his student, an assignment that asked him to make a simple undirected graph.
An undirected graph is
simple
when both of the following conditions are satisfied.
There are no
multi-edges
. That is, for any two vertices
u
and
v
, there is at most one edge connecting
u
and
v
.
The... | [
{
"input": "3 3\n1 2\n2 3\n3 4\n",
"output": "No\n"
},
{
"input": "2 2\n1 2\n2 1\n",
"output": "No\n"
},
{
"input": "1 1\n1 1\n",
"output": "No\n"
},
{
"input": "5 4\n1 3\n3 4\n4 1\n2 5\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_e | Problem Statement
Let us play a game of bowling consisting of
R
rounds.
Each round goes as follows.
Place
N
pins.
Repeat the following procedure
M
times.
Throw a ball toward them, and record the number of pins knocked down as the score.
Remove the pins knocked down.
If all
N
pins have been removed, end the round even i... | [
{
"input": "3 10 5 9\n7 3 0 2 4 0 1 0 10\n",
"output": "Yes\n"
},
{
"input": "1 100 3 2\n10 20\n",
"output": "No\n"
},
{
"input": "2 100 3 5\n100 10 20 30 40\n",
"output": "No\n"
},
{
"input": "3 30 100 5\n20 20 15 15 30\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_f | Problem Statement
We have
N
kinds of drugs numbered
1
to
N
.
The efficiency of a drug is represented by an integer from
1
to
100
; the greater, the more efficient. The efficiency of Drug
i
is
A_i
. (All
A_i
are distinct.)
The drugs also contain allergens (substances that cause allergic reactions). Allergens are represe... | [
{
"input": "3\n10 9 8\n3\n1 2 3\n1\n1\n2\n2 3\n4\n0\n\n1\n1\n1\n2\n2\n1 2\n",
"output": "1\n3\n2\n-1\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_g | Problem Statement
Let
S
be a string consisting of lowercase English letters and
T
be a string consisting of lowercase English letters and
?
.
S
is said to be
obtainable from
T
when one can replace each occurrence of
?
in
T
with some lowercase English letter so that
T
equals
S
.
For example,
abcd
and
addd
are obtainable... | [
{
"input": "5 4 2\naabc\nbbaa\nabbc\ncccc\nacba\n",
"output": "3\n"
},
{
"input": "5 4 4\naabc\nbbaa\nabbc\ncccc\nacba\n",
"output": "5\n"
},
{
"input": "5 4 0\naabc\nbbaa\nabbc\ncccc\nacba\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_h | Problem Statement
Takahashi has
0
gold coins,
10^9
silver coins, and
X
bronze coins.
A shop sells
N
bags.
For
i = 1, 2, \ldots, N
, the
i
-th bag can be bought by paying
A_i
silver coins and
B_i
bronze coins. The
i
-th bag contains
C_i
gold coins; by buying the bag, he obtains the gold coins in it.
A gold coin is wor... | [
{
"input": "5 4\n2 2 3\n2 2 2\n3 1 2\n1 3 1\n1 2 2\n",
"output": "5 999999997 0\n"
},
{
"input": "20 50\n4 3 7\n2 0 8\n7 2 4\n9 0 9\n6 5 8\n4 7 1\n3 9 2\n3 9 2\n7 4 4\n2 7 3\n6 3 2\n4 10 8\n2 2 10\n8 1 5\n3 2 6\n3 8 5\n8 1 9\n3 7 4\n9 6 2\n5 6 7\n",
"output": "92 999999930 0\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_i | Problem Statement
Solve the following problem for
T
test cases.
Takahashi has
10^{100}
coupons, each worth
M
yen, available in Lunlun Mart.
The shop does not give change on these coupons where the price of the purchased item is less than the value of the coupons.
On the
i
-th day, Takahashi will buy an apple worth
A \t... | [
{
"input": "10\n4 5 8\n8 9 10\n4 10 7\n10 1 5\n6 4 9\n304607 77 89\n291969 231 9\n424790 216 294\n76881 213 111\n312895 58 1\n",
"output": "14\n36\n12\n20\n24\n13402703\n875907\n61169622\n4151490\n0\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_j | Problem Statement
There is a rectangular garden that is
H
meters long and
W
meters wide.
At the center of the garden is a sprinkler, which sprays water within a radius of
D
meters from it.
Find the proportion of the area sprayed by the sprinkler in the garden. | [
{
"input": "10 15 3\n",
"output": "0.1884955592\n"
},
{
"input": "10 15 6\n",
"output": "0.6939614954\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_k | Problem Statement
There is an undirected graph with
N
vertices and
M
edges. Initially, the
i
-th edge connects Vertex
a_i
and Vertex
b_i
.
Process
Q
queries. The
i
-th query is represented by
t_i
,
x_i
, and
y_i
as follows.
If
t_i=1
, add an edge connecting Vertex
x_i
and Vertex
y_i
. There are at most
10
queries of th... | [
{
"input": "5 3\n1 3\n2 3\n4 5\n4\n1 1 4\n3 1 5\n2 2 3\n3 1 5\n",
"output": "Yes\nYes\n"
},
{
"input": "5 2\n1 3\n2 4\n2\n2 2 4\n2 1 3\n",
"output": "\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_l | Problem Statement
There are
N
paintings numbered
1, \dots, N
. We are going to choose some of them to display in an exhibition.
Takahashi the critic has decided to score the exhibition as follows:
For
i = 1, \dots, N
, add
A_i
points if Painting
i
is exhibited.
Additionally, for
j = 1 \dots, M
, add
P_j
points if all ... | [
{
"input": "3 2\n1 2 3\n4 3 2 0\n5 2 0 1\n",
"output": "8\n"
},
{
"input": "1 1\n1\n10 1 0 0\n",
"output": "10\n"
},
{
"input": "4 1\n3 1 4 1\n5 3 1 1\n",
"output": "12\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_m | Problem Statement
There is a series of manga consisting of
N
books. The
i
-th (
1 \leq i \leq N
) book is sold for
A_i
yen.
These books are also sold in sets. There are
M
sets, the
j
-th (
1 \leq j \leq M
) of which is sold for
B_j
yen and contains the
L_j
-th,
(L_j + 1)
-th,
\ldots
,
R_j
-th books of the series.
At le... | [
{
"input": "5 3\n5 4 6 2 3\n4 1 2\n7 2 4\n14 2 5\n",
"output": "14\n"
},
{
"input": "6 3\n3 1 4 1 5 9\n3 1 2\n12 4 6\n10 3 4\n",
"output": "19\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_n | Problem Statement
We have a grid with
H
horizontal rows and
W
vertical columns. The square at the
i
-th row from the top and
j
-th column from the left has a lowercase English character
a_{i,j}
written on it. Additionally, we have an empty string
S
.
Process
Q
queries in the order given by the input, and print the re... | [
{
"input": "2 2 2\nab\ncd\n1 2 x\n2 1 y\n",
"output": "dx\n"
},
{
"input": "3 4 8\nabcd\ndefg\nghij\n1 2 a\n1 2 b\n1 2 c\n1 2 d\n2 3 x\n2 3 y\n2 3 y\n2 3 y\n",
"output": "gfedibcx\n"
}
] |
https://atcoder.jp/contests/past202209-open/tasks/past202209_o | Problem Statement
There are two boxes
A
and
B
that contain balls with integers between
0
and
2^N-1
written on them. Box
A
contains
A_i
balls with the integer
i
(0 \leq i \lt 2^N)
, and Box
B
contains
B_i
balls with the integer
i
(0 \leq i \lt 2^N)
. All balls are distinguishable.
Consider picking up one ball from each ... | [
{
"input": "2 3\n3 1 4 1\n5 9 2 6\n1 1\n3 2\n2 0\n",
"output": "32\n61\n0\n"
},
{
"input": "1 1\n0 0\n1 2\n1 1\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_a | 問題文
N
頂点
M
辺からなる単純で連結な無向グラフがあります.
頂点には
1
から
N
までの番号がついており,
i
番目の辺は頂点
A_i
と頂点
B_i
を結んでいます.
(1,2,\cdots,N)
の順列
P=(P_1,P_2,\cdots,P_N)
であって,以下の条件を満たすものの個数を
998244353
で割った余りを求めてください.
頂点集合の(非空な)部分集合
S
であって,
S
による誘導部分グラフが連結になるものを考える.
この時,
S
に含まれる頂点
v
のうち,番号が最大であるものは,
P_v
の値も最大である.
つまり,
\max\{v|v \in S\}=\argmax\{P_v|v \in... | [
{
"input": "4 4\n1 2\n2 4\n4 1\n3 4\n",
"output": "3\n"
},
{
"input": "10 10\n4 8\n1 3\n6 10\n6 7\n8 7\n1 5\n4 2\n5 2\n3 9\n9 10\n",
"output": "126\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_b | 問題文
長さ
N
の整数列
A=(A_1,A_2,\cdots,A_N)
が与えられます.
あなたは以下の
2
種類の操作を好きな順序で好きな回数 (
0
回でもよい) 繰り返すことができます.
操作
1
:
A
の先頭の要素に
1
を足す.つまり,
A_1:=A_1+1
とする.
操作
2
:
A
の先頭の要素を末尾に移動する.つまり,
A:=(A_2,A_3,\cdots,A_N,A_1)
とする.
あなたの目標は,
A
を広義単調増加 (
A_1 \leq A_2 \leq \cdots \leq A_N
) にすることです.
目標達成のために必要な操作回数の最小値を求めてください. | [
{
"input": "4\n2 4 1 3\n",
"output": "3\n"
},
{
"input": "20\n786820955 250480341 710671230 946667801 19271059 404902145 251317818 22712439 520643153 344670307 274195604 561032101 140039457 543856068 521915711 857077284 499774361 419370025 744280521 249168130\n",
"output": "3774454944\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_c | 問題文
1
と
2
からなる長さ
N
の整数列
A=(A_1,A_2,\cdots,A_N)
が与えられます.
A
を
K
個の連続部分列に分割することを考えます.
この時,各部分列について,その値の総和が
3
で割り切れないようにしたいです.
このような分割が可能かどうか判定し,可能な場合は分割の方法を一つ示してください. | [
{
"input": "4 2\n1 2 2 1\n",
"output": "Yes\n1 3\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_d | 問題文
整数
N
が与えられます.
非負整数列
A=(A_1,A_2,\cdots,A_k)
であって,以下の条件を満たすものが存在するか判定してください.
また,存在するならば実際に一つ示してください.
A
の長さ
k
は
1
以上
100
以下である.
A
の各要素は
0
以上
2^{20}-1
以下の整数である.
A
の非空な(連続するとは限らない)部分列であって,その値のビット単位
\mathrm{AND}
が
0
になるものを考える.
そのような部分列の個数はちょうど
N
個である.
ただしここで,取り出す位置が異なる
2
つの部分列は,値が同じであったとしても異なるものとして扱う.
ビット単位
\mathrm{AN... | [
{
"input": "3\n",
"output": "3\n2 1 1\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_e | 問題文
長さ
2^L
の円周があります.
円周上のある点から距離
x
時計回りに進んだ点を,座標
x
の点と呼ぶことにします.
円周上で
N
個の寿司が動いています.
i
番目の寿司は時刻
0
に座標
A_i
にあり,時計回りに速度
V_i
で動いています.
また,
i
番目の寿司の価値は
W_i
です.
あなたはこれから非負
実数
t
を選びます.
そして,時刻
t
に座標
0
に存在するすべての寿司を獲得します.
あなたが獲得する寿司の価値の総和としてありうる最大値を求めてください. | [
{
"input": "3 2\n3 1 1\n2 2 2\n1 1 3\n",
"output": "5\n"
},
{
"input": "20 4\n12 10 946667801\n0 2 520643153\n5 2 543856068\n8 8 419370025\n11 5 910500853\n2 3 715892722\n15 8 459924868\n4 8 950300099\n7 2 504976377\n11 1 152036485\n15 4 361324668\n7 14 628902494\n12 12 69837030\n7 7 596982638\n1 10... |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_f | 問題文
1
から
N
までの番号のついた
N
台のサーバーがあります.
すぬけくんは,秘伝のレシピをサーバー
1
に保存しました.
他のサーバーにはレシピは保存されていません.
これから
N(N-1)/2
回,すぬけくんは以下の操作を行います.
相異なる
2
つのサーバーを選ぶ.
ただし,選ぶサーバーの組は,今まで選んだことのない組でなければならない.
なお,組
(x,y)
は組
(y,x)
と同一とみなす.
操作前の段階で少なくとも一方のサーバーがレシピを保存している場合,操作後には両方のサーバーにレシピが保存される.
操作を行う方法は,
(N(N-1)/2)!
通りあります.
このうち,以下の条件を満たす方法が何通り... | [
{
"input": "3\n1 3\n",
"output": "2\n"
},
{
"input": "3\n1 1\n",
"output": "0\n"
},
{
"input": "4\n1 2 6\n",
"output": "48\n"
},
{
"input": "13\n62 20 56 74 2 32 20 2 41 27 22 44\n",
"output": "665691201\n"
}
] |
https://atcoder.jp/contests/jsc2022-final-open/tasks/jsc2022_final_g | 問題文
整数
N
が与えられます.
1
から
N
までの番号のついた
N
頂点からなる無向グラフ
G
を考えます.
以下の条件をすべて満たすグラフ
G
の個数を
998244353
で割った余りを求めてください.
G
は多重辺や自己ループを含まない.
G
は連結である.
G
の頂点集合の分割
\{S_1,S_2,\cdots\}
であって,以下の条件をみたすものが存在する.
各
S_i
について,
|S_i| \geq 2
である.
各
S_i
について,
S_i
による誘導部分グラフは,連結な二部グラフである.
誘導部分グラフとは
S
をグラフ
G
の頂点の部分集合とします.
このとき,
G
の
S
による誘導部分グラフとは,... | [
{
"input": "2\n",
"output": "1\n"
},
{
"input": "3\n",
"output": "3\n"
},
{
"input": "4\n",
"output": "38\n"
},
{
"input": "5\n",
"output": "712\n"
},
{
"input": "12345\n",
"output": "503682022\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_a | 問題文
N
頂点
M
辺からなる単純で連結な無向グラフがあります.
頂点には
1
から
N
までの番号がついており,
i
番目の辺は頂点
A_i
と頂点
B_i
を結んでいます.
(1,2,\cdots,N)
の順列
P=(P_1,P_2,\cdots,P_N)
であって,以下の条件を満たすものの個数を
998244353
で割った余りを求めてください.
頂点集合の(非空な)部分集合
S
であって,
S
による誘導部分グラフが連結になるものを考える.
この時,
S
に含まれる頂点
v
のうち,番号が最大であるものは,
P_v
の値も最大である.
つまり,
\max\{v|v \in S\}=\argmax\{P_v|v \in... | [
{
"input": "4 4\n1 2\n2 4\n4 1\n3 4\n",
"output": "3\n"
},
{
"input": "10 10\n4 8\n1 3\n6 10\n6 7\n8 7\n1 5\n4 2\n5 2\n3 9\n9 10\n",
"output": "126\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_b | 問題文
長さ
N
の整数列
A=(A_1,A_2,\cdots,A_N)
が与えられます.
あなたは以下の
2
種類の操作を好きな順序で好きな回数 (
0
回でもよい) 繰り返すことができます.
操作
1
:
A
の先頭の要素に
1
を足す.つまり,
A_1:=A_1+1
とする.
操作
2
:
A
の先頭の要素を末尾に移動する.つまり,
A:=(A_2,A_3,\cdots,A_N,A_1)
とする.
あなたの目標は,
A
を広義単調増加 (
A_1 \leq A_2 \leq \cdots \leq A_N
) にすることです.
目標達成のために必要な操作回数の最小値を求めてください. | [
{
"input": "4\n2 4 1 3\n",
"output": "3\n"
},
{
"input": "20\n786820955 250480341 710671230 946667801 19271059 404902145 251317818 22712439 520643153 344670307 274195604 561032101 140039457 543856068 521915711 857077284 499774361 419370025 744280521 249168130\n",
"output": "3774454944\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_c | 問題文
1
と
2
からなる長さ
N
の整数列
A=(A_1,A_2,\cdots,A_N)
が与えられます.
A
を
K
個の連続部分列に分割することを考えます.
この時,各部分列について,その値の総和が
3
で割り切れないようにしたいです.
このような分割が可能かどうか判定し,可能な場合は分割の方法を一つ示してください. | [
{
"input": "4 2\n1 2 2 1\n",
"output": "Yes\n1 3\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_d | 問題文
整数
N
が与えられます.
非負整数列
A=(A_1,A_2,\cdots,A_k)
であって,以下の条件を満たすものが存在するか判定してください.
また,存在するならば実際に一つ示してください.
A
の長さ
k
は
1
以上
100
以下である.
A
の各要素は
0
以上
2^{20}-1
以下の整数である.
A
の非空な(連続するとは限らない)部分列であって,その値のビット単位
\mathrm{AND}
が
0
になるものを考える.
そのような部分列の個数はちょうど
N
個である.
ただしここで,取り出す位置が異なる
2
つの部分列は,値が同じであったとしても異なるものとして扱う.
ビット単位
\mathrm{AN... | [
{
"input": "3\n",
"output": "3\n2 1 1\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_e | 問題文
長さ
2^L
の円周があります.
円周上のある点から距離
x
時計回りに進んだ点を,座標
x
の点と呼ぶことにします.
円周上で
N
個の寿司が動いています.
i
番目の寿司は時刻
0
に座標
A_i
にあり,時計回りに速度
V_i
で動いています.
また,
i
番目の寿司の価値は
W_i
です.
あなたはこれから非負
実数
t
を選びます.
そして,時刻
t
に座標
0
に存在するすべての寿司を獲得します.
あなたが獲得する寿司の価値の総和としてありうる最大値を求めてください. | [
{
"input": "3 2\n3 1 1\n2 2 2\n1 1 3\n",
"output": "5\n"
},
{
"input": "20 4\n12 10 946667801\n0 2 520643153\n5 2 543856068\n8 8 419370025\n11 5 910500853\n2 3 715892722\n15 8 459924868\n4 8 950300099\n7 2 504976377\n11 1 152036485\n15 4 361324668\n7 14 628902494\n12 12 69837030\n7 7 596982638\n1 10... |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_f | 問題文
1
から
N
までの番号のついた
N
台のサーバーがあります.
すぬけくんは,秘伝のレシピをサーバー
1
に保存しました.
他のサーバーにはレシピは保存されていません.
これから
N(N-1)/2
回,すぬけくんは以下の操作を行います.
相異なる
2
つのサーバーを選ぶ.
ただし,選ぶサーバーの組は,今まで選んだことのない組でなければならない.
なお,組
(x,y)
は組
(y,x)
と同一とみなす.
操作前の段階で少なくとも一方のサーバーがレシピを保存している場合,操作後には両方のサーバーにレシピが保存される.
操作を行う方法は,
(N(N-1)/2)!
通りあります.
このうち,以下の条件を満たす方法が何通り... | [
{
"input": "3\n1 3\n",
"output": "2\n"
},
{
"input": "3\n1 1\n",
"output": "0\n"
},
{
"input": "4\n1 2 6\n",
"output": "48\n"
},
{
"input": "13\n62 20 56 74 2 32 20 2 41 27 22 44\n",
"output": "665691201\n"
}
] |
https://atcoder.jp/contests/jsc2022-final/tasks/jsc2022_final_g | 問題文
整数
N
が与えられます.
1
から
N
までの番号のついた
N
頂点からなる無向グラフ
G
を考えます.
以下の条件をすべて満たすグラフ
G
の個数を
998244353
で割った余りを求めてください.
G
は多重辺や自己ループを含まない.
G
は連結である.
G
の頂点集合の分割
\{S_1,S_2,\cdots\}
であって,以下の条件をみたすものが存在する.
各
S_i
について,
|S_i| \geq 2
である.
各
S_i
について,
S_i
による誘導部分グラフは,連結な二部グラフである.
誘導部分グラフとは
S
をグラフ
G
の頂点の部分集合とします.
このとき,
G
の
S
による誘導部分グラフとは,... | [
{
"input": "2\n",
"output": "1\n"
},
{
"input": "3\n",
"output": "3\n"
},
{
"input": "4\n",
"output": "38\n"
},
{
"input": "5\n",
"output": "712\n"
},
{
"input": "12345\n",
"output": "503682022\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_a | Problem Statement
You are given an odd-length string
S
consisting of lowercase English letters.
Print the central character of
S
.
What is the central character?
For an odd-length string
T
, its central character is the
\frac{|T|+1}{2}
-th character from the beginning, where
|T|
is the length of
T
. | [
{
"input": "atcoder\n",
"output": "o\n"
},
{
"input": "a\n",
"output": "a\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_b | Problem Statement
You are given an integer
N
between
-10^{18}
and
10^{18}
(inclusive).
Find an integer
x
between
0
and
998244353 - 1
(inclusive) that satisfies the following condition. It can be proved that such an integer is unique.
N-x
is a multiple of
998244353
. | [
{
"input": "998244354\n",
"output": "1\n"
},
{
"input": "-9982443534\n",
"output": "998244349\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_c | Problem Statement
Consider a two-dimensional coordinate plane, where the
x
-axis is oriented to the right, and the
y
-axis is oriented upward.
In this plane, there is a quadrilateral without self-intersection.
The coordinates of the four vertices are
(A_x,A_y)
,
(B_x,B_y)
,
(C_x,C_y)
, and
(D_x,D_y)
, in counter-clockw... | [
{
"input": "0 0\n1 0\n1 1\n0 1\n",
"output": "Yes\n"
},
{
"input": "0 0\n1 1\n-1 0\n1 -1\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_d | Problem Statement
Takahashi is trying to catch many Snuke.
There are five pits at coordinates
0
,
1
,
2
,
3
, and
4
on a number line, connected to Snuke's nest.
Now,
N
Snuke will appear from the pits. It is known that the
i
-th Snuke will appear from the pit at coordinate
X_i
at time
T_i
, and its size is
A_i
.
Takahas... | [
{
"input": "3\n1 0 100\n3 3 10\n5 4 1\n",
"output": "101\n"
},
{
"input": "3\n1 4 1\n2 4 1\n3 4 1\n",
"output": "0\n"
},
{
"input": "10\n1 4 602436426\n2 1 623690081\n3 3 262703497\n4 4 628894325\n5 3 450968417\n6 1 161735902\n7 1 707723857\n8 2 802329211\n9 0 317063340\n10 2 125660016\n... |
https://atcoder.jp/contests/abc266/tasks/abc266_e | Problem Statement
Let us play a game using a die. The game consists of at most
N
turns, each of which goes as follows.
Throw a
6
-sided die that shows
1,\ldots,6
with equal probability, and let
X
be the number shown (each throw is independent of the others).
If it is the
N
-th turn now, your
score
is
X
, and the game e... | [
{
"input": "1\n",
"output": "3.5000000000\n"
},
{
"input": "2\n",
"output": "4.2500000000\n"
},
{
"input": "10\n",
"output": "5.6502176688\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_f | Problem Statement
You are given a connected simple undirected graph
G
with
N
vertices numbered
1
to
N
and
N
edges. The
i
-th edge connects Vertex
u_i
and Vertex
v_i
bidirectionally.
Answer the following
Q
queries.
Determine whether there is a unique simple path from Vertex
x_i
to Vertex
y_i
(a simple path is a path wit... | [
{
"input": "5\n1 2\n2 3\n1 3\n1 4\n2 5\n3\n1 2\n1 4\n1 5\n",
"output": "No\nYes\nNo\n"
},
{
"input": "10\n3 5\n5 7\n4 8\n2 9\n1 2\n7 9\n1 6\n4 10\n2 5\n2 10\n10\n1 8\n6 9\n8 10\n6 8\n3 10\n3 9\n1 10\n5 8\n1 10\n7 8\n",
"output": "Yes\nNo\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nNo\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_g | Problem Statement
You are given integers
R
,
G
,
B
, and
K
. How many strings
S
consisting of
R
,
G
, and
B
satisfy all of the conditions below? Find the count modulo
998244353
.
The number of occurrences of
R
,
G
, and
B
in
S
are
R
,
G
, and
B
, respectively.
The number of occurrences of
RG
as (contiguous) substrings ... | [
{
"input": "2 1 1 1\n",
"output": "6\n"
},
{
"input": "1000000 1000000 1000000 1000000\n",
"output": "80957240\n"
}
] |
https://atcoder.jp/contests/abc266/tasks/abc266_h | Problem Statement
Takahashi is trying to catch many Snuke.
There are some pits in a two-dimensional coordinate plane, connected to Snuke's nest.
Now,
N
Snuke will appear from the pits. It is known that the
i
-th Snuke will appear from the pit at coordinates
(X_i,Y_i)
at time
T_i
, and its size is
A_i
.
Takahashi is at ... | [
{
"input": "3\n1 0 0 100\n3 2 1 10\n5 3 1 1\n",
"output": "101\n"
},
{
"input": "2\n100 0 1 1\n200 1 0 10\n",
"output": "10\n"
},
{
"input": "10\n797829355 595605750 185676190 353195922\n913575467 388876063 395940406 533206504\n810900084 201398242 159760440 87027328\n889089200 220046203 ... |
https://atcoder.jp/contests/abc265/tasks/abc265_a | Problem Statement
A fruit store sells apples.
You may perform the following operations as many times as you want in any order:
Buy one apple for
X
yen (the currency in Japan).
Buy three apples for
Y
yen.
How much yen do you need to pay to obtain
exactly
N
apples? | [
{
"input": "10 25 10\n",
"output": "85\n"
},
{
"input": "10 40 10\n",
"output": "100\n"
},
{
"input": "100 100 2\n",
"output": "200\n"
},
{
"input": "100 100 100\n",
"output": "3400\n"
}
] |
https://atcoder.jp/contests/abc265/tasks/abc265_b | Problem Statement
Takahashi is exploring a cave in a video game.
The cave consists of
N
rooms arranged in a row. The rooms are numbered Room
1,2,\ldots,N
from the entrance.
Takahashi is initially in Room
1
, and the
time limit
is
T
.
For each
1 \leq i \leq N-1
, he may consume a time of
A_i
to move from Room
i
to Room... | [
{
"input": "4 1 10\n5 7 5\n2 10\n",
"output": "Yes\n"
},
{
"input": "4 1 10\n10 7 5\n2 10\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc265/tasks/abc265_c | Problem Statement
We have a grid with
H
horizontal rows and
W
vertical columns.
(i, j)
denotes the square at the
i
-th row from the top and
j
-th column from the left.
(i,j)
has a character
G_{i,j}
written on it.
G_{i,j}
is
U
,
D
,
L
, or
R
.
You are initially at
(1,1)
. You repeat the following operation until you ca... | [
{
"input": "2 3\nRDU\nLRU\n",
"output": "1 3\n"
},
{
"input": "2 3\nRRD\nULL\n",
"output": "-1\n"
},
{
"input": "9 44\nRRDDDDRRRDDDRRRRRRDDDRDDDDRDDRDDDDDDRRDRRRRR\nRRRDLRDRDLLLLRDRRLLLDDRDLLLRDDDLLLDRRLLLLLDD\nDRDLRLDRDLRDRLDRLRDDLDDLRDRLDRLDDRLRRLRRRDRR\nDDLRRDLDDLDDRLDDLDRDDRDDDDRLRRL... |
https://atcoder.jp/contests/abc265/tasks/abc265_d | Problem Statement
There is a sequence
A=(A_0,\ldots,A_{N-1})
of length
N
.
Determine if there exists a tuple of integers
(x,y,z,w)
that satisfies all of the following conditions:
0 \leq x < y < z < w \leq N
A_x + A_{x+1} + \ldots + A_{y-1} = P
A_y + A_{y+1} + \ldots + A_{z-1} = Q
A_z + A_{z+1} + \ldots + A_{w-1} = R | [
{
"input": "10 5 7 5\n1 3 2 2 2 3 1 4 3 2\n",
"output": "Yes\n"
},
{
"input": "9 100 101 100\n31 41 59 26 53 58 97 93 23\n",
"output": "No\n"
},
{
"input": "7 1 1 1\n1 1 1 1 1 1 1\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc265/tasks/abc265_e | Problem Statement
Takahashi is at the origin of a two-dimensional plane.
Takahashi will repeat teleporting
N
times. In each teleportation, he makes one of the following moves:
Move from the current coordinates
(x,y)
to
(x+A,y+B)
Move from the current coordinates
(x,y)
to
(x+C,y+D)
Move from the current coordinates
(x,... | [
{
"input": "2 2\n1 1 1 2 1 3\n1 2\n2 2\n",
"output": "5\n"
},
{
"input": "10 3\n-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000\n-1000000000 -1000000000\n1000000000 1000000000\n-1000000000 1000000000\n",
"output": "0\n"
},
{
"input": "300 0\n0 0 1 0 0 1\n",
"outp... |
https://atcoder.jp/contests/abc265/tasks/abc265_f | Problem Statement
In an
N
-dimensional space, the Manhattan distance
d(x,y)
between two points
x=(x_1, x_2, \dots, x_N)
and
y = (y_1, y_2, \dots, y_N)
is defined by:
\displaystyle d(x,y)=\sum_{i=1}^n \vert x_i - y_i \vert.
A point
x=(x_1, x_2, \dots, x_N)
is said to be a lattice point if the components
x_1, x_2, \dots,... | [
{
"input": "1 5\n0\n3\n",
"output": "8\n"
},
{
"input": "3 10\n2 6 5\n2 1 2\n",
"output": "632\n"
},
{
"input": "10 100\n3 1 4 1 5 9 2 6 5 3\n2 7 1 8 2 8 1 8 2 8\n",
"output": "145428186\n"
}
] |
https://atcoder.jp/contests/abc265/tasks/abc265_g | Problem Statement
You are given a sequence
A=(A_1,\ldots,A_N)
of length
N
. Each element is
0
,
1
, or
2
.
Process
Q
queries in order. Each query is of one of the following kinds:
1 L R
: print the inversion number of the sequence
(A_L,\ldots,A_R)
.
2 L R S T U
: for each
i
such that
L\leq i \leq R
, if
A_i
is
0
, re... | [
{
"input": "5 3\n2 0 2 1 0\n1 2 5\n2 2 4 2 1 0\n1 2 5\n",
"output": "3\n4\n"
},
{
"input": "3 3\n0 1 2\n1 1 1\n2 1 3 0 0 0\n1 1 3\n",
"output": "0\n0\n"
}
] |
https://atcoder.jp/contests/abc265/tasks/abc265_h | Problem Statement
There is a grid with
H
horizontal rows and
W
vertical columns, and
(2 \times H)
pieces. We consider the following game using them.
Two players take alternating turns. The game progresses as follows.
In the initial state, every row contains one piece of the first player facing left and one piece of t... | [
{
"input": "1 3\n",
"output": "2\n"
},
{
"input": "9 9\n",
"output": "583962987\n"
},
{
"input": "265 30\n",
"output": "366114675\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_a | Problem Statement
There are
N
cards, numbered
1
to
N
.
Card
i
has a positive integer
A_i
written on it.
You can choose three of these cards and concatenate the integers written on them in any order you like to make a new integer. For example, if you choose cards with
1
,
23
, and
4
written on them, you can make integer... | [
{
"input": "5\n1 4 3 5 8\n",
"output": "854\n"
},
{
"input": "8\n813 921 481 282 120 900 555 409\n",
"output": "921900813\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_b | Problem Statement
You are given a sequence of
N
non-negative integers:
A=(A_1,A_2,\dots,A_N)
. You may perform the following operation at most
M
times (possibly zero):
choose an integer
i
such that
1 \le i \le N
and add
1
to
A_i
.
Then, you will choose
K
of the elements of
A
.
Find the maximum possible value of the bit... | [
{
"input": "4 8 2\n1 2 4 8\n",
"output": "10\n"
},
{
"input": "5 345 3\n111 192 421 390 229\n",
"output": "461\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_c | Problem Statement
How many sets
S
consisting of non-negative integers between
0
and
2^N-1
(inclusive) satisfy the following condition? Print the count modulo
998244353
.
Every non-empty subset
T
of
S
satisfies at least one of the following:
The number of elements in
T
is odd.
The
\mathrm{XOR}
of the elements in
T
is no... | [
{
"input": "2\n",
"output": "15\n"
},
{
"input": "146\n",
"output": "743874490\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_d | Problem Statement
A
fantastic IS
is an integer sequence of length
N
whose every element is between
1
and
M
(inclusive) that satisfies the following condition.
For every integer
i
such that
1 \le i \le K
, one of the following holds.
A_{P_i} < X_i
and
A_{Q_i} < Y_i
;
A_{P_i} = X_i
and
A_{Q_i} = Y_i
;
A_{P_i} > X_i
and
A... | [
{
"input": "3 4 3\n3 1 1 2\n1 1 2 2\n3 4 1 4\n",
"output": "6\n"
},
{
"input": "2 2 2\n1 1 2 2\n2 1 1 2\n",
"output": "-1\n"
},
{
"input": "5 10 10\n4 1 2 7\n5 1 3 2\n2 9 4 4\n5 4 2 9\n2 9 1 9\n4 8 3 10\n5 7 1 5\n3 5 1 2\n3 8 2 10\n2 9 4 8\n",
"output": "12\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_e | Problem Statement
You are given a sequence of
N
positive integers:
A=(A_1,A_2,\dots,A_N)
.
How many integer sequences
B
consisting of integers between
1
and
N
(inclusive) satisfy all of the following conditions? Print the count modulo
998244353
.
For each integer
i
such that
1 \le i \le N
, there are exactly
A_i
occurr... | [
{
"input": "3\n2 3 1\n",
"output": "6\n"
},
{
"input": "1\n200000\n",
"output": "0\n"
},
{
"input": "6\n12100 31602 41387 41498 31863 12250\n",
"output": "750337372\n"
}
] |
https://atcoder.jp/contests/arc146/tasks/arc146_f | Problem Statement
The following process is carried out on a permutation
P
of
(1,2,\dots,N)
.
We have
N
cards, numbered
1
to
N
. Card
i
has the integer
P_i
written on it.
There are an integer
X=1
and a boy called PCT, who initially has nothing. PCT does the following procedure for each
i=1,2,\dots,N
in this order.
Get C... | [
{
"input": "3 2\n",
"output": "1\n"
},
{
"input": "3 3\n",
"output": "5\n"
},
{
"input": "146146 146\n",
"output": "103537573\n"
}
] |
https://atcoder.jp/contests/agc058/tasks/agc058_a | Problem Statement
You are given a permutation
P=(P_1,P_2,\cdots,P_{2N})
of
(1,2,\cdots,2N)
.
The following operation may be performed between
0
and
N
times (inclusive).
Choose an integer
x
(
1 \leq x \leq 2N-1
). Swap the values of
P_x
and
P_{x+1}
.
Present a sequence of operations that make
P
satisfy the following con... | [
{
"input": "2\n4 3 2 1\n",
"output": "2\n1 3\n"
},
{
"input": "1\n1 2\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/agc058/tasks/agc058_b | Problem Statement
You are given a permutation
P=(P_1,P_2,\cdots,P_N)
of
(1,2,\cdots,N)
.
You may perform the following operation zero or more times.
Choose an integer
i
(
1 \leq i \leq N-1
).
Let
v=\max(P_i,P_{i+1})
and replace the values of
P_i
and
P_{i+1}
with
v
.
How many sequences are there that
P
can be after you... | [
{
"input": "3\n1 3 2\n",
"output": "4\n"
},
{
"input": "4\n2 1 3 4\n",
"output": "11\n"
},
{
"input": "10\n4 9 6 3 8 10 1 2 7 5\n",
"output": "855\n"
}
] |
https://atcoder.jp/contests/agc058/tasks/agc058_c | Problem Statement
There are
N
vertices on a circumference.
The vertices are numbered
1
to
N
in clockwise order, and Vertex
i
has an integer
A_i
written on it, where
A_i
is
1
,
2
,
3
, or
4
. Here,
A
contains each of
1
,
2
,
3
, and
4
at least once.
Consider making a tree by adding
N-1
edges connecting these
N
vertices... | [
{
"input": "3\n4\n1 2 3 4\n4\n1 3 4 2\n4\n1 4 2 3\n",
"output": "Yes\nYes\nNo\n"
},
{
"input": "3\n8\n4 2 3 4 1 2 2 1\n8\n3 2 2 3 1 3 3 4\n8\n2 3 3 2 1 4 1 4\n",
"output": "Yes\nYes\nNo\n"
}
] |
https://atcoder.jp/contests/agc058/tasks/agc058_d | Problem Statement
You are given integers
A
,
B
, and
C
.
How many strings
S
consisting of
A
,
B
, and
C
satisfy all of the following conditions? Find the count modulo
998244353
.
The number of occurrences of
A
,
B
, and
C
in
S
are
A
,
B
, and
C
, respectively.
S
contains none of
ABC
,
BCA
, and
CAB
as a (contiguous) s... | [
{
"input": "1 1 1\n",
"output": "3\n"
},
{
"input": "2 2 2\n",
"output": "42\n"
},
{
"input": "96 11 46\n",
"output": "818015722\n"
},
{
"input": "125132 102271 152064\n",
"output": "128086069\n"
}
] |
https://atcoder.jp/contests/agc058/tasks/agc058_e | Problem Statement
In this problem, a "permutation" always means a permutation of
(1,2,\cdots,N)
.
For two permutations
p
and
q
, let us define the distance between them,
d(p,q)
, as follows.
Consider making
p
equal
q
by repeatedly swapping two adjacent terms in
p
. Let
d(p,q)
be the minimum number of swaps required her... | [
{
"input": "2\n2\n1 2\n2\n2 1\n",
"output": "Yes\nYes\n"
},
{
"input": "6\n3\n1 2 3\n3\n1 3 2\n3\n2 1 3\n3\n2 3 1\n3\n3 1 2\n3\n3 2 1\n",
"output": "Yes\nYes\nYes\nYes\nNo\nNo\n"
},
{
"input": "24\n4\n1 2 3 4\n4\n1 2 4 3\n4\n1 3 2 4\n4\n1 3 4 2\n4\n1 4 2 3\n4\n1 4 3 2\n4\n2 1 3 4\n4\n2 1... |
https://atcoder.jp/contests/agc058/tasks/agc058_f | Problem Statement
For an undirected tree
t
, let us define a rational number
f(t)
as follows.
Let
n
be the number of vertices in
t
.
If
n=1
: Let
f(t)=1
.
If
n \geq 2
:
For an edge
e
in
t
, we denote by
t_x(e)
and
t_y(e)
the two trees that result from deleting
e
from
t
(in arbitrary order).
Let
f(t)=(\sum_{e \in t} f(t... | [
{
"input": "2\n1 2\n",
"output": "499122177\n"
},
{
"input": "3\n1 2\n2 3\n",
"output": "332748118\n"
},
{
"input": "4\n1 2\n2 3\n3 4\n",
"output": "103983787\n"
},
{
"input": "10\n4 5\n1 9\n6 1\n8 4\n5 9\n4 7\n3 10\n5 2\n4 3\n",
"output": "462781191\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_a | Problem Statement
Print the
L
-th through
R
-th characters of the string
atcoder
. | [
{
"input": "3 6\n",
"output": "code\n"
},
{
"input": "4 4\n",
"output": "o\n"
},
{
"input": "1 7\n",
"output": "atcoder\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_b | Problem Statement
Print the color of the cell at the
R
-th row from the top and
C
-th column from the left
in the following grid with
15
vertical rows and
15
horizontal columns. | [
{
"input": "3 5\n",
"output": "black\n"
},
{
"input": "4 5\n",
"output": "white\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_c | Problem Statement
You are given a matrix
A
with
H_1
rows and
W_1
columns, and a matrix
B
with
H_2
rows and
W_2
columns.
For all integer pairs
(i, j)
such that
1 \leq i \leq H_1
and
1 \leq j \leq W_1
, the element at the
i
-th row and
j
-th column of matrix
A
is
A_{i, j}
.
For all integer pairs
(i, j)
such that
1 \leq i... | [
{
"input": "4 5\n1 2 3 4 5\n6 7 8 9 10\n11 12 13 14 15\n16 17 18 19 20\n2 3\n6 8 9\n16 18 19\n",
"output": "Yes\n"
},
{
"input": "3 3\n1 1 1\n1 1 1\n1 1 1\n1 1\n2\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_d | Problem Statement
You are given a string
S
that is a permutation of
atcoder
.
On this string
S
, you will perform the following operation
0
or more times:
Choose two adjacent characters of
S
and swap them.
Find the minimum number of operations required to make
S
equal
atcoder
. | [
{
"input": "catredo\n",
"output": "8\n"
},
{
"input": "atcoder\n",
"output": "0\n"
},
{
"input": "redocta\n",
"output": "21\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_e | Problem Statement
A country has
N
cities and
M
power plants, which we collectively call places.
The places are numbered
1,2,\dots,N+M
, among which Places
1,2,\dots,N
are the cities and Places
N+1,N+2,\dots,N+M
are the power plants.
This country has
E
power lines. Power Line
i
(
1 \le i \le E
) connects Place
U_i
and ... | [
{
"input": "5 5 10\n2 3\n4 10\n5 10\n6 9\n2 9\n4 8\n1 7\n3 6\n8 10\n1 8\n6\n3\n5\n8\n10\n2\n7\n",
"output": "4\n4\n2\n2\n2\n1\n"
}
] |
https://atcoder.jp/contests/abc264/tasks/abc264_f | Problem Statement
We have a grid with
H
rows and
W
columns. Each square is painted either white or black.
For each integer pair
(i, j)
such that
1 \leq i \leq H
and
1 \leq j \leq W
,
the color of the square at the
i
-th row from the top and
j
-th column from the left (we simply denote this square by Square
(i, j)
) ... | [
{
"input": "3 4\n4 3 5\n2 6 7 4\n0100\n1011\n1010\n",
"output": "9\n"
},
{
"input": "15 20\n29 27 79 27 30 4 93 89 44 88 70 75 96 3 78\n39 97 12 53 62 32 38 84 49 93 53 26 13 25 2 76 32 42 34 18\n01011100110000001111\n10101111100010011000\n11011000011010001010\n00010100011111010100\n1111100110101000... |
https://atcoder.jp/contests/abc264/tasks/abc264_g | Problem Statement
In a string fair, they determine the
beauty
of a non-empty string
S
consisting of lowercase English letters.
The beauty of string
S
equals the sum of
N
scores determined by
N
criteria.
For
i = 1, 2, \ldots, N
, the score determined by the
i
-th criterion is
"the number of occurrences of a string
T_i... | [
{
"input": "3\na -5\nab 10\nba -20\n",
"output": "Infinity\n"
},
{
"input": "28\na -5\nab 10\nba -20\nbb -20\nbc -20\nbd -20\nbe -20\nbf -20\nbg -20\nbh -20\nbi -20\nbj -20\nbk -20\nbl -20\nbm -20\nbn -20\nbo -20\nbp -20\nbq -20\nbr -20\nbs -20\nbt -20\nbu -20\nbv -20\nbw -20\nbx -20\nby -20\nbz -20... |
https://atcoder.jp/contests/abc264/tasks/abc264_h | Problem Statement
We have a rooted tree with
N
vertices numbered
1,2,\dots,N
.
The tree is rooted at Vertex
1
, and the parent of Vertex
i \ge 2
is Vertex
P_i(<i)
.
For each integer
k=1,2,\dots,N
, solve the following problem:
There are
2^{k-1}
ways to choose some of the vertices numbered between
1
and
k
so that Vertex... | [
{
"input": "10\n1 1 2 1 2 5 5 5 1\n",
"output": "1\n1\n2\n2\n4\n4\n4\n5\n7\n10\n"
},
{
"input": "1\n\n",
"output": "1\n"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9\n",
"output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"
},
{
"input": "13\n1 1 1 2 2 2 3 3 3 4 4 4\n",
"output": "1\n1\n2\n... |
https://atcoder.jp/contests/ahc013/tasks/ahc013_a | Problem Statement
Recruit Co. has a server room represented by a grid of
N
rows and
N
columns.
Let
(i, j)
denote the cell in row
i
(
0 \leq i \lt N
) from the top and column
j
(
0 \leq j \lt N
) from the left of the server room.
Each cell can contain up to one computer.
There are
K
types of computers and
100
computers ... | [] |
https://atcoder.jp/contests/abc263/tasks/abc263_a | Problem Statement
We have five cards with integers
A
,
B
,
C
,
D
, and
E
written on them, one on each card.
This set of five cards is called a Full house if and only if the following condition is satisfied:
the set has three cards with a same number written on them, and two cards with another same number written on the... | [
{
"input": "1 2 1 2 1\n",
"output": "Yes\n"
},
{
"input": "12 12 11 1 2\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_b | Problem Statement
There are
N
people, called Person
1
, Person
2
,
\ldots
, Person
N
.
The parent of Person
i
(2 \le i \le N)
is Person
P_i
. Here, it is guaranteed that
P_i < i
.
How many generations away from Person
N
is Person
1
? | [
{
"input": "3\n1 2\n",
"output": "2\n"
},
{
"input": "10\n1 2 3 4 5 6 7 8 9\n",
"output": "9\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_c | Problem Statement
Print all strictly increasing integer sequences of length
N
where all elements are between
1
and
M
(inclusive), in lexicographically ascending order. | [
{
"input": "2 3\n",
"output": "1 2 \n1 3 \n2 3 \n"
},
{
"input": "3 5\n",
"output": "1 2 3 \n1 2 4 \n1 2 5 \n1 3 4 \n1 3 5 \n1 4 5 \n2 3 4 \n2 3 5 \n2 4 5 \n3 4 5 \n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_d | Problem Statement
You are given an integer sequence of length
N
:
A=(A_1,A_2,\ldots,A_N)
.
You will perform the following consecutive operations just once:
Choose an integer
x
(0\leq x \leq N)
. If
x
is
0
, do nothing. If
x
is
1
or greater, replace each of
A_1,A_2,\ldots,A_x
with
L
.
Choose an integer
y
(0\leq y \leq N... | [
{
"input": "5 4 3\n5 5 0 6 3\n",
"output": "14\n"
},
{
"input": "4 10 10\n1 2 3 4\n",
"output": "10\n"
},
{
"input": "10 -5 -3\n9 -6 10 -1 2 10 -1 7 -15 5\n",
"output": "-58\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_e | Problem Statement
There are
N
squares called Square
1
though Square
N
. You start on Square
1
.
Each of the squares from Square
1
through Square
N-1
has a die on it. The die on Square
i
is labeled with the integers from
0
through
A_i
, each occurring with equal probability. (Die rolls are independent of each other.)
Un... | [
{
"input": "3\n1 1\n",
"output": "4\n"
},
{
"input": "5\n3 1 2 1\n",
"output": "332748122\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_f | Problem Statement
2^N
people, numbered
1
to
2^N
, will participate in a rock-paper-scissors tournament.
The tournament proceeds as follows:
The participants are arranged in a row in the order Person
1
, Person
2
,
\ldots
, Person
2^N
from left to right.
Let
2M
be the current length of the row. For each
i\ (1\leq i \leq... | [
{
"input": "2\n2 5\n6 5\n2 1\n7 9\n",
"output": "15\n"
},
{
"input": "3\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n",
"output": "4\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_g | Problem Statement
There are integers with
N
different values written on a blackboard. The
i
-th value is
A_i
and is written
B_i
times.
You may repeat the following operation as many times as possible:
Choose two integers
x
and
y
written on the blackboard such that
x+y
is prime. Erase these two integers.
Find the maximu... | [
{
"input": "3\n3 3\n2 4\n6 2\n",
"output": "3\n"
},
{
"input": "1\n1 4\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/abc263/tasks/abc263_h | Problem Statement
There are
N
lines in a two-dimensional plane. The
i
-th line is
A_i x + B_i y + C_i = 0
. It is guaranteed that no two of the lines are parallel.
In this plane, there are
\frac{N(N-1)}{2}
intersection points of two lines, including duplicates. Print the distance between the origin and the
K
-th neares... | [
{
"input": "3 2\n1 1 1\n2 1 -3\n1 -1 2\n",
"output": "2.3570226040\n"
},
{
"input": "6 7\n5 1 9\n4 4 -3\n8 -1 2\n0 1 -8\n4 0 -4\n2 -3 0\n",
"output": "4.0126752298\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_a | Problem Statement
A sport event is held in June of every year whose remainder when divided by
4
is
2
.
Suppose that it is now January of the year
Y
. In what year will this sport event be held next time? | [
{
"input": "2022\n",
"output": "2022\n"
},
{
"input": "2023\n",
"output": "2026\n"
},
{
"input": "3000\n",
"output": "3002\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_b | Problem Statement
You are given a simple undirected graph with
N
vertices and
M
edges. The vertices are numbered
1, \dots, N
, and the
i
-th
(1 \leq i \leq M)
edge connects Vertex
U_i
and Vertex
V_i
.
Find the number of tuples of integers
a, b, c
that satisfy all of the following conditions:
1 \leq a \lt b \lt c \leq ... | [
{
"input": "5 6\n1 5\n4 5\n2 3\n1 4\n3 5\n2 5\n",
"output": "2\n"
},
{
"input": "3 1\n1 2\n",
"output": "0\n"
},
{
"input": "7 10\n1 7\n5 7\n2 5\n3 6\n4 7\n1 5\n2 4\n1 3\n1 6\n2 7\n",
"output": "4\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_c | Problem Statement
You are given a sequence
a = (a_1, \dots, a_N)
of length
N
consisting of integers between
1
and
N
.
Find the number of pairs of integers
i, j
that satisfy all of the following conditions:
1 \leq i \lt j \leq N
\min(a_i, a_j) = i
\max(a_i, a_j) = j | [
{
"input": "4\n1 3 2 4\n",
"output": "2\n"
},
{
"input": "10\n5 8 2 2 1 6 7 2 9 10\n",
"output": "8\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_d | Problem Statement
You are given a sequence of positive integers
A=(a_1,\ldots,a_N)
of length
N
.
There are
(2^N-1)
ways to choose one or more terms of
A
. How many of them have an integer-valued average? Find the count modulo
998244353
. | [
{
"input": "3\n2 6 2\n",
"output": "6\n"
},
{
"input": "5\n5 5 5 5 5\n",
"output": "31\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_e | Problem Statement
You are given a simple undirected graph with
N
vertices and
M
edges. The vertices are numbered
1, \dots, N
, and the
i
-th
(1 \leq i \leq M)
edge connects Vertices
U_i
and
V_i
.
There are
2^N
ways to paint each vertex red or blue. Find the number, modulo
998244353
, of such ways that satisfy all of ... | [
{
"input": "4 4 2\n1 2\n1 3\n2 3\n3 4\n",
"output": "2\n"
},
{
"input": "10 10 3\n1 2\n2 4\n1 5\n3 6\n3 9\n4 10\n7 8\n9 10\n5 9\n3 4\n",
"output": "64\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_f | Problem Statement
You are given a sequence
P = (p_1,p_2,\ldots,p_N)
that contains
1,2,\ldots,N
exactly once each.
You may perform the following operations between
0
and
K
times in total in any order:
Choose one term of
P
and remove it.
Move the last term of
P
to the head.
Find the lexicographically smallest
P
that can ... | [
{
"input": "5 3\n4 5 2 3 1\n",
"output": "1 2 3\n"
},
{
"input": "3 0\n3 2 1\n",
"output": "3 2 1\n"
},
{
"input": "15 10\n12 10 7 2 8 11 9 1 6 14 3 15 13 5 4\n",
"output": "1 3 4 7 2 8 11 9\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_g | Problem Statement
There is an empty sequence
X
and an empty stack
S
. Also, you are given an integer sequence
A=(a_1,\ldots,a_N)
of length
N
.
For each
i=1,\ldots,N
in this order, Takahashi will do one of the following operations:
Move the integer
a_i
onto the top of
S
.
Discard the integer
a_i
from
A
.
Additionally, ... | [
{
"input": "7\n1 2 3 4 1 2 3\n",
"output": "5\n"
},
{
"input": "10\n1 1 1 1 1 1 1 1 1 1\n",
"output": "10\n"
}
] |
https://atcoder.jp/contests/abc262/tasks/abc262_h | Problem Statement
Find the number, modulo
998244353
, of integer sequences
A = (A_1, \dots, A_N)
of length
N
that satisfy all of the following conditions:
0 \leq A_i \leq M
for all
i
such that
1 \leq i \leq N
.
The maximum value of
A_{L_j}, \dots, A_{R_j}
is
X_j
for all
j
such that
1 \leq j \leq Q
. | [
{
"input": "3 3 2\n1 2 2\n2 3 3\n",
"output": "5\n"
},
{
"input": "1 1 1\n1 1 1\n",
"output": "1\n"
},
{
"input": "6 40000000 3\n1 4 30000000\n2 6 20000000\n3 5 10000000\n",
"output": "135282163\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_a | Problem Statement
You are given a string
S
of length
N
consisting of
A
and
B
.
You can repeat the following operation zero or more times:
choose a pair of adjacent characters in
S
and replace them with
AB
.
Determine whether
S
can be turned into a palindrome.
What is a palindrome?
A string
T
is a palindrome if and only... | [
{
"input": "3\nBBA\n",
"output": "Yes\n"
},
{
"input": "4\nABAB\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_b | Problem Statement
The following game is called Game
n
:
The game is played by Alice and Bob. Initially, there are
n
stones.
The players alternate turns, making a move described below, with Alice going first. The player who becomes unable to make a move loses.
In Alice's turn, she must remove a number of stones that is ... | [
{
"input": "4 2 1\n",
"output": "2\n"
},
{
"input": "27182818284 59045 23356\n",
"output": "10752495144\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_c | Problem Statement
The score of a permutation
P=(P_1,P_2,\ldots,P_{2N})
of
(1,2,\ldots,2N)
is defined as follows:
Consider dividing
P
into two (not necessarily contiguous) subsequences
A = (A_1,A_2,\ldots,A_N)
and
B = (B_1,B_2,\ldots,B_N)
. The score of
P
is the maximum possible value of
\displaystyle\sum_{i=1}^{N}A_i B... | [
{
"input": "2\n",
"output": "16\n"
},
{
"input": "10000\n",
"output": "391163238\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_d | Problem Statement
Construct a set
S
of integers satisfying all of the conditions below. It can be proved that at least one such set
S
exists under the Constraints of this problem.
S
has exactly
N
elements.
The element of
S
are distinct integers between
-10^7
and
10^7
(inclusive).
\displaystyle \sum _{s \in S} s = M
.
y... | [
{
"input": "3 9\n",
"output": "1 2 6\n"
},
{
"input": "5 -15\n",
"output": "-15 -5 0 2 3\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_e | Problem Statement
You are given two sequences, each of length
N
, consisting of non-negative integers:
A=(A_1,A_2,\ldots,A_{N})
and
B=(B_1,B_2,\ldots,B_{N})
.
Determine whether it is possible to make
A
equal to
B
by performing the operation below at most
70000
times. If it is possible, present a specific sequence of op... | [
{
"input": "3\n1 2 0\n1 2 3\n",
"output": "Yes\n2\n2 3\n"
},
{
"input": "2\n10 100\n1 0\n",
"output": "No\n"
},
{
"input": "2\n1152921504606846975 0\n1152921504606846975 0\n",
"output": "Yes\n0\n\n"
}
] |
https://atcoder.jp/contests/arc145/tasks/arc145_f | Problem Statement
Find the number, modulo
998244353
, of non-decreasing sequences
A=(A_1,A_2,\ldots,A_N)
of length
N
consisting of integers between
0
and
M
(inclusive) that satisfy the following, for each
K=0,1,\ldots,\mathrm{MOD}-1
:
the sum of the elements in
A
is congruent to
K
modulo
\mathrm{MOD}
.
What is a non-de... | [
{
"input": "2 2 4\n",
"output": "2 1 2 1\n"
},
{
"input": "3 45 3\n",
"output": "5776 5760 5760\n"
},
{
"input": "1000000 1000000 6\n",
"output": "340418986 783857865 191848859 783857865 340418986 635287738\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_a | Problem Statement
We have a number line. Takahashi painted some parts of this line, as follows:
First, he painted the part from
X=L_1
to
X=R_1
red.
Next, he painted the part from
X=L_2
to
X=R_2
blue.
Find the length of the part of the line painted both red and blue. | [
{
"input": "0 3 1 5\n",
"output": "2\n"
},
{
"input": "0 1 4 5\n",
"output": "0\n"
},
{
"input": "0 3 3 7\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_b | Problem Statement
N
players played a round-robin tournament.
You are given an
N
-by-
N
table
A
containing the results of the matches. Let
A_{i,j}
denote the element at the
i
-th row and
j
-th column of
A
.
A_{i,j}
is
-
if
i=j
, and
W
,
L
, or
D
otherwise.
A_{i,j}
is
W
if Player
i
beat Player
j
,
L
if Player
i
lost to P... | [
{
"input": "4\n-WWW\nL-DD\nLD-W\nLDW-\n",
"output": "incorrect\n"
},
{
"input": "2\n-D\nD-\n",
"output": "correct\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_c | Problem Statement
For two strings
A
and
B
, let
A+B
denote the concatenation of
A
and
B
in this order.
You are given
N
strings
S_1,\ldots,S_N
. Modify and print them as follows, in the order
i=1, \ldots, N
:
if none of
S_1,\ldots,S_{i-1}
is equal to
S_i
, print
S_i
;
if
X
(X>0)
of
S_1,\ldots,S_{i-1}
are equal to
S_i
, ... | [
{
"input": "5\nnewfile\nnewfile\nnewfolder\nnewfile\nnewfolder\n",
"output": "newfile\nnewfile(1)\nnewfolder\nnewfile(2)\nnewfolder(1)\n"
},
{
"input": "11\na\na\na\na\na\na\na\na\na\na\na\n",
"output": "a\na(1)\na(2)\na(3)\na(4)\na(5)\na(6)\na(7)\na(8)\na(9)\na(10)\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_d | Problem Statement
Takahashi will toss a coin
N
times.
He also has a counter, which initially shows
0
.
Depending on the result of the
i
-th coin toss, the following happens:
If it heads: Takahashi increases the counter's value by
1
and receives
X_i
yen (Japanese currency).
If it tails: he resets the counter's value to
... | [
{
"input": "6 3\n2 7 1 8 2 8\n2 10\n3 1\n5 5\n",
"output": "48\n"
},
{
"input": "3 2\n1000000000 1000000000 1000000000\n1 1000000000\n3 1000000000\n",
"output": "5000000000\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_e | Problem Statement
We have a variable
X
and
N
kinds of operations that change the value of
X
. Operation
i
is represented as a pair of integers
(T_i,A_i)
, and is the following operation:
if
T_i=1
, it replaces the value of
X
with
X\ {\rm and}\ A_i
;
if
T_i=2
, it replaces the value of
X
with
X\ {\rm or}\ A_i
;
if
T_i=3... | [
{
"input": "3 10\n3 3\n2 5\n1 12\n",
"output": "9\n15\n12\n"
},
{
"input": "9 12\n1 1\n2 2\n3 3\n1 4\n2 5\n3 6\n1 7\n2 8\n3 9\n",
"output": "0\n2\n1\n0\n5\n3\n3\n11\n2\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_f | Problem Statement
There are
N
balls arranged from left to right.
The color of the
i
-th ball from the left is Color
C_i
, and an integer
X_i
is written on it.
Takahashi wants to rearrange the balls so that the integers written on the balls are non-decreasing from left to right.
In other words, his objective is to rea... | [
{
"input": "5\n1 5 2 2 1\n3 2 1 2 1\n",
"output": "6\n"
},
{
"input": "3\n1 1 1\n3 2 1\n",
"output": "0\n"
},
{
"input": "3\n3 1 2\n1 1 2\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_g | Problem Statement
You are given two strings
S
and
T
consisting of lowercase English letters.
Takahashi starts with the string
S
. He can perform
K
kinds of operations any number of times in any order.
The
i
-th operation is the following:
Pay a cost of
1
.
Then, if the current string contains the
character
C_i
, choos... | [
{
"input": "ab\ncbca\n3\na b\nb ca\na efg\n",
"output": "4\n"
},
{
"input": "a\naaaaa\n2\na aa\na aaa\n",
"output": "2\n"
},
{
"input": "a\nz\n1\na abc\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc261/tasks/abc261_h | Problem Statement
We have a directed graph with
N
vertices and
M
edges. Edge
i
is directed from Vertex
A_i
to
B_i
and has a weight of
C_i
.
Initially, there is a piece on Vertex
v
. Takahashi and Aoki will play a game where they alternate turns moving the piece as follows:
If there is no edge that goes from the vertex ... | [
{
"input": "7 6 1\n1 2 1\n1 3 10\n2 4 100\n2 5 102\n3 6 20\n3 7 30\n",
"output": "40\n"
},
{
"input": "3 6 3\n1 2 1\n2 1 2\n2 3 3\n3 2 4\n3 1 5\n1 3 6\n",
"output": "INFINITY\n"
},
{
"input": "4 4 1\n1 2 1\n2 3 1\n3 1 1\n2 4 1\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/abc260/tasks/abc260_a | Problem Statement
You are given a string
S
of length
3
.
Print a character that occurs only once in
S
.
If there is no such character, print
-1
instead. | [
{
"input": "pop\n",
"output": "o\n"
},
{
"input": "abc\n",
"output": "a\n"
},
{
"input": "xxx\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc260/tasks/abc260_b | Problem Statement
N
examinees took an entrance exam.
The examinee numbered
i
scored
A_i
points in math and
B_i
points in English.
The admissions are determined as follows.
X
examinees with the highest math scores are admitted.
Then, among the examinees who are not admitted yet,
Y
examinees with the highest English scor... | [
{
"input": "6 1 0 2\n80 60 80 60 70 70\n40 20 50 90 90 80\n",
"output": "1\n4\n5\n"
},
{
"input": "5 2 1 2\n0 100 0 100 0\n0 0 100 100 0\n",
"output": "1\n2\n3\n4\n5\n"
},
{
"input": "15 4 3 2\n30 65 20 95 100 45 70 85 20 35 95 50 40 15 85\n0 25 45 35 65 70 80 90 40 55 20 20 45 75 100\n"... |
https://atcoder.jp/contests/abc260/tasks/abc260_c | Problem Statement
Takahashi has a red jewel of level
N
. (He has no other jewels.)
Takahashi can do the following operations any number of times.
Convert a red jewel of level
n
(
n
is at least
2
) into "a red jewel of level
(n-1)
and
X
blue jewels of level
n
".
Convert a blue jewel of level
n
(
n
is at least
2
) into ... | [
{
"input": "2 3 4\n",
"output": "12\n"
},
{
"input": "1 5 5\n",
"output": "0\n"
},
{
"input": "10 5 5\n",
"output": "3942349900\n"
}
] |
https://atcoder.jp/contests/abc260/tasks/abc260_d | Problem Statement
There is a deck consisting of
N
face-down cards with an integer from
1
through
N
written on them. The integer on the
i
-th card from the top is
P_i
.
Using this deck, you will perform
N
moves, each consisting of the following steps:
Draw the topmost card from the deck. Let
X
be the integer written o... | [
{
"input": "5 2\n3 5 2 1 4\n",
"output": "4\n3\n3\n-1\n4\n"
},
{
"input": "5 1\n1 2 3 4 5\n",
"output": "1\n2\n3\n4\n5\n"
},
{
"input": "15 3\n3 14 15 9 2 6 5 13 1 7 10 11 8 12 4\n",
"output": "9\n9\n9\n15\n15\n6\n-1\n-1\n6\n-1\n-1\n-1\n-1\n6\n15\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.