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

21586번 - Another Substring Query Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 1024 MB253574528.125%

문제

You are given a string $s$ and several queries.

Each query consists of a string $t$ and an integer $k$. For each query, determine the $k$th position in $s$ where a substring matching $t$ starts. If $t$ occurs fewer than $k$ times in $s,ドル print −1.

입력

The first line of input contains a single string $s$ (1ドル \le |s| \le 2 \cdot 10^5$), which is the queriable string. It will consist only of lower-case letters.

The next line of input contains a single integer $q$ (1ドル \le q \le 2 \cdot 10^5$), which is the number of queries that follow.

Each of the next $q$ lines contains a string $t$ (1ドル \le |t|$) and an integer $k$ (1ドル \le k \le |s|$). This represents a query for the $k$th occurrence of $t$ in $s$. The string $t$ will consist only of lower-case letters. The sum of all $|t|$’s will be $\le 2 \cdot 10^5$.

출력

Output a single integer, which is the position of the start of the $k$th occurrence of $t$ in $s,ドル or −1 if $t$ occurs fewer than $k$ times in $s$. The first character in $s$ is at position 1.

제한

예제 입력 1

abacabadabacaba
4
a 7
e 3
bac 2
abada 1

예제 출력 1

13
-1
10
5

힌트

출처

ICPC > Regionals > North America > North America Division Championships > 2021 ICPC North America Division Championships B번

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

출처

대학교 대회

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

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