url stringlengths 49 92 | description stringlengths 22 4.78k | cases listlengths 0 6 |
|---|---|---|
https://atcoder.jp/contests/abc281/tasks/abc281_h | Problem Statement
Takahashi has
A
kinds of level-
1
gems, and
10^{10^{100}}
gems of each of those kinds.
For an integer
n
greater than or equal to
2
, he can put
n
gems that satisfy all of the following conditions into a cauldron to generate a level-
n
gem in return.
No two gems are of the same kind.
Every gem's level ... | [
{
"input": "3 3\n",
"output": "10\n"
},
{
"input": "1 100\n",
"output": "100\n"
},
{
"input": "200000 1000000000\n",
"output": "797585162\n"
}
] |
https://atcoder.jp/contests/future-contest-2023-final-open/tasks/future_contest_2023_final_a | Problem Statement
A psychic, Takahashi, has discovered a treasure map.
According to the map, there are
50
buried treasures under the ground of an uninhabited island.
The island has a circular shape with a radius of
R=10^9
.
Unfortunately, the map does not indicate the locations of the buried treasures.
Since it is ... | [] |
https://atcoder.jp/contests/future-contest-2023-final/tasks/future_contest_2023_final_a | Problem Statement
A psychic, Takahashi, has discovered a treasure map.
According to the map, there are
50
buried treasures under the ground of an uninhabited island.
The island has a circular shape with a radius of
R=10^9
.
Unfortunately, the map does not indicate the locations of the buried treasures.
Since it is ... | [] |
https://atcoder.jp/contests/agc059/tasks/agc059_a | Problem Statement
Consider a string
t
consisting only of characters
A
,
B
, and
C
.
We can do the following operation with it:
Choose any substring
t[l:r]
and any permutation
(X, Y, Z)
of characters
(
A
,
B
,
C
)
. Here,
t[l:r]
denotes the substring formed by the
l
-th through the
r
-th characters of
t
, where
l
and
r... | [
{
"input": "6 4\nABCCCA\n3 5\n2 3\n1 3\n1 6\n",
"output": "0\n1\n2\n2\n"
}
] |
https://atcoder.jp/contests/agc059/tasks/agc059_b | Problem Statement
You have
N
balls of colors
C_1, C_2, \ldots, C_N
.
Here, all colors are represented by an integer between
1
and
N
inclusive.
You want to arrange the balls on a circle. After you do that, you will count the number of pairs of colors
(X, Y)
such that
X < Y
and there exist two adjacent balls of colors
... | [
{
"input": "3\n3\n1 2 3\n4\n1 2 1 3\n5\n2 2 5 3 3\n",
"output": "1 2 3 \n2 1 3 1 \n3 3 2 5 2 \n"
}
] |
https://atcoder.jp/contests/agc059/tasks/agc059_c | Problem Statement
A teacher has a hidden permutation
P=(P_1,P_2,\ldots,P_N)
of
(1,2,\cdots,N)
.
You are going to determine it.
To do this, you prepared a sequence of pairs of integers
(A_1,B_1),(A_2,B_2),\ldots,(A_{N(N-1)/2},B_{N(N-1)/2})
; this is a permutation of all pairs of the form
(a,b)
(
1 \le a < b \le N
).
N... | [
{
"input": "2\n1 2\n",
"output": "2\n"
},
{
"input": "4\n1 2\n1 3\n2 3\n2 4\n3 4\n1 4\n",
"output": "4\n"
},
{
"input": "5\n1 2\n2 3\n3 4\n4 5\n1 5\n1 3\n2 4\n3 5\n1 4\n2 5\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/agc059/tasks/agc059_d | Problem Statement
For an integer array
A=(A_1, A_2, \ldots, A_{N + K-1})
(
1 \leq A_i \leq N+K-1
), let's construct an array
B=(B_1, B_2, \ldots, B_N)
, where
B_i
is the number of distinct elements in
A_i,A_{i+1},\ldots,A_{i+K-1}
.
You are given
B_1, B_2, \ldots, B_N
. Determine if there exists an array
A
which could h... | [
{
"input": "3\n3 3\n1 2 1\n4 3\n1 2 2 1\n6 4\n3 3 3 3 3 3\n",
"output": "NO\nYES\n1 1 1 2 2 2 \nYES\n1 2 3 1 2 3 1 2 3 \n"
}
] |
https://atcoder.jp/contests/agc059/tasks/agc059_e | Problem Statement
You have an
N \times N
grid board.
You want to color all cells in
3
colors so that no two adjacent (edge-sharing) cells have the same color.
You have already painted the border of the board. Determine if you can color the rest of the board properly.
More precisely, you are given a string
S
of length
4... | [
{
"input": "4\n3\n12312312\n4\n121212121212\n7\n321312312312121212121321\n7\n321312312312121312121321\n",
"output": "NO\nYES\nNO\nYES\n"
}
] |
https://atcoder.jp/contests/agc059/tasks/agc059_f | Problem Statement
Given
N, pos, val
, find the number of permutations
P=(P_1, P_2, \ldots, P_N)
of
(1,2,\ldots,N)
that satisfy all of the following conditions, modulo
10^9+7
:
LIS(P) + LDS(P) = N+1
P_{pos} = val
Here,
LIS(P)
denotes the length of the longest increasing subsequence of
P
, and
LDS(P)
denotes the length o... | [
{
"input": "3 2 2\n",
"output": "2\n"
},
{
"input": "4 1 1\n",
"output": "6\n"
},
{
"input": "5 2 5\n",
"output": "11\n"
},
{
"input": "2022 69 420\n",
"output": "128873576\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_a | Problem Statement
There is a grid with
H
rows from top to bottom and
W
columns from left to right. Each square has a piece placed on it or is empty.
The state of the grid is represented by
H
strings
S_1, S_2, \ldots, S_H
, each of length
W
.
If the
j
-th character of
S_i
is
#
, the square at the
i
-th row from the top... | [
{
"input": "3 5\n#....\n.....\n.##..\n",
"output": "3\n"
},
{
"input": "1 10\n..........\n",
"output": "0\n"
},
{
"input": "6 5\n#.#.#\n....#\n..##.\n####.\n..#..\n#####\n",
"output": "16\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_b | Problem Statement
You are given an integer
N
and a sequence
S=(S_1,\ldots,S_N)
of length
N
.
Find a sequence
A=(A_1,\ldots,A_N)
of length
N
that satisfies the following condition for all
k=1,\ldots,N
:
A_1+A_2+\ldots+A_k = S_k
.
Such a sequence
A
always exists and is unique. | [
{
"input": "3\n3 4 8\n",
"output": "3 1 4\n"
},
{
"input": "10\n314159265 358979323 846264338 -327950288 419716939 -937510582 97494459 230781640 628620899 -862803482\n",
"output": "314159265 44820058 487285015 -1174214626 747667227 -1357227521 1035005041 133287181 397839259 -1491424381\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_c | Problem Statement
You are given strings
S
and
T
.
S
consists of lowercase English letters, and
T
is obtained by inserting a lowercase English letter into
S
.
Find the position of the inserted character in
T
.
If there are multiple candidates, find any of them. | [
{
"input": "atcoder\natcorder\n",
"output": "5\n"
},
{
"input": "million\nmilllion\n",
"output": "5\n"
},
{
"input": "vvwvw\nvvvwvw\n",
"output": "3\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_d | Problem Statement
You are given an integer
K
greater than or equal to
2
.
Find the minimum positive integer
N
such that
N!
is a multiple of
K
.
Here,
N!
denotes the factorial of
N
. Under the Constraints of this problem, we can prove that such an
N
always exists. | [
{
"input": "30\n",
"output": "5\n"
},
{
"input": "123456789011\n",
"output": "123456789011\n"
},
{
"input": "280\n",
"output": "7\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_e | Problem Statement
There is a monster with initial stamina
N
.
Takahashi repeatedly attacks the monster while the monster's stamina remains
1
or greater.
An attack by Takahashi reduces the monster's stamina by
2
with probability
\frac{P}{100}
and by
1
with probability
1-\frac{P}{100}
.
Find the expected value, modulo
99... | [
{
"input": "3 10\n",
"output": "229596204\n"
},
{
"input": "5 100\n",
"output": "3\n"
},
{
"input": "280 59\n",
"output": "567484387\n"
}
] |
https://atcoder.jp/contests/abc280/tasks/abc280_f | Problem Statement
There are
N
towns numbered
1,\ldots,N
and
M
roads numbered
1,\ldots,M
.
Road
i
connects towns
A_i
and
B_i
. When you use a road, your
score
changes as follows:
when you move from town
A_i
to town
B_i
using road
i
, your score increases by
C_i
; when you move from town
B_i
to town
A_i
using road
i
, y... | [
{
"input": "5 5 3\n1 2 1\n1 2 2\n3 4 1\n4 5 1\n3 5 2\n5 3\n1 2\n3 1\n",
"output": "-2\ninf\nnan\n"
},
{
"input": "2 1 1\n1 1 1\n1 1\n",
"output": "inf\n"
},
{
"input": "9 7 5\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n3 2 3\n8 4 6\n2 6\n4 3\n3 8\n3 2\n7 9\n",
"output": "inf\nnan\nnan\ninf\n... |
https://atcoder.jp/contests/abc280/tasks/abc280_g | Problem Statement
We have an infinite hexagonal grid shown below.
A hexagonal cell is represented as
(i,j)
with two integers
i
and
j
.
Cell
(i,j)
is adjacent to the following six cells:
(i-1,j-1)
(i-1,j)
(i,j-1)
(i,j+1)
(i+1,j)
(i+1,j+1)
Let us define the distance between two cells
X
and
Y
by the minimum number of move... | [
{
"input": "3 1\n0 0\n0 1\n1 0\n",
"output": "5\n"
},
{
"input": "9 1\n0 0\n0 1\n0 2\n1 0\n1 1\n1 2\n2 0\n2 1\n2 2\n",
"output": "33\n"
},
{
"input": "5 10000000000\n314159265 358979323\n846264338 -327950288\n-419716939 937510582\n-97494459 -230781640\n628620899 862803482\n",
"output... |
https://atcoder.jp/contests/abc280/tasks/abc280_h | Problem Statement
You are given
N
strings
S_1,S_2,\ldots, S_N
.
Let
M = \displaystyle\sum_{i=1}^N \frac{|S_i|(|S_i|+1)}{2}
.
For a string
S
and integers
L
and
R
, let us denote by
S[L, R]
the substring consisting of the
L
-th through
R
-th characters of
S
.
A sequence of triples of integers
((K_1, L_1, R_1), (K_2, L_2... | [
{
"input": "2\nabab\ncab\n2\n5 14\n",
"output": "1 3 4\n2 1 1\n"
},
{
"input": "3\na\na\nba\n2\n1 2\n",
"output": "1 1 1\n1 1 1\n"
},
{
"input": "10\ngxgpuamkx\nszhkbpphykin\nezplvfja\nmopodotkrj\nrimlvumuar\nnexcfyce\neurgvjyos\ndhvuyfvt\nnrdyluacvra\nggwnpnzij\n6\n74 268 310 380 455 48... |
https://atcoder.jp/contests/past202212-open/tasks/past202212_a | Problem Statement
Takahashi has come to an amusement arcade with
N
yen (Japanese currency) in his pocket.
In the arcade, he can pay
X
yen for
Y
tokens any number of times (possibly zero).
Find the maximum total number of tokens that he can get. | [
{
"input": "12 5 3\n",
"output": "6\n"
},
{
"input": "4 5 3\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_b | Problem Statement
You are given integers
A
and
C
, and non-negative integers
B
and
D
.
If
\frac{A}{B}<\frac{C}{D}
, print
<
;
if
\frac{A}{B}>\frac{C}{D}
, print
>
;
if
\frac{A}{B}=\frac{C}{D}
, print
=
. | [
{
"input": "1 2 1 3\n",
"output": ">\n"
},
{
"input": "-3 -6 1 2\n",
"output": "=\n"
},
{
"input": "-1 3 1 -4\n",
"output": "<\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_c | Problem Statement
You are given an integer sequence of length
N
:
A = (A_1, \dots, A_N)
.
Find the number of integers
X
that satisfy the following condition.
There are integers
i
,
j
, and
k
such that
A_i \times A_j \times A_k = X
and
1 \leq i \lt j \lt k \leq N
. | [
{
"input": "4\n2 1 3 2\n",
"output": "3\n"
},
{
"input": "10\n3 1 4 1 5 9 2 6 5 3\n",
"output": "37\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_d | Problem Statement
N
players will play a game using cards.
Initially, the first pile contains
M
cards, the second pile contains
0
cards, and each player has
0
cards.
Each card has one of the symbols
+
,
0
, and
-
written on it. The symbol on the
i
-th card from the top of the initial first pile is
S_i
.
In the game, the... | [
{
"input": "3 6\n000--+\n",
"output": "0\n0\n6\n"
},
{
"input": "2 6\n++++++\n",
"output": "3\n3\n"
},
{
"input": "7 20\n++-0+-0++-++0-+0-0-0\n",
"output": "6\n3\n0\n4\n0\n2\n0\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_e | Problem Statement
A string consisting of
(
and
)
is said to be a
correct bracket sequence
if it can be made empty by erasing a contiguous occurrence of
()
zero or more times.
For instance,
()
,
(())
, and
(()())()
are correct bracket sequences, while
)(
,
())
, and
(()()))(()
are not.
You are given a string
S
consisti... | [
{
"input": "(())\n",
"output": "Yes\n"
},
{
"input": "())(\n",
"output": "No\n"
},
{
"input": "(\n",
"output": "No\n"
},
{
"input": "((())()()())()()\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_f | Problem Statement
Snuke played
N
matches of a
4
-player game, and ranked
1
-st
A
times,
2
-nd
B
times,
3
-rd
C
times, and
4
-th
D
times.
Snuke is happy if the value of his average rank is at most
X
.
At least how many additional matches must be played to make him happy? | [
{
"input": "4\n1 1 1 1\n1.600\n",
"output": "6\n"
},
{
"input": "10\n0 0 0 10\n4.000\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_g | Problem Statement
You are given an integer sequence of length
N
:
A = (A_1, A_2, \ldots, A_N)
.
Print the maximum possible value of
A_l + A_{l+1} + \cdots + A_r
for a pair
(l, r)
such that
1 \leq l \leq r \leq N
. | [
{
"input": "10\n-6 5 -3 3 -1 4 -1 5 -9 2\n",
"output": "12\n"
},
{
"input": "3\n-1 -2 -3\n",
"output": "-1\n"
},
{
"input": "20\n-14 74 -48 38 -51 43 5 37 -39 -29 80 -44 -55 59 17 89 -37 -68 38 -16\n",
"output": "176\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_h | Problem Statement
You are given a positive integer
N
that has
D
digits when written in base
10
.
For
1\leq k\leq D
, let
A_k
be the
k
-th digit from the top when
N
is written in base
10
.
Find the value
\displaystyle\sum_{i=1}^{D-1}\sum_{j=i+1}^D \lvert A_i-A_j \rvert
. | [
{
"input": "3\n287\n",
"output": "12\n"
},
{
"input": "2\n11\n",
"output": "0\n"
},
{
"input": "20\n12345678901234567890\n",
"output": "660\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_i | Problem Statement
There are
N
people numbered
1
to
N
.
You are given
N
pieces of information, each in this form: person
A_i
is taller than person
B_i
. Determine whether they are consistent. | [
{
"input": "3 3\n1 2\n2 3\n3 1\n",
"output": "No\n"
},
{
"input": "4 9\n1 3\n1 3\n1 3\n1 3\n2 4\n1 4\n3 4\n2 3\n1 2\n",
"output": "Yes\n"
},
{
"input": "3 3\n1 2\n2 1\n1 3\n",
"output": "No\n"
},
{
"input": "100 0\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_j | Problem Statement
You are given points
S(x_{\mathrm{s}}, y_{\mathrm{s}})
and
T(x_{\mathrm{t}}, y_{\mathrm{t}})
in the
xy
-plane.
You are also given
N
four-tuples
(P_i, Q_i, R_i, W_i)(1 \leq i \leq N)
.
Consider the following procedure.
First, choose an arbitrary (directed) curve
C
from point
S(x_{\mathrm{s}}, y_{\mathr... | [
{
"input": "4 3\n-2 0 2 0\n2 1 2 7\n0 1 10 10\n1 0 -1 3\n-1 1 0 5\n",
"output": "8\n"
},
{
"input": "2 2\n0 0 0 0\n1 2 3 4\n2 4 6 8\n",
"output": "0\n"
},
{
"input": "20 17\n-6 -77 40 99\n-14 74 -48 27\n-51 43 5 89\n-39 -29 80 75\n-55 59 17 39\n-37 -68 38 62\n14 31 43 49\n49 -7 -65 13\n-... |
https://atcoder.jp/contests/past202212-open/tasks/past202212_k | Problem Statement
Takahashi wants an integer, so he goes to an integer shop.
The integer shop sells every integer between
1
and
10^9
, inclusive. The integer
n
is sold for
A \times n + B \times d(n)
yen (the currency in Japan), where
d(n)
denotes the sum of digits in the decimal notation of
n
.
Takahashi has
X
yen. F... | [
{
"input": "3 4 50\n",
"output": "12\n"
},
{
"input": "199 211 10000000000\n",
"output": "50251233\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_l | Problem Statement
You are given
N
segments
[L_1, R_1], [L_2, R_2], \ldots, [L_N, R_N]
on a number line.
A subset
S
of the set
\lbrace 1, 2, \ldots, N \rbrace
is said to be a
good set
if:
for all
i, j \in S
, at least one of the following two conditions is satisfied:
the segment
[L_i, R_i]
contains the segment
[L_j, R_j... | [
{
"input": "4\n1 3\n2 4\n3 4\n1 4\n",
"output": "3\n"
},
{
"input": "3\n0 1\n0 1\n0 1\n",
"output": "3\n"
},
{
"input": "9\n1 6\n1 3\n3 6\n4 6\n2 5\n1 2\n3 4\n3 5\n2 7\n",
"output": "4\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_m | Problem Statement
There is a tree with
N
vertices, whose vertices are numbered
1, \dots, N
and edges are numbered
1, \dots, N-1
. Edge
i \, (1 \leq i \leq N - 1)
connects vertices
U_i
and
V_i
.
Find the sum of the following value over all integer pairs
(l, r)
such that
1 \leq l \leq r \leq N - 1
:
the number of vertic... | [
{
"input": "5\n2 3\n1 2\n2 4\n3 5\n",
"output": "24\n"
},
{
"input": "2\n1 2\n",
"output": "2\n"
},
{
"input": "7\n1 2\n2 7\n4 6\n3 6\n4 5\n1 5\n",
"output": "49\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_n | Problem Statement
For an integer sequence
X = (X_1, X_2, \dots, X_k)
, let us define a function
f(X)
as follows:
Let
Y = (Y_1, Y_2, \dots, Y_k)
be the sequence obtained by sorting
X
in ascending order.
Then,
\displaystyle f(X) = \sum_{i=1}^{k-1}(Y_{i+1}-Y_i)^2
.
We have an integer sequence
A = (A_1, A_2, \dots, A_N)
. ... | [
{
"input": "3\n3 1 4\n4\n1 1\n1 2\n2 3\n1 3\n",
"output": "0\n4\n9\n5\n"
},
{
"input": "10\n19 70 14 11 85 75 72 35 14 50\n10\n1 1\n3 8\n5 7\n1 3\n5 8\n5 5\n2 10\n2 5\n1 5\n2 9\n",
"output": "0\n1928\n109\n2626\n1478\n0\n1188\n3370\n2860\n1788\n"
}
] |
https://atcoder.jp/contests/past202212-open/tasks/past202212_o | Problem Statement
You are given an integer sequence
A = (A_1, A_2, \ldots, A_N)
of length
N
.
Each element
A_1, A_2, \ldots, A_N
of
A
is a
D
-digit integer (without leading zeros) in the decimal notation, and none of its digits are
0
.
You are given
Q
queries. Each query is of one of type
1
, type
2
, and type
3
, wh... | [
{
"input": "5 3\n123 234 345 456 567\n5\n3 2 4\n1 3\n3 2 4\n2 3 5 2\n3 2 4\n",
"output": "123\n678\n680\n"
},
{
"input": "20 6\n318153 438943 474719 114997 373645 598458 427319 171794 653644 463294 123454 842368 264537 215892 467783 121159 836368 946718 889644 865849\n20\n2 6 9 3\n2 8 13 5\n2 1 6 3\... |
https://atcoder.jp/contests/abc279/tasks/abc279_a | Problem Statement
You are given a string
S
consisting of
v
and
w
.
Print the number of "bottoms" in the string
S
(see the figure at Sample Input/Output). | [
{
"input": "vvwvw\n",
"output": "7\n"
},
{
"input": "v\n",
"output": "1\n"
},
{
"input": "wwwvvvvvv\n",
"output": "12\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_b | Problem Statement
You are given strings
S
and
T
consisting of lowercase English letters. Determine whether
T
is a (contiguous) substring of
S
.
A string
Y
is said to be a (contiguous) substring of
X
if and only if
Y
can be obtained by performing the operation below on
X
zero or more times.
Do one of the following.
Dele... | [
{
"input": "voltage\ntag\n",
"output": "Yes\n"
},
{
"input": "atcoder\nace\n",
"output": "No\n"
},
{
"input": "gorilla\ngorillagorillagorilla\n",
"output": "No\n"
},
{
"input": "toyotasystems\ntoyotasystems\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_c | Problem Statement
You are given patterns
S
and
T
consisting of
#
and
.
, each with
H
rows and
W
columns.
The pattern
S
is given as
H
strings, and the
j
-th character of
S_i
represents the element at the
i
-th row and
j
-th column. The same goes for
T
.
Determine whether
S
can be made equal to
T
by rearranging the colum... | [
{
"input": "3 4\n##.#\n##..\n#...\n.###\n..##\n...#\n",
"output": "Yes\n"
},
{
"input": "3 3\n#.#\n.#.\n#.#\n##.\n##.\n.#.\n",
"output": "No\n"
},
{
"input": "2 1\n#\n.\n#\n.\n",
"output": "Yes\n"
},
{
"input": "8 7\n#..#..#\n.##.##.\n#..#..#\n.##.##.\n#..#..#\n.##.##.\n#..#.... |
https://atcoder.jp/contests/abc279/tasks/abc279_d | Problem Statement
A superman, Takahashi, is about to jump off the roof of a building to help a person in trouble on the ground.
Takahashi's planet has a constant value
g
that represents the strength of gravity, and the time it takes for him to reach the ground after starting to fall is
\frac{A}{\sqrt{g}}
.
It is now t... | [
{
"input": "10 1\n",
"output": "7.7735026919\n"
},
{
"input": "5 10\n",
"output": "5.0000000000\n"
},
{
"input": "1000000000000000000 100\n",
"output": "8772053214538.5976562500\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_e | Problem Statement
You are given a sequence of length
M
consisting of integers between
1
and
N-1
, inclusive:
A=(A_1,A_2,\dots,A_M)
.
Answer the following question for
i=1, 2, \dots, M
.
There is a sequence
B=(B_1,B_2,\dots,B_N)
. Initially, we have
B_j=j
for each
j
. Let us perform the following operation for
k=1, 2, ... | [
{
"input": "5 4\n1 2 3 2\n",
"output": "1\n3\n2\n4\n"
},
{
"input": "3 3\n2 2 2\n",
"output": "1\n1\n1\n"
},
{
"input": "10 10\n1 1 1 9 4 4 2 1 3 3\n",
"output": "2\n2\n2\n3\n3\n3\n1\n3\n4\n4\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_f | Problem Statement
There are
N
boxes numbered
1,2,\ldots,N
, and
10^{100}
balls numbered
1,2,\dots,10^{100}
.
Initially, box
i
contains just ball
i
.
Process a total of
Q
operations that will be performed.
There are three types of operations:
1
,
2
, and
3
.
Type
1
: Put all contents of box
Y
into box
X
. It is guarante... | [
{
"input": "5 10\n3 5\n1 1 4\n2 1\n2 4\n3 7\n1 3 1\n3 4\n1 1 4\n3 7\n3 6\n",
"output": "5\n4\n3\n1\n3\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_g | Problem Statement
There is a grid with
1 \times N
squares, numbered
1,2,\dots,N
from left to right.
Takahashi prepared paints of
C
colors and painted each square in one of the
C
colors.
Then, there were at most two colors in any consecutive
K
squares.
Formally, for every integer
i
such that
1 \le i \le N-K+1
, there we... | [
{
"input": "3 3 3\n",
"output": "21\n"
},
{
"input": "10 5 2\n",
"output": "1024\n"
},
{
"input": "998 244 353\n",
"output": "952364159\n"
}
] |
https://atcoder.jp/contests/abc279/tasks/abc279_h | Problem Statement
You are given positive integers
N
and
M
. Here, it is guaranteed that
N\leq M \leq 2N
.
Print the sum, modulo
200\ 003
(a prime), of the following value over all sequences of positive integers
S=(S_1,S_2,\dots,S_N)
such that
\displaystyle \sum_{i=1}^{N} S_i = M
(notice the unusual modulo):
\displaysty... | [
{
"input": "3 5\n",
"output": "14\n"
},
{
"input": "1126 2022\n",
"output": "40166\n"
},
{
"input": "1000000000000 1500000000000\n",
"output": "180030\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_a | Problem Statement
There is a row of
L
chairs. Now,
N
groups of people will come and take seats in order.
Each group consists of one or two people, and the
i
-th group to come consists of
a_i
people.
The total number of people equals
L
.
Each group will randomly choose unoccupied chairs where all group members can sit... | [
{
"input": "2 4\n2 2\n",
"output": "No\n"
},
{
"input": "3 4\n1 2 1\n",
"output": "Yes\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_b | Problem Statement
There is a narrow straight road of length
L
stretching east to west. Two travelers will visit this road.
Along the road, there are
N
rest areas. The distance from the west end of the road to the
i
-th rest area is
a_i
(no rest area is at either end of the road).
The road is so narrow that the two tr... | [
{
"input": "2 6\n2 5\n",
"output": "14\n"
},
{
"input": "2 3\n1 2\n",
"output": "6\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_c | Problem Statement
We have a sequence of
N
terms:
a_1,a_2,\ldots,a_N
.
You can perform the following operation on this sequence any number of times (possibly zero).
Choose a term of the sequence at that point, and let
s
be its value.
Then, for every
1\leq i\leq N
, replace
a_i
with
2s-a_i
.
However, this operation ma... | [
{
"input": "3\n1 3 6\n",
"output": "5\n"
},
{
"input": "5\n400 500 600 700 800\n",
"output": "400\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_d | Problem Statement
We have an undirected graph with
N
vertices numbered
0
through
N-1
and no edges at first.
You may add edges to this graph as you like.
When you are done with adding edges, the following operation will be performed once using a given integer
K
.
For each edge you have added, let
u
and
v
be its endpoi... | [
{
"input": "5 2\n",
"output": "2\n2 3\n2 4\n"
},
{
"input": "2 1\n",
"output": "-1\n"
},
{
"input": "7 1\n",
"output": "3\n0 1\n2 3\n4 5\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_e | Problem Statement
On a number line, there are
2^N-1
balls at the coordinates
x=1,2,3,...,2^N-1
, and the ball at
x=i
has a weight of
w_i
. Here,
w_1, w_2,...,w_{2^N-1}
is a permutation of the integers from
1
through
2^N-1
. You will choose a non-negative integer
Z
at most
2^N-1
and attach a weight of
Z
at each of the c... | [
{
"input": "2\n1 2 3\n",
"output": "1\n"
},
{
"input": "3\n7 1 2 3 4 5 6\n",
"output": "2\n"
}
] |
https://atcoder.jp/contests/arc152/tasks/arc152_f | Problem Statement
You are given a tree with
N
vertices numbered
1
to
N
.
The
i
-th edge connects two vertices
a_i
and
b_i
(1\leq i\leq N-1)
.
Initially, a piece is placed at vertex
1
. You will perform the following operation exactly
N
times.
Choose a vertex that is not occupied by the piece at that moment and is neve... | [
{
"input": "4\n1 2\n2 4\n3 4\n",
"output": "3\n"
},
{
"input": "6\n1 6\n2 6\n2 3\n3 4\n4 5\n",
"output": "-1\n"
},
{
"input": "14\n1 2\n1 3\n3 4\n3 5\n5 6\n6 7\n5 8\n8 9\n8 14\n14 10\n10 11\n14 12\n12 13\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/abc278/tasks/abc278_a | Problem Statement
You are given a sequence
A = (A_1, A_2, \dots, A_N)
of length
N
.
You perform the following operation exactly
K
times:
remove the initial element of
A
and append a
0
to the tail of
A
.
Print all the elements of
A
after the operations. | [
{
"input": "3 2\n2 7 8\n",
"output": "8 0 0\n"
},
{
"input": "3 4\n9 9 9\n",
"output": "0 0 0\n"
},
{
"input": "9 5\n1 2 3 4 5 6 7 8 9\n",
"output": "6 7 8 9 0 0 0 0 0\n"
}
] |
https://atcoder.jp/contests/abc278/tasks/abc278_b | Problem Statement
Takahashi bought a table clock.
The clock shows the time as shown in Figure 1 at
\mathrm{AB}
:
\mathrm{CD}
in the
24
-hour system.
For example, the clock in Figure 2 shows 7:58.
The format of the time is formally described as follows.
Suppose that the current time is
m
minutes past
h
in the
24
-hour s... | [
{
"input": "1 23\n",
"output": "1 23\n"
},
{
"input": "19 57\n",
"output": "20 0\n"
},
{
"input": "20 40\n",
"output": "21 0\n"
}
] |
https://atcoder.jp/contests/abc278/tasks/abc278_c | Problem Statement
Takahashi runs an SNS "Twidai," which has
N
users from user
1
through user
N
.
In Twidai, users can follow or unfollow other users.
Q
operations have been performed since Twidai was launched.
The
i
-th
(1\leq i\leq Q)
operation is represented by three integers
T_i
,
A_i
, and
B_i
, whose meanings ar... | [
{
"input": "3 9\n1 1 2\n3 1 2\n1 2 1\n3 1 2\n1 2 3\n1 3 2\n3 1 3\n2 1 2\n3 1 2\n",
"output": "No\nYes\nNo\nNo\n"
},
{
"input": "2 8\n1 1 2\n1 2 1\n3 1 2\n1 1 2\n1 1 2\n1 1 2\n2 1 2\n3 1 2\n",
"output": "Yes\nNo\n"
},
{
"input": "10 30\n3 1 6\n3 5 4\n1 6 1\n3 1 7\n3 8 4\n1 1 6\n2 4 3\n1 6... |
https://atcoder.jp/contests/abc278/tasks/abc278_d | Problem Statement
You are given a sequence
A = (A_1, A_2, \dots, A_N)
of length
N
.
Given
Q
queries, process all of them in order.
The
q
-th
(1\leq q\leq Q)
query is in one of the following three formats, which represents the following queries:
1\ x _ q
: assign
x_q
to every element of
A
.
2\ i _ q\ x _ q
: add
x_q
to... | [
{
"input": "5\n3 1 4 1 5\n6\n3 2\n2 3 4\n3 3\n1 1\n2 3 4\n3 3\n",
"output": "1\n8\n5\n"
},
{
"input": "1\n1000000000\n8\n2 1 1000000000\n2 1 1000000000\n2 1 1000000000\n2 1 1000000000\n2 1 1000000000\n2 1 1000000000\n2 1 1000000000\n3 1\n",
"output": "8000000000\n"
},
{
"input": "10\n1 8... |
https://atcoder.jp/contests/abc278/tasks/abc278_e | Problem Statement
You have a grid with
H
rows from top to bottom and
W
columns from left to right.
We denote by
(i, j)
the square at the
i
-th row from the top and
j
-th column from the left.
(i,j)\ (1\leq i\leq H,1\leq j\leq W)
has an integer
A _ {i,j}
between
1
and
N
written on it.
You are given integers
h
and
w
. ... | [
{
"input": "3 4 5 2 2\n2 2 1 1\n3 2 5 3\n3 4 4 3\n",
"output": "4 4 3\n5 3 4\n"
},
{
"input": "5 6 9 3 4\n7 1 5 3 9 5\n4 5 4 5 1 2\n6 1 6 2 9 7\n4 7 1 5 8 8\n3 4 3 3 5 3\n",
"output": "8 8 7\n8 9 7\n8 9 8\n"
},
{
"input": "9 12 30 4 7\n2 2 2 2 2 2 2 2 2 2 2 2\n2 2 20 20 2 2 5 9 10 9 9 23... |
https://atcoder.jp/contests/abc278/tasks/abc278_f | Problem Statement
You are given
N
strings
S _ 1,S _ 2,\ldots,S _ N
.
S _ i\ (1\leq i\leq N)
is a non-empty string of length at most
10
consisting of lowercase English letters, and the strings are pairwise distinct.
Taro the First and Jiro the Second play a word-chain game.
In this game, the two players take alternatin... | [
{
"input": "6\nenum\nfloat\nif\nmodint\ntakahashi\ntemplate\n",
"output": "First\n"
},
{
"input": "10\ncatch\nchokudai\nclass\ncontinue\ncopy\nexec\nhavoc\nintrinsic\nstatic\nyucatec\n",
"output": "Second\n"
},
{
"input": "16\nmnofcmzsdx\nlgeowlxuqm\nouimgdjxlo\njhwttcycwl\njbcuioqbsj\nm... |
https://atcoder.jp/contests/abc278/tasks/abc278_g | Problem Statement
This is an
interactive task
(where your program interacts with the judge's program via Standard Input and Output).
You are given integers
N
,
L
, and
R
.
You play the following game against the judge:
There are
N
cards numbered
1
through
N
on the table.
The players alternately perform the following op... | [] |
https://atcoder.jp/contests/abc278/tasks/abc278_h | Problem Statement
A sequence
S
of non-negative integers is said to be a
good sequence
if:
there exists a non-empty (not necessarily contiguous) subsequence
T
of
S
such that the bitwise XOR of all elements in
T
is
1
.
There are an empty sequence
A
, and
2^B
cards with each of the integers between
0
and
2^B-1
written on ... | [
{
"input": "2 2\n",
"output": "5\n"
},
{
"input": "2022 1119\n",
"output": "293184537\n"
},
{
"input": "200000 10000000\n",
"output": "383948354\n"
}
] |
https://atcoder.jp/contests/joi2023yo1c/tasks/joi2023_yo1c_a | ๅ้กๆ
2
ใคใฎๆฐๅญ
A, B
ใไธใใใใ๏ผ
ๅใฎไฝใ
A
ใงใใ๏ผไธใฎไฝใ
B
ใงใใ
2
ๆกใฎๆญฃใฎๆดๆฐใๅบๅใใ๏ผ | [
{
"input": "2\n2\n",
"output": "22\n"
},
{
"input": "1\n0\n",
"output": "10\n"
},
{
"input": "1\n9\n",
"output": "19\n"
}
] |
https://atcoder.jp/contests/joi2023yo1c/tasks/joi2023_yo1c_b | ๅ้กๆ
2
ใคใฎๆดๆฐ
A, B
ใไธใใใใ๏ผ
2022
ๅนด
11
ๆ
A
ๆฅใฎ
B
้ฑ้ๅพใฎๆฅใ
2022
ๅนด
11
ๆใชใใฐ
1
ใ๏ผ
2022
ๅนด
11
ๆใงใชใใชใใฐ
0
ใๅบๅใใ๏ผ
ใใ ใ๏ผ
2022
ๅนด
11
ๆใฏ
2022
ๅนด
11
ๆ
1
ๆฅใใ
2022
ๅนด
11
ๆ
30
ๆฅใพใงใฎ
30
ๆฅ้ใงใใ๏ผ
x
้ฑ้ๅพใฎๆฅใจใฏ
(7\times x)
ๆฅๅพใฎๆฅใฎใใจใๆใ๏ผ | [
{
"input": "19\n1\n",
"output": "1\n"
},
{
"input": "3\n4\n",
"output": "0\n"
},
{
"input": "8\n3\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/joi2023yo1c/tasks/joi2023_yo1c_c | ๅ้กๆ
ใใ ๅฅๅฆใช็บๆใง็ฅใใใ JOI ็คพใฏ๏ผๆ่ฟ JOI Editor ใจใใใใญในใใจใใฃใฟใ้็บใใ๏ผ
ใใฎใใญในใใจใใฃใฟใฏ๏ผ
j
๏ผ
o
๏ผ
i
ใฎ
3
ใคใฎใญใผใงๆไฝใใใใจใใงใใ๏ผ
j
๏ผ
o
๏ผ
i
ใฎใใใใใฎใญใผใๆผใใจ๏ผใใฎใญใผใซๆธใใใฆใใ่ฑๅฐๆๅญใๅ
ฅๅใใใใ๏ผๅใ่ฑๅฐๆๅญใ
2
ใค้ฃๆฅใใใจ๏ผใใ ใกใซใใฎ
2
ๆๅญใๅฏพๅฟใใ่ฑๅคงๆๅญใซ็ฝฎๆใใใ๏ผใใชใใก๏ผ
jj
ใฏ
JJ
ใซ๏ผ
oo
ใฏ
OO
ใซ๏ผ
ii
ใฏ
II
ใซ็ฝฎๆใใใ๏ผ
ไพใใฐ๏ผ
j
๏ผ
o
๏ผ
o
๏ผ
o
๏ผ
i
ใฎใญใผใใใฎ้ ็ชใงๆผใใจ๏ผ
j
๏ผ
o
๏ผ
o
ใพใงใญใผใๆผใใ็ดๅพ๏ผ
2
ๆๅญ็ฎใจ
3
ๆๅญ็ฎใฎไธฆใณใ
oo
ใจใชใ๏ผๅใ่ฑ... | [
{
"input": "6\njjoiii\n",
"output": "JJoIIi\n"
},
{
"input": "6\njoijoi\n",
"output": "joijoi\n"
},
{
"input": "7\nooooooo\n",
"output": "OOOOOOo\n"
}
] |
https://atcoder.jp/contests/joi2023yo1c/tasks/joi2023_yo1c_d | ๅ้กๆ
JOI ้ซๆ กใซใฏ
N
ไบบใฎ็ๅพใใใ๏ผ
1
ใใ
N
ใพใงใฎ็ชๅทใไปใใใใฆใใ๏ผ
ๅ
ๆ JOI ้ซๆ กใงใฏใใฉใฝใณๅคงไผใ้ๅฌใใ๏ผ็ๅพๅ
จๅกใใใใซๅๅ ใใ๏ผ็ๅพ
i
(
1 \leqq i \leqq N
) ใฎ่จ้ฒใฏ
A_i
ๅใงใใฃใ๏ผ
ใใฉใฝใณๅคงไผใซใใใๅ็ๅพใฎ้ ไฝใๆฑใใ๏ผใใ ใ๏ผ็ๅพ
i
(
1 \leqq i \leqq N
) ใฎ้ ไฝใฏ๏ผ(่จ้ฒใ
A_i
ๅๆชๆบใฎ็ๅพใฎไบบๆฐ)
{} + 1
ใง่จ็ฎใใใ๏ผ | [
{
"input": "3\n44 42 69\n",
"output": "2\n1\n3\n"
},
{
"input": "4\n40 60 40 60\n",
"output": "1\n3\n1\n3\n"
},
{
"input": "10\n766 152 595 926 663 509 368 595 175 622\n",
"output": "9\n1\n5\n10\n8\n4\n3\n5\n2\n7\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_a | Problem Statement
You are given a sequence
P
that is a permutation of
(1,2,โฆ,N)
, and an integer
X
.
The
i
-th term of
P
has a value of
P_i
.
Print
k
such that
P_k = X
. | [
{
"input": "4 3\n2 3 1 4\n",
"output": "2\n"
},
{
"input": "5 2\n3 5 1 4 2\n",
"output": "5\n"
},
{
"input": "6 6\n1 2 3 4 5 6\n",
"output": "6\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_b | Problem Statement
You are given
N
strings, each of length
2
, consisting of uppercase English letters and digits. The
i
-th string is
S_i
.
Determine whether the following three conditions are all satisfied.
ใปFor every string, the first character is one of
H
,
D
,
C
, and
S
.
ใปFor every string, the second character is ... | [
{
"input": "4\nH3\nDA\nD3\nSK\n",
"output": "Yes\n"
},
{
"input": "5\nH3\nDA\nCK\nH3\nS7\n",
"output": "No\n"
},
{
"input": "4\n3H\nAD\n3D\nKS\n",
"output": "No\n"
},
{
"input": "5\n00\nAA\nXX\nYY\nZZ\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_c | Problem Statement
There is a
10^9
-story building with
N
ladders.
Takahashi, who is on the
1
-st (lowest) floor, wants to reach the highest floor possible by using ladders (possibly none).
The ladders are numbered from
1
to
N
, and ladder
i
connects the
A_i
-th and
B_i
-th floors. One can use ladder
i
in either directi... | [
{
"input": "4\n1 4\n4 3\n4 10\n8 3\n",
"output": "10\n"
},
{
"input": "6\n1 3\n1 5\n1 12\n3 5\n3 12\n5 12\n",
"output": "12\n"
},
{
"input": "3\n500000000 600000000\n600000000 700000000\n700000000 800000000\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_d | Problem Statement
Takahashi has
N
cards in his hand.
For
i = 1, 2, \ldots, N
, the
i
-th card has an non-negative integer
A_i
written on it.
First, Takahashi will freely choose a card from his hand and put it on a table.
Then, he will repeat the following operation as many times as he wants (possibly zero).
Let
X
be ... | [
{
"input": "9 7\n3 0 2 5 5 3 0 6 3\n",
"output": "11\n"
},
{
"input": "1 10\n4\n",
"output": "0\n"
},
{
"input": "20 20\n18 16 15 9 8 8 17 1 3 17 11 9 12 11 7 3 2 14 3 12\n",
"output": "99\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_e | Problem Statement
You are given an undirected graph consisting of
N
vertices and
M
edges.
For
i = 1, 2, \ldots, M
, the
i
-th edge is an undirected edge connecting vertex
u_i
and
v_i
that is initially passable if
a_i = 1
and initially impassable if
a_i = 0
.
Additionally, there are switches on
K
of the vertices: verte... | [
{
"input": "5 5 2\n1 3 0\n2 3 1\n5 4 1\n2 1 1\n1 4 0\n3 4\n",
"output": "5\n"
},
{
"input": "4 4 2\n4 3 0\n1 2 1\n1 2 0\n2 1 1\n2 4\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_f | Problem Statement
You are given a matrix
A
whose elements are non-negative integers.
For a pair of integers
(i, j)
such that
1 \leq i \leq H
and
1 \leq j \leq W
,
let
A_{i, j}
denote the element at the
i
-th row and
j
-th column of
A
.
Let us perform the following procedure on
A
.
First, replace each element of
A
that ... | [
{
"input": "3 3\n9 6 0\n0 4 0\n3 0 3\n",
"output": "Yes\n"
},
{
"input": "2 2\n2 1\n1 2\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_g | Problem Statement
You are given a connected simple undirected graph consisting of
N
vertices and
M
edges.
For
i = 1, 2, \ldots, M
, the
i
-th edge connects vertex
u_i
and vertex
v_i
.
Takahashi starts at
Level
0
on vertex
1
, and will perform the following action exactly
K
times.
First, choose one of the vertices adjac... | [
{
"input": "5 4 8\n4 5\n2 3\n2 4\n1 2\n0 0 1 1 0\n",
"output": "89349064\n"
},
{
"input": "8 12 20\n7 6\n2 6\n6 4\n2 1\n8 5\n7 2\n7 5\n3 7\n3 5\n1 8\n6 3\n1 4\n0 0 1 1 0 0 0 0\n",
"output": "139119094\n"
}
] |
https://atcoder.jp/contests/abc277/tasks/abc277_h | Problem Statement
Determine whether there is a sequence of
N
integers
X = (X_1, X_2, \ldots ,X_N)
that satisfies all of the following conditions, and construct one such sequence if it exists.
0 \leq X_i \leq M
for every
1 \leq i \leq N
.
L_i \leq X_{A_i} + X_{B_i} \leq R_i
for every
1 \leq i \leq Q
. | [
{
"input": "4 5 3\n1 3 5 7\n1 4 1 2\n2 2 3 8\n",
"output": "2 4 3 0\n"
},
{
"input": "3 7 3\n1 2 3 4\n3 1 9 12\n2 3 2 4\n",
"output": "-1\n"
}
] |
https://atcoder.jp/contests/ahc016/tasks/ahc016_a | Problem Statement
Given an integer
M
and an error rate
\epsilon
, determine an integer
N
satisfying
4\leq N\leq 100
and output
N
-vertex undirected graphs
G_0,G_1,\cdots,G_{M-1}
.
The graphs may be disconnected.
Then process the following query
100
times.
In the
k
-th query, you are given an
N
-vertex undirected grap... | [] |
https://atcoder.jp/contests/abc276/tasks/abc276_a | Problem Statement
You are given a string
S
consisting of lowercase English letters.
If
a
appears in
S
, print the last index at which it appears; otherwise, print
-1
. (The index starts at
1
.) | [
{
"input": "abcdaxayz\n",
"output": "7\n"
},
{
"input": "bcbbbz\n",
"output": "-1\n"
},
{
"input": "aaaaa\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_b | Problem Statement
There are
N
cities numbered
1, \dots, N
, and
M
roads connecting cities.
The
i
-th road
(1 \leq i \leq M)
connects city
A_i
and city
B_i
.
Print
N
lines as follows.
Let
d_i
be the number of cities directly connected to city
i \, (1 \leq i \leq N)
, and those cities be city
a_{i, 1}
,
\dots
, city
a_{i... | [
{
"input": "6 6\n3 6\n1 3\n5 6\n2 5\n1 2\n1 6\n",
"output": "3 2 3 6\n2 1 5\n2 1 6\n0\n2 2 6\n3 1 3 5\n"
},
{
"input": "5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n",
"output": "4 2 3 4 5\n4 1 3 4 5\n4 1 2 4 5\n4 1 2 3 5\n4 1 2 3 4\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_c | Problem Statement
You are given a permutation
P = (P_1, \dots, P_N)
of
(1, \dots, N)
, where
(P_1, \dots, P_N) \neq (1, \dots, N)
.
Assume that
P
is the
K
-th lexicographically smallest among all permutations of
(1 \dots, N)
. Find the
(K-1)
-th lexicographically smallest permutation.
What are permutations?
A
permutati... | [
{
"input": "3\n3 1 2\n",
"output": "2 3 1\n"
},
{
"input": "10\n9 8 6 5 10 3 1 2 4 7\n",
"output": "9 8 6 5 10 2 7 4 3 1\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_d | Problem Statement
You are given a sequence of positive integers:
A=(a_1,a_2,\ldots,a_N)
.
You can choose and perform one of the following operations any number of times, possibly zero.
Choose an integer
i
such that
1 \leq i \leq N
and
a_i
is a multiple of
2
, and replace
a_i
with
\frac{a_i}{2}
.
Choose an integer
i
suc... | [
{
"input": "3\n1 4 3\n",
"output": "3\n"
},
{
"input": "3\n2 7 6\n",
"output": "-1\n"
},
{
"input": "6\n1 1 1 1 1 1\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_e | Problem Statement
We have a grid with
H
rows from top to bottom and
W
columns from left to right. Let
(i, j)
denote the
i
-th row from the top
(1 \leq i \leq H)
and
j
-th column from the left
(1 \leq j \leq W)
.
Each square is one of the following: the initial point, a road, and an obstacle.
A square
(i, j)
is represen... | [
{
"input": "4 4\n....\n#.#.\n.S..\n.##.\n",
"output": "Yes\n"
},
{
"input": "2 2\nS.\n.#\n",
"output": "No\n"
},
{
"input": "5 7\n.#...#.\n..#.#..\n...S...\n..#.#..\n.#...#.\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_f | Problem Statement
There are
N
cards called card
1
, card
2
,
\ldots
, card
N
. On card
i
(1\leq i\leq N)
, an integer
A_i
is written.
For
K=1, 2, \ldots, N
, solve the following problem.
We have a bag that contains
K
cards: card
1
, card
2
,
\ldots
, card
K
.
Let us perform the following operation twice, and let
x
and
... | [
{
"input": "3\n5 7 5\n",
"output": "5\n499122183\n443664163\n"
},
{
"input": "7\n22 75 26 45 72 81 47\n",
"output": "22\n249561150\n110916092\n873463862\n279508479\n360477194\n529680742\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_g | Problem Statement
Find the number of sequences of integers with
N
terms,
A=(a_1,a_2,\ldots,a_N)
, that satisfy the following conditions, modulo
998244353
.
0 \leq a_1 \leq a_2 \leq \ldots \leq a_N \leq M
.
For each
i=1,2,\ldots,N-1
, the remainder when
a_i
is divided by
3
is different from the remainder when
a_{i+1}
is... | [
{
"input": "3 4\n",
"output": "8\n"
},
{
"input": "276 10000000\n",
"output": "909213205\n"
}
] |
https://atcoder.jp/contests/abc276/tasks/abc276_h | Problem Statement
Determine whether there is an
N
-by-
N
matrix
X
that satisfies the following conditions, and present one such matrix if it exists. (Let
x_{i,j}
denote the element of
X
at the
i
-th row from the top and
j
-th column from the left.)
x_{i,j} \in \{ 0,1,2 \}
for every
i
and
j
(1 \leq i,j \leq N)
.
The fol... | [
{
"input": "2 3\n1 1 1 2 0\n1 2 2 2 1\n2 2 1 2 2\n",
"output": "Yes\n0 2\n1 2\n"
},
{
"input": "4 4\n1 4 1 4 0\n1 4 1 4 1\n1 4 1 4 2\n1 4 1 4 0\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_a | ๅ้กๆ
TTPC (Tottemo Tanoshii Programming Contest) ใฏใ
2015
ๅนดใซ
1
ๅ็ฎใ้ๅฌใใใใใฎๅพ
A
ๅนดใใจ (
A
ใฏๆญฃใฎๆดๆฐ) ใซ้ๅฌใใใใณใณใในใใงใใ
ใใๆญฃ็ขบใซใฏใTTPC ใฏ
2015 + A \times n
(
n
ใฏ้่ฒ ๆดๆฐ) ใจ่กจใใใจใใงใใๅนดใซ้ๅฌใใใใใไปฅๅคใฎๅนดใซใฏ้ๅฌใใใพใใใ
ใพใใTTPC ใฏใ
2015
ๅนดใฎไปใซใ
X
ๅนดใจ
Y
ๅนดใซ้ๅฌใใใใใจใๅใใฃใฆใใพใใ
ใใฎใจใใ
A
ใจใใฆใใๅพใๆดๆฐใ
ๆ้ ใซ
ๅ
จใฆๅบๅใใฆใใ ใใใ | [
{
"input": "2019 2023\n",
"output": "1\n2\n4\n"
},
{
"input": "999999999995 1000000000000\n",
"output": "1\n5\n"
},
{
"input": "2019 2022\n",
"output": "1\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_b | ๅ้กๆ
ใใชใใฏ
X
ๅใๅ
ฅใฃใ้ญๆณใฎ่ฒกๅธใๆใฃใฆใใพใใ
ใใฎ่ฒกๅธใซ้ญๆณใไฝฟใใจใใใชใใฏ่ฒกๅธใซๅ
ฅใฃใฆใใ้้กใ
10
้ฒใฎๆๅญๅใจ่ฆใฆไปปๆใซไธฆใณๆฟใใใใจใใงใใพใใ
ไพใใฐใ
120
ๅใๅ
ฅใฃใ้ญๆณใฎ่ฒกๅธใซ้ญๆณใไฝฟใใจใๅ
ฅใฃใฆใใ้้กใ
12
ๅใ
21
ๅใ
102
ๅใ
120
ๅใ
201
ๅใ
210
ๅใฎใใใใใซๅคใใใใจใใงใใพใ(ๅ
้ ญใฎ
0
ใฏ็ก่ฆใใใพใ)ใ
ใใชใใฏใใใใ้ญๆณใฎ่ฒกๅธใๆใฃใฆ
N
ๅใฎใๅบใ
้ ็ชใซ
่จชใใพใใ
i
็ช็ฎใฎใๅบ (
1 โค i โค N
) ใงใฏ
A_i
ๅใฎๅๅใ
1
ใคๅฃฒใฃใฆใใใใใ้ญๆณใฎ่ฒกๅธใซ
A_i
ๅไปฅไธๅ
ฅใฃใฆใใใฐใ้ญๆณใฎ่ฒกๅธใใ
A_i
ๅใๆฏๆใฃใฆใใฎๅๅใ... | [
{
"input": "2 120\n142 90\n",
"output": "2\n"
},
{
"input": "1 119\n911\n",
"output": "1\n"
},
{
"input": "5 1000\n900 90 900 9 900\n",
"output": "3\n"
},
{
"input": "7 1171\n6328 2419 8302 7503 1744 8495 1522\n",
"output": "5\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_c | ๅ้กๆ
้ทใ
N
ใฎๆดๆฐๅ
A = (A_1, \dots, A_N), B = (B_1, \dots, B_N), C = (C_1, \dots, C_N), D = (D_1, \dots, D_N), E = (E_1, \dots, E_N)
ใไธใใใใพใใ
ไปฅไธใฎๅคใ
998244353
ใงๅฒใฃใใใพใใๆฑใใฆใใ ใใใ
\displaystyle\sum_{i=1}^{N}\sum_{j=1}^{N}\sum_{k=1}^{N}\sum_{l=1}^{N}\sum_{m=1}^{N}\mathrm{med}(A_i,B_j,C_k,D_l,E_m)
ใใ ใใ
\mathrm{med}(a,b,c,d,e)
ใฏ
a,... | [
{
"input": "1\n1\n2\n3\n4\n5\n",
"output": "3\n"
},
{
"input": "3\n1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 1 2\n",
"output": "486\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_d | ๅ้กๆ
้ ็นใซ
1, 2, \dots, N
ใฎ็ชๅทใไปใใใ้ ็น
1
ใๆ นใจใใ
N
้ ็นใฎๆ นไปใๆจใใใใพใใ
i
็ช็ฎใฎ่พบ (
1 โค i โค N - 1
) ใฏ้ ็น
U_i
ใจ้ ็น
V_i
ใ็ตใใงใใพใใ
ๆจใฎๅ้ ็นใฏ็ฝใ้ปใงๅกใใใฆใใใ้ ็น
i
(
1 โค i โค N
) ใฏ
A_i = 0
ใฎใจใ็ฝใงใ
A_i = 1
ใฎใจใ้ปใงๅกใใใฆใใพใใ
ๆจใ้ปใใใใ้ปๆจใใใฏใไปฅไธใฎๆไฝใ
0
ๅไปฅไธใฎไปปๆใฎๅๆฐ่กใฃใฆใ
้ป
ใงๅกใใใฆใใ้ ็นใฎๆฐใๆๅคงๅใใพใใ
่
ใงใใ้ ็น
x
ใ
1
ใค้ธใณใๆ นใใ
x
ใพใงใฎใในใซๅซใพใใ้ ็น (ไธก็ซฏใๅซใ) ใฎ่ฒใๅ่ปขใใใ (็ฝใงๅกใใใฆใใๅ ดๅใฏ้ปใซใ้ปใงๅกใใใฆใใๅ ดๅ... | [
{
"input": "5\n1 0 0 1 0\n1 2\n1 3\n3 4\n3 5\n",
"output": "5\n"
},
{
"input": "6\n1 1 0 0 1 0\n3 1\n2 5\n1 2\n4 1\n2 6\n",
"output": "5\n"
},
{
"input": "9\n1 0 1 0 1 0 1 0 1\n2 9\n1 2\n6 9\n3 8\n4 5\n5 9\n2 8\n7 8\n",
"output": "6\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_e | ๅ้กๆ
ๅคงๅญฆ A ใจๅคงๅญฆ B ใฏ็ตฑๅใใใใจใซใชใใพใใใๅคงๅญฆ A ใฎๅคงๅญฆๅใฏ
A
ใๅคงๅญฆ B ใฎๅคงๅญฆๅใฏ
B
ใงใใ็ตฑๅๅพใฎๆฐใใๅคงๅญฆๅ
C
ใ่ใใพใใใใๅ
ทไฝ็ใซใฏใไปฅไธใฎใใใซใใฆ
C
ใๅฎใใพใใ
A
ใฎ็ฉบใงใชใ้จๅๅใ
1
ใคใจใฃใฆ
a
ใจใใใ
B
ใฎ็ฉบใงใชใ้จๅๅใ
1
ใคใจใฃใฆ
b
ใจใใใ
C
ใ
a
ใจ
b
ใใใฎ้ ใง้ฃ็ตใใๆๅญๅใจใใใ
Q
ๅใฎๆๅญๅ
S_1, S_2, \dots, S_Q
ใไธใใใใพใใใใใใใฎๆๅญๅใ
C
ใจใใฆใใๅพใใใฉใใๅคๅฎใใใใๅพใๅ ดๅใฏใ
|\text{len}(a) - \text{len}(b)|
ใจใใฆใใๅพใๆๅฐๅคใๆฑใใฆใใ ใใใ(
\text{len}(... | [
{
"input": "Tokyo Institute of Technology\nTokyo Medical and Dental University\n10\nThe University\nTokyo University\nkyoto University\nTokyo Tech\nTMDU\nKyoto University\nThe University of Tokyo\nTokyo Technology and Medical and Dental University\n Tehnoooorsty\nTokyo\n",
"output": "10\n4\n4\n-1\n2\n-1\n... |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_f | ๅ้กๆ
ๆดๆฐๅ
L = (L_1, L_2, \dots, L_N)
ใจ
R = (R_1, R_2, \dots, R_N)
ใไธใใใใพใใ
ไปฅไธใฎๆกไปถใๆบใใ
ๅฎๆฐ
ๅ
A = (A_1, A_2, \dots, A_N)
ใๅญๅจใใใๅคๅฎใใฆใใ ใใใ
1 \leq i \leq N
ใๆบใใใในใฆใฎๆดๆฐ
i
ใซๅฏพใใฆ
L_i \leq A_i \leq R_i
ใๆใ็ซใคใ
2 \leq i \leq N-1
ใๆบใใใในใฆใฎๆดๆฐ
i
ใซๅฏพใใฆ
A_{i-1} + A_{i+1} \geq 2 A_i
ใๆใ็ซใคใ | [
{
"input": "4\n2 1 2 5\n4 6 5 8\n",
"output": "Yes\n"
},
{
"input": "3\n1 4 2\n3 7 4\n",
"output": "No\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_g | ๅ้กๆ
ๆดๆฐๅ
L = (L_1, L_2, \dots, L_N)
ใจ
R = (R_1, R_2, \dots, R_N)
ใไธใใใใพใใ
ไปฅไธใฎๆกไปถใๆบใใๆดๆฐๅ
A = (A_1, A_2, \dots, A_N)
ใฎๅๆฐใ
998244353
ใงๅฒใฃใใใพใใๆฑใใฆใใ ใใใ
1 \leq i \leq N
ใๆบใใใในใฆใฎๆดๆฐ
i
ใซๅฏพใใฆ
L_i \leq A_i \leq R_i
ใๆใ็ซใคใ
ใใๆดๆฐ
d
ใๅญๅจใใฆใ
1 \leq i \leq N-1
ใๆบใใใในใฆใฎๆดๆฐ
i
ใซๅฏพใใฆ
A_{i+1} - A_i = d
ใๆใ็ซใคใ | [
{
"input": "3\n5 5 2\n7 6 7\n",
"output": "6\n"
},
{
"input": "4\n2 3 1 6\n5 6 4 8\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_h | ๅ้กๆ
N
้ ็น
M
่พบใฎๆๅใฐใฉใใไธใใใใพใใ้ ็นใซใฏ
1
ใใ
N
ใฎ็ชๅทใใ่พบใซใฏ
1
ใใ
M
ใฎ็ชๅทใใคใใฆใใพใใ่พบ
i
(
1 โค i โค M
) ใฏ้ ็น
A_i
ใใ้ ็น
B_i
ใซๅใใ่พบใงใใ
ใใชใใฏใใใฎใฐใฉใใฎๅ้ ็นใ่ฒ
1, โฆ, N
ใฎใใใใใงๅกใใพใใใใ ใใ้ ็น
i
(
1 โค i โค N
) ใซๅกใ่ฒใ
c_i
ใจใใใจใใไปฅไธใฎๆกไปถใๆบใใๅฟ
่ฆใใใใพใใ
ไปปๆใฎ็ต
(i, j)
(
1 โค i < j โค N
) ใซใคใใฆใ
c_i = c_j
ใชใใฐใ้ ็น
i
ใใ้ ็น
j
ใธใฎใในใใ้ ็น
j
ใใ้ ็น
i
ใธใฎใในใฎใใใใ (ไธกๆนใงใใใ) ใๅญๅจใใใ
\max\{c_1, โฆ... | [
{
"input": "5 5\n1 4\n2 3\n1 3\n2 5\n5 1\n",
"output": "1 1 1 2 1\n"
},
{
"input": "5 7\n1 2\n2 1\n4 3\n5 1\n5 4\n4 1\n4 5\n",
"output": "2 2 1 1 1\n"
},
{
"input": "8 6\n6 1\n3 4\n3 6\n2 3\n4 1\n6 4\n",
"output": "4 4 4 4 3 4 2 1\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_i | ๅ้กๆ
ๆดๆฐ
N,M,K
ใจ
N
้ ็น
M
่พบใฎ็กๅใฐใฉใใไธใใใใพใใใฐใฉใใฎ้ ็นใซใฏ
1
ใใ
N
ใฎ็ชๅทใใ่พบใซใฏ
1
ใใ
M
ใฎ็ชๅทใไปใใใใฆใใพใใ่พบ
i
(
1 โค i โค M
) ใฏ้ ็น
A_i
ใจ้ ็น
B_i
ใฎ้ใใคใชใใงใใฆใ่พบไธใซใฏ้่ฒ ๆดๆฐ
C_i
ใ็ฝฎใใใฆใใพใใ
Q
ๅใฎใฏใจใชใไธใใใใพใใ
i
็ช็ฎ (
1 โค i โค Q
) ใฎใฏใจใชใงใฏใๆดๆฐ
D_{i}
ใไธใใใใใฎใงใๆฌกใฎๆกไปถใๅ
จใฆๆบใใๆดๆฐใฎ็ต
(u,v)
ใฎๅๆฐใๆฑใใฆใใ ใใใ
1\le u\lt v\le N
(C_{j} \oplus D_{i})\lt K
ใๆบใใใใใช่พบ
j
ใฎใฟใ้ใฃใฆใ้ ็น
u
ใใ้ ็น
v
ใพใง็งปๅ... | [
{
"input": "4 5 5\n1 2 17\n1 3 4\n2 3 20\n2 4 3\n3 4 5\n4\n0\n7\n16\n167\n",
"output": "2\n6\n3\n0\n"
},
{
"input": "9 13 488888932\n2 7 771479959\n3 8 783850182\n5 7 430673756\n6 8 350738034\n4 9 400768807\n2 3 83653266\n1 2 829786563\n5 8 357613791\n7 9 579696618\n3 7 423191200\n3 5 867380255\n1 9... |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_j | ๅ้กๆ
N
้ ็น
M
่พบใฎๆๅใฐใฉใใไธใใใใพใใ้ ็นใซใฏ
1
ใใ
N
ใฎ็ชๅทใใ่พบใซใฏ
1
ใใ
M
ใฎ็ชๅทใไปใใใใฆใใฆใ่พบ
i
(
1 โค i โค M
) ใฏ้ ็น
A_i
ใใ้ ็น
B_i
ใธใฎ่พบใงใใใใฎใฐใฉใใซ่ชๅทฑใซใผใใฏๅญๅจใใใใใใใพใใใใๅค้่พบใฏใใใพใใใใฉใฎ้ ็นใใใ่พบใ
1
ๆฌไปฅไธๅบใฆใใใใจใไฟ่จผใใใพใใ
้ ็นใฎใใก
K
ๅใซใฏๅฎ็ณใ็ฝฎใใใฆใใพใใ
i
็ช็ฎ (
1 โค i โค K
) ใฎๅฎ็ณใฏ้ ็น
V_i
ใซใใใไพกๅคใฏ
W_i
ใงใใ
ใใฎใฐใฉใใไฝฟใฃใฆ First ๅใจ Second ๅใใฒใผใ ใใใพใใใฒใผใ ้ๅงๆใFirst ๅใฏ้ ็น
F
ใซใSecond ๅใฏ้ ็น
S
ใซใใพใใFi... | [
{
"input": "5 16 1 1\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 2\n3 4\n3 5\n4 2\n4 3\n4 5\n5 2\n5 3\n5 4\n4\n2 4\n3 84\n4 38\n5 96\n",
"output": "46\n"
},
{
"input": "8 16 8 4\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 1\n1 5\n2 6\n3 7\n4 8\n5 1\n6 2\n7 3\n8 4\n6\n1 29\n2 34\n3 41\n5 7\n6 26\n7 94\n",
"o... |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_k | ๅ้กๆ
Alice ใจ Bob ใจ Chris ใฏใใใใ
N
ๅใใใใใใใใพใใ ใใ ใใๅใ
ใๅบใๆใซใฏๆฌกใฎใใใชๅถ้ใใใใพใใ
Alice ใฏ ใฐใผ ใใกใใใฉ
A_R
ๅใ ใใผ ใใกใใใฉ
A_P
ๅใ ใใงใญ ใใกใใใฉ
A_S
ๅ ๅบใใ
Bob ใฏ ใฐใผ ใใกใใใฉ
B_R
ๅใ ใใผ ใใกใใใฉ
B_P
ๅใ ใใงใญ ใใกใใใฉ
B_S
ๅ ๅบใใ
Chris ใฏ ใฐใผ ใใกใใใฉ
C_R
ๅใ ใใผ ใใกใใใฉ
C_P
ๅใ ใใงใญ ใใกใใใฉ
C_S
ๅ ๅบใใ
Alice ใจ Bob ใจ Chris ใฏใจใฆใไปฒ่ฏใใชใฎใงใ
N
ๅใในใฆใง
ใใใ
ใซใชใใใใซใใใใงใใ
N
ๅใฎใใใใใใซใใใ
3... | [
{
"input": "2\n2 0 0 1 1 0 1 0 1\n",
"output": "2\n"
},
{
"input": "3\n0 1 2 3 0 0 1 1 1\n",
"output": "0\n"
},
{
"input": "333333\n111111 111111 111111 111111 111111 111111 111111 111111 111111\n",
"output": "383902959\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_l | ๅ้กๆ
ๆญฃๆดๆฐ
N,M
ใไธใใใใพใใ
(0,1,...,NM-1)
ใฎ้ ๅ
P=(P_{0},P_{1},...,P_{NM-1})
ใฎใใกใไปฅไธใฎๆกไปถใๆบใใใใฎใฎๅๆฐใ
998244353
ใงๅฒใฃใใใพใใๆฑใใฆใใ ใใใ
0\le i\lt NM
ใๆบใใๅ
จใฆใฎๆดๆฐ
i
ใซใคใใฆใ
\left\lfloor \frac{i}{M} \right\rfloor \neq \left\lfloor \frac{P_{i}}{M}\right\rfloor
ใๆใ็ซใคใ
ใใ ใใ
\left\lfloor X \right\rfloor
ใฏ
X
ไปฅไธใฎๆๅคงใฎๆดๆฐใ่กจใใพใใ | [
{
"input": "2 2\n",
"output": "4\n"
},
{
"input": "5 1\n",
"output": "44\n"
},
{
"input": "167 91\n",
"output": "284830080\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_m | ๅ้กๆ
ๆญฃๆดๆฐ
N, M
ใไธใใใใพใใ
N
ๅใฎๆญฃๆดๆฐใฎ็ต
(x_1,x_2,\dots ,x_N)
ใงใใฃใฆ
\displaystyle\prod_{i=1}^{N}x_i=M
ใๆบใใใใฎใในใฆใฎ้ๅใ
\bm{X}
ใจใใพใใ
\displaystyle\sum_{(x_1,x_2,\dots ,x_N)\in \bm{X}}\prod_{i=1}^{N} (x_i+A_i)
ใ
998244353
ใงๅฒใฃใใใพใใๆฑใใฆใใ ใใใ | [
{
"input": "2 3\n0 1\n",
"output": "10\n"
},
{
"input": "5 1\n0 1 2 3 4\n",
"output": "120\n"
},
{
"input": "10 314159265358\n0 1 2 3 4 5 6 7 8 9\n",
"output": "658270849\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_n | ๅ้กๆ
ๆดๆฐ
K
ใจ
3
ๆฌกๅ
ไธใฎ
N
ๅใฎ็น
(x_1,y_1,z_1), \dots, (x_N,y_N,z_N)
ใไธใใใใพใใ
N
็น
(K x_1,K y_1,K z_1), \dots, (K x_N,K y_N,K z_N)
ใฎๅธๅ
ใฎๅ
้จใพใใฏๅข็ใซๅซใพใใ็นใงใใฃใฆๅบงๆจใใในใฆๆดๆฐใงใใใใใชใใฎใฎๅๆฐใ
998244353
ใงๅฒใฃใใใพใใๆฑใใฆใใ ใใใ | [
{
"input": "4 2\n0 0 0\n1 0 0\n0 1 0\n0 0 1\n",
"output": "10\n"
},
{
"input": "4 10000\n0 0 0\n1 0 0\n0 1 0\n0 0 1\n",
"output": "59878050\n"
},
{
"input": "8 314159265358979\n5 -3 -3\n-5 -3 -3\n0 5 -3\n0 0 10\n4 2 6\n-4 2 6\n0 -5 6\n0 0 -5\n",
"output": "152811018\n"
}
] |
https://atcoder.jp/contests/ttpc2022/tasks/ttpc2022_o | ็ฐกๅใชๅ้กๆ
่ฌใฎใขใใคใ
(M, \oplus)
ใจใใใใ่จ็ฎใใ CPU ใ
4
ๅใใใพใใ
ๆดๆฐ
N
ใไธใใใใใฎใงใ
M
ใฎๅ
A = (A_1, A_2, โฆ, A_N)
ใใ
A
ใฎ็ดฏ็ฉ
\oplus
ใ
4
ไธฆๅใง่จ็ฎใใฆใใ ใใใ
ใใฎ้ใๆไฝๅๆฐใๆๅฐๅใใฆใใ ใใใ | [
{
"input": "2\n",
"output": "1\n2 1 2\n2000 2000 2000\n2000 2000 2000\n2000 2000 2000\n"
},
{
"input": "4\n",
"output": "2\n2 1 2\n4 3 4\n2000 2000 2000\n2000 2000 2000\n3 2 3\n4 2 4\n2000 2000 2000\n2000 2000 2000\n"
}
] |
https://atcoder.jp/contests/ahc015/tasks/ahc015_a | Problem Statement
There is a box that can contain
10\times 10
pieces of candy in a grid pattern.
The box is initially empty, and
100
pieces of candy will be placed in order.
There are
3
flavors of candy, and we know in advance the flavor
f_t (1\leq f_t\leq 3)
of the
t
-th candy.
On the other hand, we do not know in ... | [] |
https://atcoder.jp/contests/abc275/tasks/abc275_a | Problem Statement
There are
N
bridges in AtCoder Village. The height of the bridge numbered
i
is
H_i
(
i
is an integer between
1
and
N
).
Every two different bridges in the village have different heights.
Print the number representing the highest bridge in the village. | [
{
"input": "3\n50 80 70\n",
"output": "2\n"
},
{
"input": "1\n1000000000\n",
"output": "1\n"
},
{
"input": "10\n22 75 26 45 72 81 47 29 97 2\n",
"output": "9\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_b | Problem Statement
There are non-negative integers
A
,
B
,
C
,
D
,
E
, and
F
, which satisfy
A\times B\times C\geq D\times E\times F
.
Find the remainder when
(A\times B\times C)-(D\times E\times F)
is divided by
998244353
. | [
{
"input": "2 3 5 1 2 4\n",
"output": "22\n"
},
{
"input": "1 1 1000000000 0 0 0\n",
"output": "1755647\n"
},
{
"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_c | Problem Statement
There is a two-dimensional plane. For integers
r
and
c
between
1
and
9
, there is a pawn at the coordinates
(r,c)
if the
c
-th character of
S_{r}
is
#
, and nothing if the
c
-th character of
S_{r}
is
.
.
Find the number of squares in this plane with pawns placed at all four vertices. | [
{
"input": "##.......\n##.......\n.........\n.......#.\n.....#...\n........#\n......#..\n.........\n.........\n",
"output": "2\n"
},
{
"input": ".#.......\n#.#......\n.#.......\n.........\n....#.#.#\n.........\n....#.#.#\n........#\n.........\n",
"output": "3\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_d | Problem Statement
A function
f(x)
defined for non-negative integers
x
satisfies the following conditions.
f(0) = 1
.
f(k) = f(\lfloor \frac{k}{2}\rfloor) + f(\lfloor \frac{k}{3}\rfloor)
for any positive integer
k
.
Here,
\lfloor A \rfloor
denotes the value of
A
rounded down to an integer.
Find
f(N)
. | [
{
"input": "2\n",
"output": "3\n"
},
{
"input": "0\n",
"output": "1\n"
},
{
"input": "100\n",
"output": "55\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_e | Problem Statement
Takahashi is playing sugoroku, a board game.
The board has
N+1
squares, numbered
0
to
N
.
Takahashi starts at square
0
and goes for square
N
.
The game uses a roulette wheel with
M
numbers from
1
to
M
that appear with equal probability.
Takahashi spins the wheel and moves by the number of squares in... | [
{
"input": "2 2 1\n",
"output": "499122177\n"
},
{
"input": "10 5 6\n",
"output": "184124175\n"
},
{
"input": "100 1 99\n",
"output": "0\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_f | Problem Statement
You are given an integer array
A=(a_1,a_2,\ldots,a_N)
.
You may perform the following operation any number of times (possibly zero).
Choose a nonempty contiguous subarray of
A
, and delete it from the array.
For each
x=1,2,\ldots,M
, solve the following problem:
Find the minimum possible number of ope... | [
{
"input": "4 5\n1 2 3 4\n",
"output": "1\n2\n1\n1\n1\n"
},
{
"input": "1 5\n3\n",
"output": "-1\n-1\n0\n-1\n-1\n"
},
{
"input": "12 20\n2 5 6 5 2 1 7 9 7 2 5 5\n",
"output": "2\n1\n2\n2\n1\n2\n1\n2\n2\n1\n2\n1\n1\n1\n2\n2\n1\n1\n1\n1\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_g | Problem Statement
There are
N
kinds of items, each with infinitely many copies. The
i
-th kind of item has a weight of
A_i
, a volume of
B_i
, and a value of
C_i
.
Level
X
Takahashi can carry items whose total weight is at most
X
and whose total volume is at most
X
. Under this condition, it is allowed to carry any num... | [
{
"input": "2\n100000000 200000000 100000000\n200000000 100000000 100000000\n",
"output": "0.6666666666666667\n"
},
{
"input": "1\n500000000 300000000 123456789\n",
"output": "0.2469135780000000\n"
}
] |
https://atcoder.jp/contests/abc275/tasks/abc275_h | Problem Statement
There are
N
monsters along a number line. At the coordinate
i
(1\leq i\leq N)
is a monster with a stamina of
A_i
.
Additionally, at the coordinate
i
, there is a permanent shield of a strength
B_i
.
This shield persists even when the monster at the same coordinate has a health of
0
or below.
Takahashi... | [
{
"input": "5\n4 3 5 1 2\n10 40 20 60 50\n",
"output": "210\n"
},
{
"input": "1\n1000000000\n1000000000\n",
"output": "1000000000000000000\n"
},
{
"input": "10\n522 4575 6426 9445 8772 81 3447 629 3497 7202\n7775 4325 3982 4784 8417 2156 1932 5902 5728 8537\n",
"output": "77917796\n"... |
https://atcoder.jp/contests/abc274/tasks/abc274_a | Problem Statement
Takahashi is making a computer baseball game.
He will write a program that shows a batter's batting average with a specified number of digits.
There are integers
A
and
B
, which satisfy
1 \leq A \leq 10
and
0 \leq B \leq A
.
Let
S
be the string obtained as follows.
Round off
\dfrac{B}{A}
to three deci... | [
{
"input": "7 4\n",
"output": "0.571\n"
},
{
"input": "7 3\n",
"output": "0.429\n"
},
{
"input": "2 1\n",
"output": "0.500\n"
},
{
"input": "10 10\n",
"output": "1.000\n"
},
{
"input": "1 0\n",
"output": "0.000\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.