Logo
(追記) (追記ここまで)

33647번 - Power String Matching 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB111100.000%

문제

For two strings $s_1$ and $s_2,ドル let $s_1+s_2$ denote their concatenation, e.g. abc + cda is the string abccda.

Now for a string $s$ and an integer $k≥0$ we let $s^k$ denote the result of concatenating $k$ copies of $s,ドル i.e. ab$^3=$ababab. If $k=0,ドル then $s^k$ is just the empty string.

Finally, a collection of nonempty strings $s_1,\dots ,s_k$ is said to partition a string $s$ if $s=s_1+s_2+\dots +s_k$.

For this problem, you will be given two strings $s,ドル $t$. The goal is to determine if there is a partition $s_1,s_2,\dots ,s_k$ of $s$ and integers $a_1,a_2,\dots ,a_k≥0$ such that $t=s_1^{a_1}+s_2^{a_2}+\dots +s_k^{a_k}$.

입력

The first line of input contains two integers $N$ (1ドル≤N≤300$) and $M$ (1ドル≤M≤300$). The second line contains a string $s$ of length $N$ and the third line contains a string $t$ of length $M$. Both strings contain only the characters 0 and 1.

출력

Output yes if it there is a partition $s_1,s_2,\dots ,s_k$ of $s$ and integers $a_1,a_2,\dots ,a_k≥0$ such that $t=s_1^{a_1}+s_2^{a_2}+\dots +s_k^{a_k},ドル otherwise output no.

제한

예제 입력 1

4 5
1100
11010

예제 출력 1

yes

예제 입력 2

4 2
1100
01

예제 출력 2

no

예제 입력 3

9 14
010100110
11110101010100

예제 출력 3

yes

힌트

출처

University > University of Alberta Programming Contest > UAPC 2024 > Division 1 I번

University > University of Alberta Programming Contest > UAPC 2024 > Division 2 H번

  • 문제를 만든 사람: Zachary Friggstad
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /