跳到正文

个人记录

ABC445 ABCD Solution

lzh0613约 8 分钟
原文
文章信息与版本

文章信息

收录
2026年2月16日
更新
2026年2月16日
篇幅
约 8 分钟

版本

  1. v3当前
  2. v2
  3. v1

总结

这是我第一次发文章 & 第一场 AT 上的 炸飞的 比赛,纪念一下。 翻译就耗费好长时间。《clscls:比你们英语阅读简单》 C题数据范围看错了,把 ii 看作 11,导致写得太复杂,一直调不出来,后来发现似乎一个简单的记忆化就能过。

A Strong Word

原文题面

原文题面

Problem Statement

You are given a string SS of length at least 22 consisting of lowercase English letters.

Determine whether the first character and the last character of SS are the same.

Constraints

SS is a string of length between 22 and 1010, inclusive, consisting of lowercase English letters.

大致翻译

给定一个字符串 SS,如果他的第一个字符与最后一个字符是相等的,输出 Yes,否则输出 No。

题解

本题主要考察关于字符串的语法。输入后判断即可。

核心代码

C++
	cin >> s;
	n = s.size(), s = " " + s;
	if (s[1] == s[n]) cout << "Yes";
	else cout << "No";

B Center Alignment

原文题面

原文题面

Problem Statement

You are given NN strings S1,S2,…,SNS_1, S_2, …, S_N of odd lengths consisting of lowercase English letters.

Let mm be the length of the longest string among S1,S2,…,SNS_1, S_2, …, S_N. Find strings T1,T2,…,TNT_1, T_2, …, T_N satisfying the following condition.

  • Condition: TiT_i is a string of length mm formed by concatenating kk copies of ., SiS_i, and kk copies of . in this order, for some non-negative integer kk.

Constraints

  • NN is an integer between 11 and 100100, inclusive.
  • SiS_i is a string of odd length between 11 and 9999, inclusive, consisting of lowercase English letters.

大致翻译

给定 NN 个长度为奇数且不统一的字符串 SiS_i,设 mm 为其中最长的字符串的长度,在所有字符串左右两侧填充等量且适量的 . 直至其长度增加至 mm,输出所有增长后的字符串 SiS_i。

题解

本题主要还是考察关于字符串的语法。先对所有字符串 SiS_i 的长度取个 maxmax 放在 mm 里。对于每个字符串 SiS_i,在 SiS_i 的前后共添加 m−Si.sizem - S_i.size 个 .,因为要保证左右两边的 . 的个数相同,也就是在 SiS_i 的前后分别添加 m−Si.size2\displaystyle \frac{m - S_i.size}{2} 个 .,在处理的同时直接输出即可。

核心代码

C++
    cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		m = max(m, (int)s[i].size());
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= (m - (int)s[i].size()) >> 1; j++) {
			cout << ".";
		}
		cout << s[i];
		for (int j = 1; j <= (m - (int)s[i].size()) >> 1; j++) {
			cout << ".";
		}
		cout << "\n";
	}

C Sugoroku Destination

原文题面

原文题面

Problem Statement

There are NN cells, cell 11, cell 22, …, cell NN, arranged in a line. Cell ii has an integer Ai(i≤Ai≤N)A_i (i \leq A_i \leq N) written on it.

For each of s=1,2,…,Ns = 1, 2, …, N, solve the following problem.

  • Initially, place a piece on cell ss. After performing the operation “let xx be the integer written on the cell where the piece is placed, and then move the piece to cell xx” 1010010 ^ {100} times, output the number of the cell where the piece is placed.

Constraints

  • 1≤N≤5×1051 \leq N \leq 5 \times 10 ^ 5
  • i≤Ai≤N(1≤i≤N)i \leq A_i \leq N (1 \leq i \leq N)
  • All input values are integers.

大致翻译

题解

通过代码

C++

D Reconstruct Chocolate

原文题面

原文题面

Problem Statement

There are NN pieces of a chocolate bar placed on a table. Piece i(1≤i≤N)i (1 \leq i \leq N) is a rectangle of hih_i blocks tall and wiw_i blocks wide.

It is known that these pieces were obtained by the following procedure.

  • Start by holding a chocolate bar of HH blocks tall and WW blocks wide. Nothing is placed on the table.

  • Repeat the following operation N−1N−1 times.

  • Split the piece currently in hand into two pieces. Both pieces after splitting must be rectangles along the block boundaries.

  • Place one of the pieces on the table, and keep the other piece in hand.

  • Finally, place the piece in hand on the table.

Find one way to arrange the NN pieces into a rectangle of HH blocks tall and WW blocks wide satisfying the following conditions.

  • Different pieces do not overlap.
  • Pieces must not be rotated. That is, for h≠wh \ne w, a piece of hh blocks tall and ww blocks wide cannot be placed as a piece of ww blocks tall and hh blocks wide.

Constraints

  • 1≤H≤1091 \leq H \leq 10 ^ 9
  • 1≤W≤1091 \leq W \leq 10 ^ 9
  • 2≤N≤2×1052 \leq N \leq 2 \times 10 ^ 5
  • 1≤hi≤H1 \leq h_i \leq H
  • 1≤wi≤W1 \leq w_i \leq W
  • It is guaranteed that the input was obtained by the procedure described in the problem statement.
  • All input values are integers.

大致翻译

题解

通过代码

C++
原文