No.3082 Make Palindromic Multiple(Judge)
タグ : / 解いたユーザー数 22
作問者 : 👑
hamamu
Note
This problem asks you to implement part of the judge for Problem H. In particular, this problem asks you to determine whether a string is a palindrome; it does not determine whether a number is a multiple.
Problem Statement
You are given $K$ strings $S_1,S_2,\cdots, S_K$ consisting of the digits 0123456789 and $K$ integers $T_1,T_2, \cdots, T_K$.
A string $X$ is initially empty. For $i = 1,2,\cdots, K$, perform the following operation.
Append the string formed by concatenating $T_i$ copies of the string $S_i$ to the end of the string $X$.
Determine whether the string $X$ obtained in this way is a palindrome.
What is a palindrome?
A string $X$ is a palindrome if $X_i = X_{|X| + 1 - i}$ holds for all integers $i$ satisfying $1 \leq i \leq |X|$.
Constraints
$1 \leq K\leq 2 \times 10^5$
$S_i$ $(1\leq i \leq K)$ is a string consisting of the digits
0123456789.The first character of $S_1$ is not
0.$1 \leq |S_i| \leq 2 \times 10^5$ $(1\leq i \leq K)$
$\sum_{i = 1}^K |S_i| \leq 2 \times 10^5$
$1 \leq T_i \leq 10^{18}$ $(1\leq i \leq K)$
$K, T_i$ are integers. $(1\leq i \leq K)$
Input
$K$ $S_1$ $T_1$ $S_2$ $T_2$ $\vdots$ $S_K$ $T_K$
Output
If the string $X$ is a palindrome, print Yes on $1$ line. Otherwise, print No on $1$ line.
Sample
Sample 1
Input
3 1 1 3 4 1 1
Output
Yes
The string obtained by repeating 1 $1$ time, repeating 3 $4$ times, and repeating 1 $1$ time is 133331. This is a palindrome.
Sample 2
Input
2 12123 1 21 2
Output
Yes
The string 121232121 is a palindrome.
Sample 3
Input
1 345 2
Output
No
The string 345345 is not a palindrome.
Sample 4
Input
5 2 8 2 1 2 5 7 1 2 14
Output
Yes
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。