url stringlengths 49 92 | description stringlengths 22 4.78k | cases listlengths 0 6 |
|---|---|---|
https://atcoder.jp/contests/joi2024yo1a/tasks/joi2024_yo1a_b | 問題文
3
つの正の整数
A, B, C
が与えられる.
このうちある
1
つの値がそれ以外の
2
つの値の和になっているなら
1
を,そうでないなら
0
を出力せよ. | [
{
"input": "3\n5\n2\n",
"output": "1\n"
},
{
"input": "2\n3\n4\n",
"output": "0\n"
},
{
"input": "100\n50\n50\n",
"output": "1\n"
},
{
"input": "1\n1\n1\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/joi2024yo1a/tasks/joi2024_yo1a_c | 問題文
整数
N
と,
2
つの長さ
N
の 文字列
S, T
が与えられる.
S
と
T
のハミング距離を出力せよ.
ここで
S
と
T
のハミング距離とは,
S
の
i
文字目と
T
の
i
文字目が異なるような
i
(
1 \leqq i \leqq N
) の個数である. | [
{
"input": "3\njoi\nioi\n",
"output": "1\n"
},
{
"input": "5\nmarch\napril\n",
"output": "4\n"
},
{
"input": "6\nsample\nsample\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/joi2024yo1a/tasks/joi2024_yo1a_d | 問題文
0
以上
9
以下の整数からなる,長さ
N
の数列
A = (A_1, A_2, \dots, A_N)
が与えられる.数列
A
に少なくとも
1
回現れている整数をすべて,小さい順に出力せよ. | [
{
"input": "8\n2 0 2 3 0 9 1 6\n",
"output": "0\n1\n2\n3\n6\n9\n"
},
{
"input": "3\n9 9 9\n",
"output": "9\n"
},
{
"input": "10\n3 1 4 1 5 9 2 6 5 3\n",
"output": "1\n2\n3\n4\n5\n6\n9\n"
}
] |
https://atcoder.jp/contests/abc319/tasks/abc319_a | Problem Statement
In AtCoder, the top
10
rated players' usernames are displayed with a gold crown, and the top-rated player's username is displayed with a platinum crown.
At the start of this contest, the usernames and ratings of the top
10
rated players in the algorithm category are as follows:
tourist 3858
ksun48 367... | [
{
"input": "tourist\n",
"output": "3858\n"
},
{
"input": "semiexp\n",
"output": "3481\n"
}
] |
https://atcoder.jp/contests/abc319/tasks/abc319_b | Problem Statement
You are given a positive integer
N
. Print a string of length
(N+1)
,
s_0s_1\ldots s_N
, defined as follows.
For each
i = 0, 1, 2, \ldots, N
,
if there is a divisor
j
of
N
that is between
1
and
9
, inclusive, and
i
is a multiple of
N/j
, then
s_i
is the digit corresponding to the smallest such
j
(
s_i... | [
{
"input": "12\n",
"output": "1-643-2-346-1\n"
},
{
"input": "7\n",
"output": "17777771\n"
},
{
"input": "1\n",
"output": "11\n"
}
] |
https://atcoder.jp/contests/abc319/tasks/abc319_c | Problem Statement
There is a
3\times3
grid with numbers between
1
and
9
, inclusive, written in each square. The square at the
i
-th row from the top and
j
-th column from the left
(1\leq i\leq3,1\leq j\leq3)
contains the number
c _ {i,j}
.
The same number may be written in different squares, but not in three consecuti... | [
{
"input": "3 1 9\n2 5 6\n2 7 1\n",
"output": "0.666666666666666666666666666667\n"
},
{
"input": "7 7 6\n8 6 8\n7 7 6\n",
"output": "0.004982363315696649029982363316\n"
},
{
"input": "3 6 7\n1 9 7\n5 7 5\n",
"output": "0.4\n"
}
] |
https://atcoder.jp/contests/abc319/tasks/abc319_d | Problem Statement
Takahashi is displaying a sentence with
N
words in a window.
All words have the same height, and the width of the
i
-th word
(1\leq i\leq N)
is
L _ i
.
The words are displayed in the window separated by a space of width
1
.
More precisely, when the sentence is displayed in a window of width
W
, the ... | [
{
"input": "13 3\n9 5 2 7 1 8 8 2 1 5 2 3 6\n",
"output": "26\n"
},
{
"input": "10 1\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n",
"output": "10000000009\n"
},
{
"input": "30 8\n8 55 26 97 48 37 47 35 55 5 17 62 2 60 23... |
https://atcoder.jp/contests/abc319/tasks/abc319_e | Problem Statement
Takahashi is initially at his house and is about to visit Aoki's house.
There are
N
bus stops numbered
1
to
N
between the two houses, and Takahashi can move between them in the following ways:
He can walk from his house to bus stop
1
in
X
units of time.
For each
i = 1, 2, \ldots, N-1
, a bus departs f... | [
{
"input": "4 2 3\n5 4\n6 6\n3 1\n7\n13\n0\n710511029\n136397527\n763027379\n644706927\n447672230\n",
"output": "34\n22\n710511052\n136397548\n763027402\n644706946\n447672250\n"
}
] |
https://atcoder.jp/contests/abc319/tasks/abc319_f | Problem Statement
There is a tree with
N
vertices.
The
1
-st vertex is the root, and the parent of the
i
-th vertex
(2\leq i\leq N)
is
p _ i\ (1\leq p _ i\lt i)
.
Each non-root vertex has an
enemy
or a
medicine
on it.
Takahashi wants to defeat all the enemies.
Initially, his strength is
1
, and he is at vertex
1
.
... | [
{
"input": "8\n1 2 0 3\n2 1 3 3\n1 2 0 4\n4 1 2 2\n1 2 0 5\n6 1 5 5\n5 1 140 1\n",
"output": "Yes\n"
},
{
"input": "12\n1 1 166 619\n1 1 17 592\n2 1 222 983\n2 1 729 338\n5 1 747 62\n3 1 452 815\n3 2 0 1\n4 2 0 40\n4 1 306 520\n6 1 317 591\n1 1 507 946\n",
"output": "No\n"
},
{
"input": ... |
https://atcoder.jp/contests/abc319/tasks/abc319_g | Problem Statement
We will perform the following operation on a complete undirected graph
G
with
N
vertices.
For each
i = 1, 2, \ldots, M
, delete the undirected edge connecting vertices
u_i
and
v_i
.
Determine if there is a path from vertex
1
to vertex
N
in
G
after the operation. If there is, find the number, modulo
99... | [
{
"input": "6 7\n4 3\n1 3\n2 4\n1 6\n4 6\n5 1\n6 2\n",
"output": "3\n"
},
{
"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/wtf22-day2-open/tasks/wtf22_day2_a | Problem Statement
You, the game master, and
N
players play a
Hat Guessing Game
.
The players line up behind one another, numbered
1
to
N
from front to back.
Each player wears a red or blue hat.
The colors of the hats are represented by a string
S
: player
i
wears a red hat if the
i
-th character of
S
is
R
, and a blue ... | [
{
"input": "7\n3\nRBR\n4\nBRBR\n5\nBBBBB\n5\nBBBRR\n20\nBRBBRRRRBRRBRBBBRRBR\n50\nRRBRRRBBBRRRBBBRRBRRBBRBRRBBRRRRRBBBBBRRRBRBRRBRRR\n100\nBRBRBRBBRRRBBRRBRBBRBBBRBBRBBRRRRBBRRBBBBBBBBBBBBRRBBRBBRBBBBRRRRRRRRRBRBBRBBBBRBBBRBRRBRRBBRBBBBBBB\n",
"output": "101\n0101\n11111\n10111\n10111111010101011101\n111110... |
https://atcoder.jp/contests/wtf22-day2-open/tasks/wtf22_day2_b | Problem Statement
You are given integers
N
and
K
, and a permutation
P=(P_1,P_2,\cdots,P_N)
of
(1,2,\cdots,N)
.
You can perform the following operation any number of times, possibly zero.
Choose an integer
i
(
1 \leq i \leq N-K+1
).
Swap the values of the two greatest elements among
P_i,P_{i+1},\cdots,P_{i+K-1}
.
Find... | [
{
"input": "3 3\n2 3 1\n",
"output": "2\n"
},
{
"input": "3 2\n1 3 2\n",
"output": "6\n"
},
{
"input": "10 5\n1 2 3 4 5 6 7 8 9 10\n",
"output": "144\n"
},
{
"input": "20 5\n8 13 6 11 20 3 12 18 17 4 10 1 7 16 19 5 2 15 14 9\n",
"output": "1451520\n"
}
] |
https://atcoder.jp/contests/wtf22-day2-open/tasks/wtf22_day2_c | Problem Statement
There are
N
gems numbered
1
to
N
.
Gem
i
has a color
C_i
and a value
V_i
.
Here, colors are represented as integers from
1
through
N
.
A pair of two gems
(i,j)
is said to be a
good
pair if (and only if) they satisfy the following conditions:
C_i \neq C_j
,
V_i + V_j \leq L
.
You will make some number ... | [
{
"input": "4 5\n1 2\n1 3\n2 1\n2 4\n",
"output": "4\n"
},
{
"input": "5 10\n3 8\n4 2\n1 5\n1 3\n1 2\n",
"output": "17\n"
},
{
"input": "9 10\n8 2\n7 10\n1 4\n3 0\n5 3\n3 6\n2 5\n5 9\n5 4\n",
"output": "34\n"
},
{
"input": "20 1000000000\n15 239276621\n15 910500852\n15 245532... |
https://atcoder.jp/contests/wtf22-day2-open/tasks/wtf22_day2_d | Problem Statement
You are given a sequence of positive integers
A_1,A_2,\cdots,A_N
.
Let
S=N+\sum_{1 \leq i \leq N}A_i
.
Cat Snuke has
S
cards.
Each card has an integer written on it. The integers on the cards are
A_1,A_2,\cdots,A_N,-1,\cdots,-1
.
Particularly, there are
\sum_{1 \leq i \leq N}A_i
cards with
-1
.
Snuke ... | [
{
"input": "2\n1 1\n",
"output": "2\n4\n"
},
{
"input": "3\n1 2 3\n",
"output": "140\n220\n144\n"
},
{
"input": "20\n16 6 15 19 1 9 6 1 11 7 6 12 3 11 11 18 10 9 15 5\n",
"output": "507808441\n401798892\n110460932\n680359166\n737048635\n442374434\n737773176\n980506765\n473506608\n693... |
https://atcoder.jp/contests/wtf22-day2-open/tasks/wtf22_day2_e | Problem Statement
You are given
N
non-negative integers
A_1,A_2,\cdots,A_N
.
For each
k=1,2,\cdots,N
, solve the following problem.
Alice and Bob play the following game.
Alice chooses
k
numbers from
A_1,A_2,\cdots,A_N
.
Let
x_1,x_2,\cdots,x_k
be the chosen numbers (in arbitrary order).
Bob makes a sequence of
2k
non-n... | [
{
"input": "3\n1 2 3\n",
"output": "2\n6\n6\n"
},
{
"input": "5\n1 1 1 1 1\n",
"output": "1\n3\n5\n7\n9\n"
},
{
"input": "5\n1 2 4 8 16\n",
"output": "16\n24\n28\n30\n31\n"
},
{
"input": "20\n167660508 377125547 866003430 419036363 234113368 201296307 408194538 249252693 2072... |
https://atcoder.jp/contests/wtf22-day2/tasks/wtf22_day2_a | Problem Statement
You, the game master, and
N
players play a
Hat Guessing Game
.
The players line up behind one another, numbered
1
to
N
from front to back.
Each player wears a red or blue hat.
The colors of the hats are represented by a string
S
: player
i
wears a red hat if the
i
-th character of
S
is
R
, and a blue ... | [
{
"input": "7\n3\nRBR\n4\nBRBR\n5\nBBBBB\n5\nBBBRR\n20\nBRBBRRRRBRRBRBBBRRBR\n50\nRRBRRRBBBRRRBBBRRBRRBBRBRRBBRRRRRBBBBBRRRBRBRRBRRR\n100\nBRBRBRBBRRRBBRRBRBBRBBBRBBRBBRRRRBBRRBBBBBBBBBBBBRRBBRBBRBBBBRRRRRRRRRBRBBRBBBBRBBBRBRRBRRBBRBBBBBBB\n",
"output": "101\n0101\n11111\n10111\n10111111010101011101\n111110... |
https://atcoder.jp/contests/wtf22-day2/tasks/wtf22_day2_b | Problem Statement
You are given integers
N
and
K
, and a permutation
P=(P_1,P_2,\cdots,P_N)
of
(1,2,\cdots,N)
.
You can perform the following operation any number of times, possibly zero.
Choose an integer
i
(
1 \leq i \leq N-K+1
).
Swap the values of the two greatest elements among
P_i,P_{i+1},\cdots,P_{i+K-1}
.
Find... | [
{
"input": "3 3\n2 3 1\n",
"output": "2\n"
},
{
"input": "3 2\n1 3 2\n",
"output": "6\n"
},
{
"input": "10 5\n1 2 3 4 5 6 7 8 9 10\n",
"output": "144\n"
},
{
"input": "20 5\n8 13 6 11 20 3 12 18 17 4 10 1 7 16 19 5 2 15 14 9\n",
"output": "1451520\n"
}
] |
https://atcoder.jp/contests/wtf22-day2/tasks/wtf22_day2_c | Problem Statement
There are
N
gems numbered
1
to
N
.
Gem
i
has a color
C_i
and a value
V_i
.
Here, colors are represented as integers from
1
through
N
.
A pair of two gems
(i,j)
is said to be a
good
pair if (and only if) they satisfy the following conditions:
C_i \neq C_j
,
V_i + V_j \leq L
.
You will make some number ... | [
{
"input": "4 5\n1 2\n1 3\n2 1\n2 4\n",
"output": "4\n"
},
{
"input": "5 10\n3 8\n4 2\n1 5\n1 3\n1 2\n",
"output": "17\n"
},
{
"input": "9 10\n8 2\n7 10\n1 4\n3 0\n5 3\n3 6\n2 5\n5 9\n5 4\n",
"output": "34\n"
},
{
"input": "20 1000000000\n15 239276621\n15 910500852\n15 245532... |
https://atcoder.jp/contests/wtf22-day2/tasks/wtf22_day2_d | Problem Statement
You are given a sequence of positive integers
A_1,A_2,\cdots,A_N
.
Let
S=N+\sum_{1 \leq i \leq N}A_i
.
Cat Snuke has
S
cards.
Each card has an integer written on it. The integers on the cards are
A_1,A_2,\cdots,A_N,-1,\cdots,-1
.
Particularly, there are
\sum_{1 \leq i \leq N}A_i
cards with
-1
.
Snuke ... | [
{
"input": "2\n1 1\n",
"output": "2\n4\n"
},
{
"input": "3\n1 2 3\n",
"output": "140\n220\n144\n"
},
{
"input": "20\n16 6 15 19 1 9 6 1 11 7 6 12 3 11 11 18 10 9 15 5\n",
"output": "507808441\n401798892\n110460932\n680359166\n737048635\n442374434\n737773176\n980506765\n473506608\n693... |
https://atcoder.jp/contests/wtf22-day2/tasks/wtf22_day2_e | Problem Statement
You are given
N
non-negative integers
A_1,A_2,\cdots,A_N
.
For each
k=1,2,\cdots,N
, solve the following problem.
Alice and Bob play the following game.
Alice chooses
k
numbers from
A_1,A_2,\cdots,A_N
.
Let
x_1,x_2,\cdots,x_k
be the chosen numbers (in arbitrary order).
Bob makes a sequence of
2k
non-n... | [
{
"input": "3\n1 2 3\n",
"output": "2\n6\n6\n"
},
{
"input": "5\n1 1 1 1 1\n",
"output": "1\n3\n5\n7\n9\n"
},
{
"input": "5\n1 2 4 8 16\n",
"output": "16\n24\n28\n30\n31\n"
},
{
"input": "20\n167660508 377125547 866003430 419036363 234113368 201296307 408194538 249252693 2072... |
https://atcoder.jp/contests/wtf22-day1-open/tasks/wtf22_day1_a | Problem Statement
You keep
N
monsters numbered
1
to
N
.
A hero has come to slay your monsters.
He will take
M
turns to attack the monsters.
In the
i
-th turn, he performs one of the following actions.
Consume
1
MP to attack monster
X_i
.
This action can only be performed when monster
X_i
is still alive and the hero has... | [
{
"input": "2 3 2 1\n1 2 1\n",
"output": "1\n"
},
{
"input": "2 6 3 2\n1 1 1 2 2 2\n",
"output": "1\n"
},
{
"input": "100 1 1 1\n100\n",
"output": "100\n"
},
{
"input": "6 20 16 5\n5 6 1 3 2 1 4 3 2 4 1 4 4 6 3 3 5 2 2 2\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/wtf22-day1-open/tasks/wtf22_day1_b | Problem Statement
You are given a permutation
P=(P_1,P_2,\cdots,P_N)
of
(1,2,\cdots,N)
.
Find one sequence of integer pairs
((l_1,r_1),(l_2,r_2),\cdots,(l_k,r_k))
that satisfies all of the following conditions.
The length
k
of the sequence satisfies
0 \leq k \leq N-1
.
1 \leq l_i \leq r_i \leq N
(
1 \leq i \leq k
).
Fo... | [
{
"input": "3\n3\n2 3 1\n4\n4 3 2 1\n1\n1\n",
"output": "2\n2 3\n1 2\n3\n1 4\n1 1\n2 3\n0\n"
}
] |
https://atcoder.jp/contests/wtf22-day1-open/tasks/wtf22_day1_c | Problem Statement
You are given a tree
T
with
N
vertices numbered
1
to
N
.
The
i
-th edge connects vertices
A_i
and
B_i
.
You can perform the following operation any number of times, possibly zero.
Choose two leaves
u
and
v
of
T
such that the distance between them is odd.
Then, remove
u
and
v
from
T
(along with the inc... | [
{
"input": "4\n1 2\n2 3\n3 4\n",
"output": "3\n"
},
{
"input": "5\n2 1\n3 1\n4 1\n5 3\n",
"output": "3\n"
},
{
"input": "8\n2 1\n3 2\n4 1\n5 2\n6 5\n7 3\n8 7\n",
"output": "11\n"
},
{
"input": "24\n12 7\n14 4\n8 13\n24 13\n1 3\n4 9\n17 2\n1 21\n24 22\n11 1\n15 17\n22 5\n23 10... |
https://atcoder.jp/contests/wtf22-day1-open/tasks/wtf22_day1_d | Problem Statement
There are
M
competitive programmers (kyopro-ers) numbered
1
to
M
, who will visit Tokyo during the
N
days starting today.
Kyopro-er
i
will stay in Tokyo from the
L_i
-th day through the
R_i
-th day (
1 \leq L_i \leq R_i \leq N
).
Maroon is planning dinner parties with them.
If a dinner party is held o... | [
{
"input": "3 3\n1 1\n1 2\n3 3\n",
"output": "2\n3\n3\n"
},
{
"input": "4 4\n1 1\n2 2\n3 3\n4 4\n",
"output": "1\n2\n3\n4\n"
},
{
"input": "3 6\n1 1\n1 2\n1 2\n2 3\n2 3\n3 3\n",
"output": "4\n6\n6\n"
},
{
"input": "20 15\n15 19\n1 8\n6 11\n3 11\n11 17\n6 6\n16 20\n7 11\n11 14... |
https://atcoder.jp/contests/wtf22-day1-open/tasks/wtf22_day1_e | Problem Statement
You are given positive integers
N
and
M
. Here,
N<M
.
A sequence of
N
non-negative integers
a=(a_1,a_2,\cdots,a_N)
is said to be a
good
sequence when it satisfies the following condition:
0 \leq a_1 \leq a_2 \leq \cdots \leq a_N \leq M
.
For a good sequence
a
, let
f(a)
be the sequence resulting from ... | [
{
"input": "2 3\n",
"output": "998244349\n4\n"
},
{
"input": "3 4\n",
"output": "998244329\n0\n24\n"
},
{
"input": "4 6\n",
"output": "998244233\n35\n175\n330\n"
},
{
"input": "10 1000000\n",
"output": "297189103\n747015740\n88545731\n123651717\n920498165\n977169022\n7757... |
https://atcoder.jp/contests/wtf22-day1/tasks/wtf22_day1_a | Problem Statement
You keep
N
monsters numbered
1
to
N
.
A hero has come to slay your monsters.
He will take
M
turns to attack the monsters.
In the
i
-th turn, he performs one of the following actions.
Consume
1
MP to attack monster
X_i
.
This action can only be performed when monster
X_i
is still alive and the hero has... | [
{
"input": "2 3 2 1\n1 2 1\n",
"output": "1\n"
},
{
"input": "2 6 3 2\n1 1 1 2 2 2\n",
"output": "1\n"
},
{
"input": "100 1 1 1\n100\n",
"output": "100\n"
},
{
"input": "6 20 16 5\n5 6 1 3 2 1 4 3 2 4 1 4 4 6 3 3 5 2 2 2\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/wtf22-day1/tasks/wtf22_day1_b | Problem Statement
You are given a permutation
P=(P_1,P_2,\cdots,P_N)
of
(1,2,\cdots,N)
.
Find one sequence of integer pairs
((l_1,r_1),(l_2,r_2),\cdots,(l_k,r_k))
that satisfies all of the following conditions.
The length
k
of the sequence satisfies
0 \leq k \leq N-1
.
1 \leq l_i \leq r_i \leq N
(
1 \leq i \leq k
).
Fo... | [
{
"input": "3\n3\n2 3 1\n4\n4 3 2 1\n1\n1\n",
"output": "2\n2 3\n1 2\n3\n1 4\n1 1\n2 3\n0\n"
}
] |
https://atcoder.jp/contests/wtf22-day1/tasks/wtf22_day1_c | Problem Statement
You are given a tree
T
with
N
vertices numbered
1
to
N
.
The
i
-th edge connects vertices
A_i
and
B_i
.
You can perform the following operation any number of times, possibly zero.
Choose two leaves
u
and
v
of
T
such that the distance between them is odd.
Then, remove
u
and
v
from
T
(along with the inc... | [
{
"input": "4\n1 2\n2 3\n3 4\n",
"output": "3\n"
},
{
"input": "5\n2 1\n3 1\n4 1\n5 3\n",
"output": "3\n"
},
{
"input": "8\n2 1\n3 2\n4 1\n5 2\n6 5\n7 3\n8 7\n",
"output": "11\n"
},
{
"input": "24\n12 7\n14 4\n8 13\n24 13\n1 3\n4 9\n17 2\n1 21\n24 22\n11 1\n15 17\n22 5\n23 10... |
https://atcoder.jp/contests/wtf22-day1/tasks/wtf22_day1_d | Problem Statement
There are
M
competitive programmers (kyopro-ers) numbered
1
to
M
, who will visit Tokyo during the
N
days starting today.
Kyopro-er
i
will stay in Tokyo from the
L_i
-th day through the
R_i
-th day (
1 \leq L_i \leq R_i \leq N
).
Maroon is planning dinner parties with them.
If a dinner party is held o... | [
{
"input": "3 3\n1 1\n1 2\n3 3\n",
"output": "2\n3\n3\n"
},
{
"input": "4 4\n1 1\n2 2\n3 3\n4 4\n",
"output": "1\n2\n3\n4\n"
},
{
"input": "3 6\n1 1\n1 2\n1 2\n2 3\n2 3\n3 3\n",
"output": "4\n6\n6\n"
},
{
"input": "20 15\n15 19\n1 8\n6 11\n3 11\n11 17\n6 6\n16 20\n7 11\n11 14... |
https://atcoder.jp/contests/wtf22-day1/tasks/wtf22_day1_e | Problem Statement
You are given positive integers
N
and
M
. Here,
N<M
.
A sequence of
N
non-negative integers
a=(a_1,a_2,\cdots,a_N)
is said to be a
good
sequence when it satisfies the following condition:
0 \leq a_1 \leq a_2 \leq \cdots \leq a_N \leq M
.
For a good sequence
a
, let
f(a)
be the sequence resulting from ... | [
{
"input": "2 3\n",
"output": "998244349\n4\n"
},
{
"input": "3 4\n",
"output": "998244329\n0\n24\n"
},
{
"input": "4 6\n",
"output": "998244233\n35\n175\n330\n"
},
{
"input": "10 1000000\n",
"output": "297189103\n747015740\n88545731\n123651717\n920498165\n977169022\n7757... |
https://atcoder.jp/contests/ahc023/tasks/asprocon10_a | Problem Statement
There is a rectangular piece of land with size
H \times W
.
This land is divided into square
blocks
of size
1 \times 1
, and some of the boundaries between the blocks are separated by
waterways
.
The border of the land is surrounded by fences except for a single
entrance
, which is the only way to e... | [
{
"input": "10 6 6 3\n011010\n000001\n011000\n000110\n011000\n00000\n10001\n10010\n00110\n10101\n10000\n20\n2 10\n1 10\n4 10\n1 10\n2 9\n4 5\n2 8\n4 10\n4 9\n1 9\n1 3\n1 6\n1 7\n3 6\n8 10\n1 7\n3 8\n2 8\n1 10\n2 10\n",
"output": "12\n1 0 0 2\n2 0 1 1\n3 1 0 4\n4 0 2 1\n5 3 1 2\n6 2 0 4\n7 4 0 2\n10 3 2 1\n1... |
https://atcoder.jp/contests/abc318/tasks/abc318_a | Problem Statement
Takahashi likes full moons.
Let today be day
1
. The first day on or after today on which he can see a full moon is day
M
. After that, he can see a full moon every
P
days, that is, on day
M+P
, day
M+2P
, and so on.
Find the number of days between day
1
and day
N
, inclusive, on which he can see a fu... | [
{
"input": "13 3 5\n",
"output": "3\n"
},
{
"input": "5 6 6\n",
"output": "0\n"
},
{
"input": "200000 314 318\n",
"output": "628\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_b | Problem Statement
There are
N
rectangular sheets spread out on a coordinate plane.
Each side of the rectangular region covered by each sheet is parallel to the
x
- or
y
-axis.
Specifically, the
i
-th sheet covers exactly the region satisfying
A_i \leq x\leq B_i
and
C_i \leq y\leq D_i
.
Let
S
be the area of
the region c... | [
{
"input": "3\n0 5 1 3\n1 4 0 5\n2 5 2 4\n",
"output": "20\n"
},
{
"input": "2\n0 100 0 100\n0 100 0 100\n",
"output": "10000\n"
},
{
"input": "3\n0 1 0 1\n0 3 0 5\n5 10 0 10\n",
"output": "65\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_c | Problem Statement
Takahashi is planning an
N
-day train trip.
For each day, he can pay the regular fare or use a one-day pass.
Here, for
1\leq i\leq N
, the regular fare for the
i
-th day of the trip is
F_i
yen.
On the other hand, a batch of
D
one-day passes is sold for
P
yen. You can buy as many passes as you want, bu... | [
{
"input": "5 2 10\n7 1 6 3 6\n",
"output": "20\n"
},
{
"input": "3 1 10\n1 2 3\n",
"output": "6\n"
},
{
"input": "8 3 1000000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n",
"output": "3000000000\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_d | Problem Statement
You are given a weighted undirected complete graph with
N
vertices numbered from
1
to
N
. The edge connecting vertices
i
and
j
(i< j)
has a weight of
D_{i,j}
.
When choosing some number of edges under the following condition, find the maximum possible total weight of the chosen edges.
The endpoints of... | [
{
"input": "4\n1 5 4\n7 8\n6\n",
"output": "13\n"
},
{
"input": "3\n1 2\n3\n",
"output": "3\n"
},
{
"input": "16\n5 6 5 2 1 7 9 7 2 5 5 2 4 7 6\n8 7 7 9 8 1 9 6 10 8 8 6 10 3\n10 5 8 1 10 7 8 4 8 6 5 1 10\n7 4 1 4 5 4 5 10 1 5 1 2\n2 9 9 7 6 2 2 8 3 5 2\n9 10 3 1 1 2 10 7 7 5\n10 6 1 8 9... |
https://atcoder.jp/contests/abc318/tasks/abc318_e | Problem Statement
You are given a sequence of positive integers of length
N
:
A=(A_1,A_2,\ldots,A_N)
. Find the number of triples of positive integers
(i,j,k)
that satisfy all of the following conditions:
1\leq i < j < k\leq N
,
A_i = A_k
,
A_i \neq A_j
. | [
{
"input": "5\n1 2 1 3 2\n",
"output": "3\n"
},
{
"input": "7\n1 2 3 4 5 6 7\n",
"output": "0\n"
},
{
"input": "13\n9 7 11 7 3 8 1 13 11 11 11 6 13\n",
"output": "20\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_f | Problem Statement
There is an octopus-shaped robot and
N
treasures on a number line.
The
i
-th treasure
(1\leq i\leq N)
is located at coordinate
X_i
.
The robot has one head and
N
legs, and the
i
-th leg
(1\leq i\leq N)
has a length of
L_i
.
Find the number of
integers
k
such that the robot can grab all
N
treasures as... | [
{
"input": "3\n-6 0 7\n3 5 10\n",
"output": "6\n"
},
{
"input": "1\n0\n1000000000000000000\n",
"output": "2000000000000000001\n"
},
{
"input": "2\n-100 100\n1 1\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_g | Problem Statement
You are given a simple connected undirected graph
G
with
N
vertices and
M
edges.
The vertices and edges of
G
are numbered as vertex
1
, vertex
2
,
\ldots
, vertex
N
, and edge
1
, edge
2
,
\ldots
, edge
M
, respectively, and edge
i
(1\leq i\leq M)
connects vertices
U_i
and
V_i
.
You are also given dis... | [
{
"input": "6 7\n1 3 2\n1 2\n1 5\n2 3\n2 5\n2 6\n3 4\n4 5\n",
"output": "Yes\n"
},
{
"input": "6 6\n1 3 2\n1 2\n2 3\n2 5\n2 6\n3 4\n4 5\n",
"output": "No\n"
},
{
"input": "3 2\n1 3 2\n1 2\n2 3\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc318/tasks/abc318_h | Problem Statement
Snuke has come up with the following problem.
You are given permutations
P=(P_1,P_2,\ldots,P_N)
and
Q=(Q_1,Q_2,\ldots,Q_N)
of
(1,2,\ldots,N)
.
Let us build a graph with
N
vertices and
N
edges as follows.
For
i=1,2,\ldots,N
in this order, draw an edge of weight
Q_i
connecting vertices
i
and
P_i
bi... | [
{
"input": "3\n",
"output": "4\n"
},
{
"input": "2\n",
"output": "0\n"
},
{
"input": "6\n",
"output": "314708\n"
},
{
"input": "318\n",
"output": "321484323\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_a | Problem Statement
In Japan, swallows can be observed from April through September.
Given an integer
M
between
1
and
12
, determine if swallows can be observed in month
M
(where January is month
1
). | [
{
"input": "4\n",
"output": "Yes\n"
},
{
"input": "12\n",
"output": "No\n"
},
{
"input": "9\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_b | Problem Statement
You are given three positive integers
A
,
B
, and
C
.
Print
Yes
if
A
,
B
, and
C
are all equal, and
No
otherwise. | [
{
"input": "3 3 3\n",
"output": "Yes\n"
},
{
"input": "7 7 8\n",
"output": "No\n"
},
{
"input": "1 2 3\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_c | Problem Statement
You are going to hold a competitive programming contest several times.
Holding a contest requires preparing a total of eight problems: one problem of each
difficulty
from
1
through
8
.
You have prepared
N
problems, the
i
-th of which is of difficulty
A_i
.
If you cannot use the same problem for multip... | [
{
"input": "10\n1 2 3 4 5 5 6 7 8 8\n",
"output": "1\n"
},
{
"input": "27\n3 1 4 1 5 2 6 5 3 5 8 7 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7\n",
"output": "2\n"
},
{
"input": "1\n1\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_d | Problem Statement
You held a programming contest. There were
N
participants, and the
i
-th
(1\leq i\leq N)
of them scored
A _ i
points.
In order to make their scores integers between
0
and
10^9
(inclusive), you are going to determine the relative score of the
i
-th participant for each
i=1,2,\ldots,N
by the following ... | [
{
"input": "3\n200 600 300\n",
"output": "333333333 1000000000 500000000\n"
},
{
"input": "2\n1 999999999\n",
"output": "1 1000000000\n"
},
{
"input": "10\n55580908 183811851 247188750 266233976 335843599 344138315 389659771 389921297 698238479 720357617\n",
"output": "77157382 25516... |
https://atcoder.jp/contests/past16-open/tasks/past202309_e | Problem Statement
Given a positive integer
X
,
find the minimum non-negative integer
n
such that
X\leq 10^n
. | [
{
"input": "23\n",
"output": "2\n"
},
{
"input": "1\n",
"output": "0\n"
},
{
"input": "12345678901234567890\n",
"output": "20\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_h | Problem Statement
You are making plans for an upcoming
N
-day vacation.
On each day, you will either "play" or "study."
Among the
N
days, you need to study on at least
M
days.
You will not study on two or more days in a row.
If you play on day
i
, you get a
joy
of
A_i
; if you study, the joy is
0
on that day.
Find the ... | [
{
"input": "5 2\n3 2 4 1 5\n",
"output": "12\n"
},
{
"input": "5 2\n3 5 4 1 2\n",
"output": "11\n"
},
{
"input": "10 0\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n",
"output": "10000000000\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_i | Problem Statement
N
children are standing in line. Initially, the
i
-th child from the front has
A_i
candies.
You are going to repeat the following operation
M
times.
Give
K
candies to the child with the fewest candies (if there are multiple such children, to the frontmost one among them).
Find how many candies the ch... | [
{
"input": "4 3 2\n3 4 1 10\n",
"output": "5 4 5 10\n"
},
{
"input": "2 1000000000000 100000\n1000000000000 1\n",
"output": "50000500000000000 50000500000000001\n"
},
{
"input": "3 1415 9\n26 53 58\n",
"output": "4292 4292 4288\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_j | Problem Statement
The New Year's bell rang
N
times at equal intervals.
More specifically, the bell rang at times
t, d+t, 2d+t, \ldots, (N-1)d+t
for some positive integer
d
and integer
t
.
Takahashi heard the bell ring at times
A_1, A_2, \ldots, A_K
.
Although it is certain that the bell actually rang when Takahashi hea... | [
{
"input": "8 3\n3 7 15\n",
"output": "2\n2 4\n"
},
{
"input": "500 22\n30 42 138 318 354 378 450 462 522 582 630 738 834 894 930 942 1002 1050 1062 1110 1146 1158\n",
"output": "4\n3 4 6 12\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_k | Problem Statement
There is an
N \times N
grid. Let
(i,j)
denote the square at the
i
-th row from the top and
j
-th square from the left.
Each square is one of the following: the starting point, a goal, a passage, and a hole. The state of the square
(i,j)
is given as
S_{i,j}
.
S
indicates that the square is the starting... | [
{
"input": "5\nSX...\n.....\n..GX.\n..XG.\nX.X.G\n",
"output": "4\n2\n-1\n-1\n"
},
{
"input": "2\nGX\nXS\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_l | Problem Statement
You are given a sequence of length
N
consisting of positive integers,
A=(A_1,A_2,\ldots,A_N)
, and an empty set
S
.
Let us define
f(L,R)
as
\displaystyle\sum_{i=L+1}^R \frac{A_i}{R-L}
for a pair of integers
(L,R)
such that
0\leq L<R\leq N
.
Process
Q
queries in the given order.
Each query is of one of... | [
{
"input": "3 8\n2 3 5\n1 0\n1 3\n2\n1 2\n2\n1 1\n1 3\n2\n",
"output": "10 3\n5 1\n3 1\n"
},
{
"input": "2 3\n1 1\n1 0\n1 2\n2\n",
"output": "1 1\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_m | Problem Statement
There are two line segments in the
xy
-plane. The endpoints of the
i
-th line segment are at coordinates
(a_i,b_i)
and
(c_i,d_i)
.
Determine if these two line segments intersect. | [
{
"input": "0 0 10 10\n0 10 10 0\n",
"output": "Yes\n"
},
{
"input": "0 0 10 0\n0 10 0 0\n",
"output": "Yes\n"
},
{
"input": "0 0 10 0\n0 10 0 1\n",
"output": "No\n"
},
{
"input": "0 3 8 7\n0 3 8 7\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_n | Problem Statement
For a multiset (set with duplicate elements allowed)
S
of positive integers, let us define the function
f(S)
as follows.
First, let
A=(A_0,A_1,...,A_{|S|-1})
be the sorted list of the elements of
S
in ascending order.
Then, let
f(S)=\displaystyle \sum_{i=0}^{|S|-1} K^i A_i
. This constant
K
is given f... | [
{
"input": "10 2\n+ 7\n- 7\n+ 2\n+ 3\n- 2\n+ 3\n+ 5\n- 3\n+ 998244352\n+ 5\n",
"output": "7\n0\n2\n8\n3\n9\n29\n13\n9\n25\n"
}
] |
https://atcoder.jp/contests/past16-open/tasks/past202309_o | Problem Statement
You are given a sequence of length
N
,
A=(A_1,A_2,\ldots,A_N)
, and another of length
K
,
P=(P_1,P_2,\ldots,P_K)
.
We now perform the following
Q
operations on the sequence
A
.
The
q
-th operation
(1\leq q \leq Q)
is represented by integers
l_q,r_q\ (1\leq l_q \leq r_q\leq N)
and a sequence of length
... | [
{
"input": "5 2 3\n0 0 0 0 0\n2 1\n1 4\n3 1\n3 5\n4 1\n2 2\n5 9\n",
"output": "3 6 9 12 6\n"
},
{
"input": "1 3 1\n5\n1 0 1\n1 1\n3 1 4\n",
"output": "8\n"
},
{
"input": "10 3 5\n306334866 801978559 895954374 576826717 755317213 872021310 894146017 171871727 347837426 489203653\n25999592... |
https://atcoder.jp/contests/toyota2023summer-final-open/tasks/toyota2023summer_final_a | Problem Statement
There is a warehouse with a grid of
D\times D
squares.
Let
(0,0)
be the coordinates of the northwesternmost square and
(i,j)
be the coordinates of the squares located
i
squares to the south and
j
squares to the east from there.
The warehouse entrance is in the square
(0,(D-1)/2)
, where
D
is an odd ... | [] |
https://atcoder.jp/contests/toyota2023summer-final/tasks/toyota2023summer_final_a | Problem Statement
There is a warehouse with a grid of
D\times D
squares.
Let
(0,0)
be the coordinates of the northwesternmost square and
(i,j)
be the coordinates of the squares located
i
squares to the south and
j
squares to the east from there.
The warehouse entrance is in the square
(0,(D-1)/2)
, where
D
is an odd ... | [] |
https://atcoder.jp/contests/abc317/tasks/abc317_a | Problem Statement
Naohiro has a monster. The monster's current health is
H
.
He also has
N
kinds of potions, numbered from
1
to
N
in ascending order of effectiveness.
If you give the monster potion
n
, its health will increase by
P_n
. Here,
P_1 \lt P_2 \lt \dots \lt P_N
.
He wants to increase the monster's health to
X... | [
{
"input": "3 100 200\n50 200 999\n",
"output": "2\n"
},
{
"input": "2 10 21\n10 999\n",
"output": "2\n"
},
{
"input": "10 500 999\n38 420 490 585 613 614 760 926 945 999\n",
"output": "4\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_b | Problem Statement
Naohiro had
N+1
consecutive integers, one of each, but he lost one of them.
The remaining
N
integers are given in arbitrary order as
A_1,\ldots,A_N
. Find the lost integer.
The given input guarantees that the lost integer is uniquely determined. | [
{
"input": "3\n2 3 5\n",
"output": "4\n"
},
{
"input": "8\n3 1 4 5 9 2 6 8\n",
"output": "7\n"
},
{
"input": "16\n152 153 154 147 148 149 158 159 160 155 156 157 144 145 146 150\n",
"output": "151\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_c | Problem Statement
A region has
N
towns numbered
1
to
N
, and
M
roads numbered
1
to
M
.
The
i
-th road connects town
A_i
and town
B_i
bidirectionally with length
C_i
.
Find the maximum possible total length of the roads you traverse when starting from a town of your choice and getting to another town without passing thr... | [
{
"input": "4 4\n1 2 1\n2 3 10\n1 3 100\n1 4 1000\n",
"output": "1110\n"
},
{
"input": "10 1\n5 9 1\n",
"output": "1\n"
},
{
"input": "10 13\n1 2 1\n1 10 1\n2 3 1\n3 4 4\n4 7 2\n4 8 1\n5 8 1\n5 9 3\n6 8 1\n6 9 5\n7 8 1\n7 9 4\n9 10 3\n",
"output": "20\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_d | Problem Statement
Takahashi and Aoki are competing in an election.
There are
N
electoral districts. The
i
-th district has
X_i + Y_i
voters, of which
X_i
are for Takahashi and
Y_i
are for Aoki. (
X_i + Y_i
is always an odd number.)
In each district, the majority party wins all
Z_i
seats in that district. Then, whoever ... | [
{
"input": "1\n3 8 1\n",
"output": "3\n"
},
{
"input": "2\n3 6 2\n1 8 5\n",
"output": "4\n"
},
{
"input": "3\n3 4 2\n1 2 3\n7 2 6\n",
"output": "0\n"
},
{
"input": "10\n1878 2089 16\n1982 1769 13\n2148 1601 14\n2189 2362 15\n2268 2279 16\n2394 2841 18\n2926 2971 20\n3091 2146... |
https://atcoder.jp/contests/abc317/tasks/abc317_e | Problem Statement
There is a field divided into a grid of
H
rows and
W
columns.
The square at the
i
-th row from the north (top) and the
j
-th column from the west (left) is represented by the character
A_{i, j}
. Each character represents the following.
.
: An empty square. Passable.
#
: An obstacle. Impassable.
>
,
v... | [
{
"input": "5 7\n....Sv.\n.>.....\n.......\n>..<.#<\n^G....>\n",
"output": "15\n"
},
{
"input": "4 3\nS..\n.<.\n.>.\n..G\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_f | Problem Statement
You are given integers
N,A_1,A_2,A_3
. Find the number, modulo
998244353
, of triples of positive integers
(X_1,X_2,X_3)
that satisfy all of the following three conditions.
1\leq X_i \leq N
for every
i
.
X_i
is a multiple of
A_i
for every
i
.
(X_1 \oplus X_2) \oplus X_3 = 0
, where
\oplus
denotes bitw... | [
{
"input": "13 2 3 5\n",
"output": "4\n"
},
{
"input": "1000000000000000000 1 1 1\n",
"output": "426724011\n"
},
{
"input": "31415926535897932 3 8 4\n",
"output": "759934997\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_g | Problem Statement
There is a grid with
N
rows and
M
columns. The square at the
i
-th row from the top and the
j
-th column from the left contains the integer
A_{i,j}
.
Here, the squares contain
M
occurrences of each of
1,\ldots,N
, for a total of
NM
integers.
You perform the following operations to swap the numbers wri... | [
{
"input": "3 2\n1 1\n2 3\n2 3\n",
"output": "Yes\n1 1\n3 2\n2 3\n"
},
{
"input": "4 4\n1 2 3 4\n1 1 1 2\n3 2 2 4\n4 4 3 3\n",
"output": "Yes\n1 4 3 2\n2 1 1 1\n4 2 2 3\n3 3 4 4\n"
}
] |
https://atcoder.jp/contests/abc317/tasks/abc317_h | Problem Statement
We have a directed graph with
N
vertices numbered
1
to
N
. The graph has no multi-edges but can have self-loops. Also, every edge in the graph satisfies the following condition.
If the edge goes from vertex
s
to vertex
t
, then
s
and
t
satisfy at least one of
0 \leq t - s\leq 2
and
t = 1
.
The presenc... | [
{
"input": "3 3\n1 0 1\n1 1 0\n1 0 0\n1 0 1\n",
"output": "6\n"
},
{
"input": "4 6\n1 1 1 1\n1 1 1 0\n1 1 0 0\n1 0 0 0\n",
"output": "50\n"
},
{
"input": "10 500000\n0 1 0 1 0 0 0 0 1 1\n1 1 1 0 1 1 1 0 1 0\n0 0 1 1 0 0 1 1 0 0\n0 1 1 1 1 1 0 1 1 0\n",
"output": "866263864\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_a | 問題文
広義単調増加な正整数列
(a_1,\ldots,a_N)
が与えられます。
以下の条件をすべて満たす正整数の組
(i,j)
が何個あるかを求めてください。
1 \leq i \lt j \leq N
a_i
は
a_j
の倍数 | [
{
"input": "3\n2 2 3\n",
"output": "1\n"
},
{
"input": "5\n1 1 1 1 1\n",
"output": "10\n"
},
{
"input": "15\n2 17 22 25 26 29 45 47 72 75 75 81 82 84 97\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_b | 問題文
正整数
N,Q
が与えられます。
i=1,2,\ldots,Q
に対し以下の問題を解いてください。
項数
N
、初項
a_i
、公差
d_i
の等差数列から
k_i
個の項を選んだとき、そのスコアを選ばれた項の積とする。
\binom{N}{k_i}
通りの選び方に対するスコアの総和を
(10^9+7)
で割った余りを求めよ。 | [
{
"input": "4 3\n1 1 1\n1 1 2\n3 5 3\n",
"output": "10\n35\n3318\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_c | 問題文
黒板に
N
以下の正整数が
1
個ずつ書かれています。また、
M
個の正整数
x_1,\ldots,x_M
が与えられます。ここで、
i \neq j
ならば
x_i
と
x_j
は互いに素であることが保証されます。
あなたは次の操作を
0
回以上何度でも行えます。
1
以上
M
以下の整数
i
とある
x_i
の倍数
y
を選ぶ。黒板に
y
が書かれているならばそのうち
1
個を選び、
\frac{y}{x_i}
に書き換える。
操作後に黒板に書かれている整数の総和の最小値を求めてください。 | [
{
"input": "10 2\n2 3\n",
"output": "24\n"
},
{
"input": "2000000000 3\n20 23 7\n",
"output": "1597222223653885214\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_d | 問題文
正整数
K
と
4
種類の英大文字
ATGC
のみからなる文字列
S
が与えられます。
S君とU君がS君から始めて交互に次の操作を行います。
後述の条件を満たしながら以下の
3
種類の操作のうち
1
つを選んで実行する。
S
のある
1
文字を
ATGC
のどれか
1
文字に置換する。
S
のある位置(先頭・末尾でもよい)に
ATGC
のどれか
1
文字を挿入する。
S
のある
1
文字を削除する(この操作は
S
が非空の時にのみ行える)。
条件:操作前の文字列を
X
、操作後の文字列を
Y
とした時、以下の
2
つの条件を満たす
Y
の文字列長は
K
以下
Y
は
X
より辞書順で真に大きい
先に操作が出来なくなった方が負... | [
{
"input": "3\nAC\n",
"output": "S\n"
},
{
"input": "1\nT\n",
"output": "U\n"
},
{
"input": "1200\nAGC\n",
"output": "S\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_e | 問題文
(1,2,\ldots,N)
の順列
P=(p_1,p_2,\ldots,p_N)
が与えられます。
P
を
1
個以上の空でない連続部分列
X_1,X_2,\ldots,X_K
に分割し、以下のように
(m_1,m_2,\ldots,m_K)
を定めました。
i
が奇数ならば
m_i
は
X_i
に含まれる値の最小値
i
が偶数ならば
m_i
は
X_i
に含まれる値の最大値
(m_1,m_2,\ldots,m_K)
としてあり得るものの個数を
(10^9+7)
で割った余りを求めてください。 | [
{
"input": "3\n1 2 3\n",
"output": "3\n"
},
{
"input": "5\n5 4 1 3 2\n",
"output": "15\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_f | 問題文
以下の条件を満たす長さ
N+M
の文字列
X
が存在するかどうかを判定し、存在する場合は一つ示してください。
X
は
N
個の
0
と
M
個の
1
からなる
X
の長さ
K
の部分文字列はいずれも
1
をちょうど
S
個含む | [
{
"input": "2 1 2 1\n",
"output": "Yes\n010\n"
},
{
"input": "10 10 20 2\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_g | 問題文
S君は
xy
平面上の
(X,Y)
にある畑で農業を始めることにしました。
しかし、平面上には
N
頭のイノシシがいて畑を荒らそうとしています。
i
番目のイノシシは
(x_i,y_i)
に棲んでいます。
S君が対処法を求めて役所に相談したところ、
M
個の計画を提案されました。
i
番目の計画は直線
y = a_i x + b_i
上に柵を設置するというもので、実行する場合
2^{i-1}
円かかります。
畑を守るには
i=1,2,\ldots,N
すべてに対して、
(X,Y)
と
(x_i,y_i)
を結ぶ線分(端点含む)とある柵に対応する直線が交点を持つ必要があります。
計画を
0
個以上選んで実行し、畑を守るのに必要... | [
{
"input": "3 3 1 1\n2 4\n3 9\n-5 10\n-4 8\n3 -3\n-7 7\n",
"output": "5\n"
},
{
"input": "2 2 0 0\n10 3\n10 3\n5 2\n5 2\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/maximum-cup-2023/tasks/maximum_cup_2023_h | 問題文
変数
a
があり、初め
a=X
です。
i=1,2,\ldots,N
の順に次の操作をします。
1
以上
m_i
以下の整数を選び、
c
とする。そして、
a
を以下の条件を満たす整数
a'
の最小値に置き換える。
a \lt a'
a'
の二進数表記にはちょうど
c
個の
1
が含まれる
操作終了後の
a
の最大値を求めてください。 | [
{
"input": "1 11\n2\n",
"output": "16\n"
},
{
"input": "23 1000\n2 5 6 5 2 1 7 9 7 2 5 5 2 4 7 6 2 2 8 7 7 9 8\n",
"output": "4294967296\n"
}
] |
https://atcoder.jp/contests/editor-update-test/tasks/editor_update_test_a | 問題文
以下の条件を満たす整数の組
x,y
がいくつあるかを求めて下さい。
0 \leq x, y \leq N
Ax+By
は
C
の倍数
T
個のテストケースが与えられるので、それぞれについて答えを求めてください。 | [
{
"input": "1\n2 3 4 5\n",
"output": "2\n"
},
{
"input": "1\n1000 314159265 271828182 2023\n",
"output": "496\n"
}
] |
https://atcoder.jp/contests/editor-update-test/tasks/editor_update_test_b | 問題文
N
頂点の根付き木があります。根は頂点
1
です。頂点
i (2 \leq i \leq N)
の親は頂点
P_i
です。
各
i (1 \leq i \leq N)
について、頂点
i
を根とする部分木の頂点数を求めて下さい。すなわち、頂点
j
から頂点
1
へ到達するために必ず頂点
i
を経由する必要のあるような
j
の個数を求めて下さい。 | [
{
"input": "4\n1\n2\n2\n",
"output": "4\n3\n1\n1\n"
},
{
"input": "10\n1\n2\n3\n2\n1\n5\n6\n3\n4\n",
"output": "10\n7\n4\n2\n2\n2\n1\n1\n1\n1\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_a | Problem Statement
You are given a string
S
consisting of lowercase English letters.
Remove all occurrences of
a
,
e
,
i
,
o
,
u
from
S
and print the resulting string.
S
contains at least one character other than
a
,
e
,
i
,
o
,
u
. | [
{
"input": "atcoder\n",
"output": "tcdr\n"
},
{
"input": "xyz\n",
"output": "xyz\n"
},
{
"input": "aaaabbbbcccc\n",
"output": "bbbbcccc\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_b | Problem Statement
In the calendar of AtCoderLand, a year consists of
M
months: month
1
, month
2
,
\dots
, month
M
. The
i
-th month consists of
D_i
days: day
1
, day
2
,
\dots
, day
D_i
.
Furthermore, the number of days in a year is odd, that is,
D_1+D_2+\dots+D_M
is odd.
Find what day of what month is the middle day ... | [
{
"input": "12\n31 28 31 30 31 30 31 31 30 31 30 31\n",
"output": "7 2\n"
},
{
"input": "1\n1\n",
"output": "1 1\n"
},
{
"input": "6\n3 1 4 1 5 9\n",
"output": "5 3\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_c | Problem Statement
We have
N
cups of ice cream.
The flavor and deliciousness of the
i
-th cup are
F_i
and
S_i
, respectively (
S_i
is an even number).
You will choose and eat two of the
N
cups.
Your satisfaction here is defined as follows.
Let
s
and
t
(
s \ge t
) be the deliciousness of the eaten cups.
If the two cups h... | [
{
"input": "4\n1 4\n2 10\n2 8\n3 6\n",
"output": "16\n"
},
{
"input": "4\n4 10\n3 2\n2 4\n4 12\n",
"output": "17\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_d | Problem Statement
There are
H \times W
cookies in
H
rows and
W
columns.
The color of the cookie at the
i
-row from the top and
j
-th column from the left is represented by a lowercase English letter
c_{i,j}
.
We will perform the following procedure.
1. For each row, perform the following operation: if there are two or ... | [
{
"input": "4 3\naaa\naaa\nabc\nabd\n",
"output": "2\n"
},
{
"input": "2 5\naaaaa\nabcde\n",
"output": "4\n"
},
{
"input": "3 3\nooo\nooo\nooo\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_e | Problem Statement
We have
N
books numbered
1
to
N
.
Book
i
assumes that you have read
C_i
books, the
j
-th of which is book
P_{i,j}
: you must read all these
C_i
books before reading book
i
.
Here, you can read all the books in some order.
You are trying to read the minimum number of books required to read book
1
.
Pri... | [
{
"input": "6\n3 2 3 4\n2 3 5\n0\n1 5\n0\n0\n",
"output": "5 3 4 2\n"
},
{
"input": "6\n1 2\n1 3\n1 4\n1 5\n1 6\n0\n",
"output": "6 5 4 3 2\n"
},
{
"input": "8\n1 5\n1 6\n1 7\n1 8\n0\n0\n0\n0\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_f | Problem Statement
There is a race through checkpoints
1,2,\dots,N
in this order on a coordinate plane.
The coordinates of checkpoint
i
are
(X_i,Y_i)
, and all checkpoints have different coordinates.
Checkpoints other than checkpoints
1
and
N
can be skipped.
However, let
C
be the number of checkpoints skipped, and the f... | [
{
"input": "6\n0 0\n1 1\n2 0\n0 1\n1 0\n2 1\n",
"output": "5.82842712474619009753\n"
},
{
"input": "10\n1 8\n3 7\n9 4\n4 9\n6 1\n7 5\n0 0\n1 3\n6 8\n6 4\n",
"output": "24.63441361516795872523\n"
},
{
"input": "10\n34 24\n47 60\n30 31\n12 97\n87 93\n64 46\n82 50\n14 7\n17 24\n3 78\n",
... |
https://atcoder.jp/contests/abc315/tasks/abc315_g | Problem Statement
You are given integers
N,A,B,C,X
. Find the number of triples of integers
(i,j,k)
that satisfy all of the following conditions.
1 \le i,j,k \le N
Ai+Bj+Ck=X | [
{
"input": "5 3 1 5 15\n",
"output": "3\n"
},
{
"input": "1 1 1 1 1\n",
"output": "0\n"
},
{
"input": "100000 31415 92653 58979 1000000000\n",
"output": "2896\n"
}
] |
https://atcoder.jp/contests/abc315/tasks/abc315_h | Problem Statement
You are given a sequence
(A_1, A_2, \ldots , A_N)
.
Let us define a sequence
(F_0, F_1, \ldots , F_N)
by the following formulae.
F_0 = 1
F_n = A_n\displaystyle\sum_{i+j<n}F_iF_j
(1 \leq n \leq N)
Find
F_1, \ldots , F_N
modulo
998244353
. | [
{
"input": "5\n1 2 3 4 5\n",
"output": "1 6 48 496 6240\n"
},
{
"input": "3\n12345 678901 2345678\n",
"output": "12345 790834943 85679169\n"
}
] |
https://atcoder.jp/contests/agc064/tasks/agc064_a | Problem Statement
You are given a positive integer
N
.
Print an integer sequence of length
L \coloneqq N(N+1)/2
,
A = (A_1, A_2, \ldots, A_L)
, that satisfies all of the following conditions.
A
contains exactly
i
occurrences of
i
for every
i = 1, 2, \ldots, N
.
1 \leq |A_i - A_{i+1}| \leq 2
for every
i = 1, 2, \ldots,... | [
{
"input": "4\n",
"output": "1 3 4 2 4 3 4 2 4 3\n"
}
] |
https://atcoder.jp/contests/agc064/tasks/agc064_b | Problem Statement
You are given a connected undirected graph
G
with
N
vertices and
M
edges. For each
i=1,2,\ldots,M
, the
i
-th edge connects vertices
a_i
and
b_i
, and is colored red if
c_i=
R
and blue if
c_i=
B
.
Determine if there is a spanning tree of
G
that satisfies the following condition, and if so, display suc... | [
{
"input": "3 3\n1 2 R\n1 3 B\n2 3 B\nRRB\n",
"output": "Yes\n2 1\n"
},
{
"input": "3 4\n1 2 R\n1 2 B\n1 3 B\n2 3 B\nRRR\n",
"output": "No\n"
},
{
"input": "8 16\n5 7 B\n2 7 R\n1 6 R\n1 4 R\n6 7 R\n4 6 B\n4 8 R\n2 3 R\n3 5 R\n6 7 B\n2 6 B\n5 6 R\n1 3 B\n4 5 B\n2 7 B\n1 8 B\nBRBRRBRB\n",
... |
https://atcoder.jp/contests/agc064/tasks/agc064_c | Problem Statement
Takahashi and Aoki will play the following game.
For each
i=1,2,\ldots,N
in this order, do the following.
Write each integer from
l_i
through
r_i
once on the blackboard. (Here,
l_i
and
r_i
are non-negative integers from the input.)
While one or more integers are written on the blackboard, the players ... | [
{
"input": "3\n2\n1 2\n5 7\n1\n0 100\n10\n1312150450968413 28316250877914571\n74859962623690078 84324828731963974\n148049062628894320 252509054433933439\n269587449430302150 335408917861648766\n349993004923078531 354979173822804781\n522842184971407769 578223540024979436\n585335723211047194 615812229161735895\n64... |
https://atcoder.jp/contests/agc064/tasks/agc064_d | Problem Statement
There are
N
squares: square
1
, square
2
,
\ldots
, square
N
. Each square is colored red or blue.
The colors of the squares are represented by a string
S
of length
N
. Specifically, for each
i = 1, 2, \ldots, N
, square
i
is colored red if the
i
-th character of
S
is
R
, and blue if it is
B
.
Squar... | [
{
"input": "4\nRBRB\n",
"output": "2\n"
},
{
"input": "20\nRRBRRRBBRBBBBRBRBRBB\n",
"output": "92378\n"
}
] |
https://atcoder.jp/contests/agc064/tasks/agc064_e | Problem Statement
You are given a positive integer
N
and integer sequences of length
N
:
A=(a_1,\ldots,a_N)
and
B=(b_1,\ldots,b_N)
.
Let
X
be the multiset of
N^2
instances
(a_i+b_j)(1 \leq i,j \leq N)
.
For an
N \times N
matrix
M
whose elements are integers between
-10^{18}
and
10^{18}
, inclusive, we define the score ... | [
{
"input": "3\n1\n5\n-10\n2\n0 -1\n8 -11\n3\n20 23 26\n1 2 3\n",
"output": "-5\n8 9\n-10 -9\n2 9 4\n7 5 3\n6 1 8\n"
}
] |
https://atcoder.jp/contests/agc064/tasks/agc064_f | Problem Statement
You are given a positive integer
N
.
Print the number, modulo
998244353
, of sequences
A
of length
3N
that contain each integer from
1
through
N
three times and satisfy the following condition.
A
has no contiguous subsequence of length
N
that is a permutation of the sequence
(1, 2, \ldots, N)
. | [
{
"input": "3\n",
"output": "132\n"
},
{
"input": "123456\n",
"output": "31984851\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_a | Problem Statement
The number pi to the
100
-th decimal place is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
.
You are given an integer
N
between
1
and
100
, inclusive.
Print the value of pi to the
N
-th decimal place.
More precisely, truncate the value of pi to... | [
{
"input": "2\n",
"output": "3.14\n"
},
{
"input": "32\n",
"output": "3.14159265358979323846264338327950\n"
},
{
"input": "100\n",
"output": "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_b | Problem Statement
N
people, person
1
, person
2
,
\ldots
, person
N
, are playing roulette.
The outcome of a spin is one of the
37
integers from
0
to
36
.
For each
i = 1, 2, \ldots, N
, person
i
has bet on
C_i
of the
37
possible outcomes:
A_{i, 1}, A_{i, 2}, \ldots, A_{i, C_i}
.
The wheel has been spun, and the outco... | [
{
"input": "4\n3\n7 19 20\n4\n4 19 24 0\n2\n26 10\n3\n19 31 24\n19\n",
"output": "2\n1 4\n"
},
{
"input": "3\n1\n1\n1\n2\n1\n3\n0\n",
"output": "0\n\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_c | Problem Statement
You are given a string
S
of length
N
consisting of lowercase English letters.
Each character of
S
is painted in one of the
M
colors: color
1
, color
2
, ..., color
M
; for each
i = 1, 2, \ldots, N
, the
i
-th character of
S
is painted in color
C_i
.
For each
i = 1, 2, \ldots, M
in this order, let us p... | [
{
"input": "8 3\napzbqrcs\n1 2 3 1 2 2 1 2\n",
"output": "cszapqbr\n"
},
{
"input": "2 1\naa\n1 1\n",
"output": "aa\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_d | Problem Statement
You are given a string
S
of length
N
consisting of uppercase and lowercase English letters.
Let us perform
Q
operations on the string
S
.
The
i
-th operation
(1\leq i\leq Q)
is represented by a tuple
(t _ i,x _ i,c _ i)
of two integers and one character, as follows.
If
t _ i=1
, change the
x _ i
-th c... | [
{
"input": "7\nAtCoder\n5\n1 4 i\n3 0 a\n1 5 b\n2 0 a\n1 4 Y\n",
"output": "atcYber\n"
},
{
"input": "35\nTheQuickBrownFoxJumpsOverTheLazyDog\n10\n2 0 a\n1 19 G\n1 13 m\n1 2 E\n1 21 F\n2 0 a\n1 27 b\n3 0 a\n3 0 a\n1 15 i\n",
"output": "TEEQUICKBROWMFiXJUGPFOVERTBELAZYDOG\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_e | Problem Statement
There are
N
roulette wheels.
The
i
-th
(1\leq i\leq N)
wheel has
P _ i
integers
S _ {i,1},S _ {i,2},\ldots,S _ {i,P _ i}
written on it, and you can play it once by paying
C _ i
yen.
When you play the
i
-th wheel once, an integer
j
between
1
and
P _ i
, inclusive, is chosen uniformly at random, and you... | [
{
"input": "3 14\n100 2 5 9\n50 4 1 2 4 8\n70 5 2 4 2 8 8\n",
"output": "215.913355350494384765625\n"
},
{
"input": "2 100\n1 2 1 2\n10 6 0 0 0 0 0 100\n",
"output": "60\n"
},
{
"input": "20 90\n3252 9 0 4 2 7 3 2 3 2 4\n2147 1 1\n4033 8 0 4 1 7 5 2 5 0\n3795 6 6 6 2 3 2 2\n3941 7 2 4 4 ... |
https://atcoder.jp/contests/abc314/tasks/abc314_f | Problem Statement
N
players, player
1
, player
2
, ..., player
N
, participate in a game tournament. Just before the tournament starts, each player forms a one-person team, so there are
N
teams in total.
The tournament has a total of
N-1
matches. In each match, two different teams are chosen. One team goes first, and t... | [
{
"input": "5\n1 2\n4 3\n5 3\n1 4\n",
"output": "698771048 698771048 964969543 964969543 133099248\n"
},
{
"input": "15\n9 2\n8 10\n13 6\n12 11\n7 10\n4 10\n14 2\n5 4\n1 15\n15 2\n6 9\n8 11\n6 3\n2 8\n",
"output": "43970290 310168785 806914186 501498951 950708909 272140427 335124893 168750835 31... |
https://atcoder.jp/contests/abc314/tasks/abc314_g | Problem Statement
There are
N
monsters in a cave: monster
1
, monster
2
,
\ldots
, monster
N
. Each monster has a positive integer
attack power
and a
type
represented by an integer between
1
and
M
, inclusive.
Specifically, for
i = 1, 2, \ldots, N
, the attack power and type of monster
i
are
A_i
and
B_i
, respectively.... | [
{
"input": "7 3 7\n3 2\n1 1\n4 2\n1 2\n5 1\n9 3\n2 3\n",
"output": "2 5 7 7\n"
},
{
"input": "15 5 400\n29 5\n27 4\n79 1\n27 2\n30 3\n4 1\n89 2\n88 3\n75 5\n3 1\n39 4\n12 1\n62 4\n38 2\n49 1\n",
"output": "8 12 15 15 15 15\n"
}
] |
https://atcoder.jp/contests/abc314/tasks/abc314_h | Problem Statement
There are
N
line segments in a coordinate plane, and the
i
-th line segment
(1\leq i\leq N)
has two points
(a _ i,b _ i)
and
(c _ i,d _ i)
as its endpoints.
Here, each line segment includes its endpoints.
Additionally, no two line segments share a point.
We want to place a single closed disk in this p... | [
{
"input": "4\n2 3 2 10\n4 0 12 6\n4 8 6 3\n7 8 10 8\n",
"output": "3.319048676309097923796460081961\n"
},
{
"input": "20\n0 18 4 28\n2 21 8 21\n3 4 10 5\n3 14 10 13\n5 9 10 12\n6 9 10 6\n6 28 10 18\n12 11 15 13\n12 17 12 27\n13 17 20 18\n13 27 19 26\n16 1 16 13\n16 22 19 25\n17 22 20 19\n18 4 23 4\... |
https://atcoder.jp/contests/newjudge-2308-heuristic/tasks/newjudge_2308_heuristic_a | Problem Statement
AtCoder currently hosts four types of contests, ABC, ARC, AGC, and AHC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. ... | [] |
https://atcoder.jp/contests/newjudge-2308-algorithm/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/newjudge-2308-algorithm/tasks/abc273_b | Problem Statement
Given a non-negative integer
X
, perform the following operation for
i=1,2,\dots,K
in this order and find the resulting
X
.
Round
X
off to the nearest
10^i
.
Formally, replace
X
with
Y
that is "the largest multiple of
10^i
that minimizes
|Y-X|
."
Here are some examples:
Rounding
273
off to the nearest... | [
{
"input": "2048 2\n",
"output": "2100\n"
},
{
"input": "1 15\n",
"output": "0\n"
},
{
"input": "999 3\n",
"output": "1000\n"
},
{
"input": "314159265358979 12\n",
"output": "314000000000000\n"
}
] |
https://atcoder.jp/contests/newjudge-2308-algorithm/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/newjudge-2308-algorithm/tasks/abc309_d | Problem Statement
We have an undirected graph with
(N_1+N_2)
vertices and
M
edges. For
i=1,2,\ldots,M
, the
i
-th edge connects vertex
a_i
and vertex
b_i
.
The following properties are guaranteed:
Vertex
u
and vertex
v
are connected, for all integers
u
and
v
with
1 \leq u,v \leq N_1
.
Vertex
u
and vertex
v
are connect... | [
{
"input": "3 4 6\n1 2\n2 3\n4 5\n4 6\n1 3\n6 7\n",
"output": "5\n"
},
{
"input": "7 5 20\n10 11\n4 5\n10 12\n1 2\n1 5\n5 6\n2 4\n3 5\n9 10\n2 5\n1 4\n11 12\n9 12\n8 9\n5 7\n3 7\n3 6\n3 4\n8 12\n9 11\n",
"output": "4\n"
}
] |
https://atcoder.jp/contests/newjudge-2308-algorithm/tasks/abc304_e | Problem Statement
You are given an undirected graph
G
with
N
vertices and
M
edges.
For
i = 1, 2, \ldots, M
, the
i
-th edge is an undirected edge connecting vertices
u_i
and
v_i
.
A graph with
N
vertices is called
good
if the following condition holds for all
i = 1, 2, \ldots, K
:
there is no path connecting vertices
... | [
{
"input": "6 6\n1 2\n2 3\n2 3\n3 1\n5 4\n5 5\n3\n1 5\n2 6\n4 3\n4\n2 5\n2 6\n5 6\n5 4\n",
"output": "No\nNo\nYes\nYes\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.