总结
这是我第一次发文章 & 第一场 AT 上的 炸飞的 比赛,纪念一下。
翻译就耗费好长时间。《:比你们英语阅读简单》
C题数据范围看错了,把 看作 ,导致写得太复杂,一直调不出来,后来发现似乎一个简单的记忆化就能过。
A Strong Word
原文题面
原文题面
Problem Statement
You are given a string of length at least consisting of lowercase English letters.
Determine whether the first character and the last character of are the same.
Constraints
is a string of length between and , inclusive, consisting of lowercase English letters.
大致翻译
给定一个字符串 ,如果他的第一个字符与最后一个字符是相等的,输出Yes,否则输出No。
题解
本题主要考察关于字符串的语法。输入后判断即可。
核心代码
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 strings of odd lengths consisting of lowercase English letters.
Let be the length of the longest string among . Find strings satisfying the following condition.
- Condition: is a string of length formed by concatenating copies of
., , and copies of.in this order, for some non-negative integer .
Constraints
- is an integer between and , inclusive.
- is a string of odd length between and , inclusive, consisting of lowercase English letters.
大致翻译
给定 个长度为奇数且不统一的字符串 ,设 为其中最长的字符串的长度,在所有字符串左右两侧填充等量且适量的 . 直至其长度增加至 ,输出所有增长后的字符串 。
题解
本题主要还是考察关于字符串的语法。先对所有字符串 的长度取个 放在 里。对于每个字符串 ,在 的前后共添加 个 .,因为要保证左右两边的 . 的个数相同,也就是在 的前后分别添加 个 .,在处理的同时直接输出即可。
核心代码
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 cells, cell , cell , …, cell , arranged in a line. Cell has an integer written on it.
For each of , solve the following problem.
- Initially, place a piece on cell . After performing the operation “let be the integer written on the cell where the piece is placed, and then move the piece to cell ” times, output the number of the cell where the piece is placed.
Constraints
- All input values are integers.
大致翻译
题解
通过代码
D Reconstruct Chocolate
原文题面
原文题面
Problem Statement
There are pieces of a chocolate bar placed on a table. Piece is a rectangle of blocks tall and blocks wide.
It is known that these pieces were obtained by the following procedure.
-
Start by holding a chocolate bar of blocks tall and blocks wide. Nothing is placed on the table.
-
Repeat the following operation 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 pieces into a rectangle of blocks tall and blocks wide satisfying the following conditions.
- Different pieces do not overlap.
- Pieces must not be rotated. That is, for , a piece of blocks tall and blocks wide cannot be placed as a piece of blocks tall and blocks wide.
Constraints
- It is guaranteed that the input was obtained by the procedure described in the problem statement.
- All input values are integers.
大致翻译
题解
通过代码