問題一覧 > 通常問題

No.3082 Make Palindromic Multiple(Judge)

レベル : / AI推定難易度 : 1650 / 実行時間制限 : 1ケース 3.500秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 22
作問者 : 👑 binap / テスター : kaichou243 👑 hamamu
お気に入りにしたユーザー ProblemId : 11992 / 自分の提出
問題文最終更新日: 2025-03-29 03:29:26
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 462 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。