Skip to main content
Hello! I'm Clover

Welcome to my blog where I'll be sharing my insights and experiences on math, algorithms, and web technology. I'm passionate about these subjects and excited to share my knowledge on topics like frontend and backend development.

Let's explore this fascinating world together!

Introduce

Recent posts

Question description

There are NN classes in the ABC competitive programming school, and class number ii (1iN1 \leq i \leq N) targets students with a rating of AiA_i.

Now, QQ students are about to join this school. The rating of student number jj (1jQ1 \leq j \leq Q) is BjB_j. Each student will be dissatisfied if they go to a class that does not match their level. The dissatisfaction for each student is defined as follows:

The absolute difference between the target rating aa and their own rating bb, that is, ab|a - b|.

For j=1,2,3,,Qj = 1, 2, 3, \dots, Q, find the minimum dissatisfaction that can be considered for student number jj. It is allowed to have classes with no students or classes with multiple students.


CloverAlgorithmAtcoderBinary Search2 min read

Question description

You are given a string SS of length NN, consisting of only lowercase English letters.

Find the lexicographically smallest substring of SS with a length of KK and output it.

Note:
A substring of a string TT is a string obtained by removing 0 or more characters from TT and concatenating the remaining characters in their original order.

The definition of lexicographic order:
Let X=x1x2xnX = x_1 x_2 \dots x_n and Y=y1y2ymY = y_1 y_2 \dots y_m be two different strings. XX is said to be lexicographically smaller than YY if and only if XX is a prefix of YY, or if jj is the smallest integer such that xjyjx_j \neq y_j, and xj<yjx_j < y_j.


CloverAlgorithmAtcoderDPMathOne min read

Question description

There is a grid with HH rows and WW columns. The cell at the ii-th row from the top and jj-th column from the left, denoted as (i,j)(i, j), contains the integer A[i][j]A[i][j].

For all cells (i,j)(i, j) where 1iH1 \leq i \leq H and 1jW1 \leq j \leq W, find the following value:

  • The sum of integers written in the cells that are in the same row or the same column as cell (i,j)(i, j) (including the cell itself).

CloverAlgorithmAtcoderGraphBFS2 min read

Question description

There are NN cities, each numbered from 1,2,3,,N1, 2, 3, \dots, N. There are also N1N-1 roads, with the ii-th road connecting cities A[i]A[i] and B[i]B[i] bidirectionally. It is possible to travel between any two cities using some roads.

Now, you can freely choose integers u,vu, v (1u<vN1 \leq u < v \leq N) and build a single new road that connects city uu and city vv bidirectionally. Then, the following value is considered as the score:

  • The number of roads traveled in a route that returns to the same city without passing the same road twice (this value is uniquely determined).

Output the maximum possible score.


CloverAlgorithmAtcoder2 min read

Question description

Output all correct bracket sequences of length NN in lexicographic order.

A correct bracket sequence is defined as follows:

  • () is a correct bracket sequence.
  • When SS is a correct bracket sequence, the string ( + SS + ) is a correct bracket sequence.
  • When SS and TT are correct bracket sequences, the string SS + TT is a correct bracket sequence.
  • All other strings are not correct bracket sequences.

CloverAlgorithmAtcoderBinary Search2 min read

Problem description

There is a Yokan of length LL [cm]. There are NN cutting points, and the ii-th cutting point from the left is at position AiA_i [cm] from the left.

You want to choose KK of the NN cutting points and divide the Yokan into K+1K+1 pieces. Then, the following value is used as the score:

  • The length of the shortest piece among the K+1K+1 pieces

Find the score that can be obtained when dividing the Yokan to maximize the score.


CloverAlgorithmAtcoderBinary Search2 min read