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

17560번 - Strings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB55161544.118%

문제

Gustave is an artist. His last project is to wrap the Eiffel Tower with a very long strip of fabric on which messages from people from all over the world are written. Obviously, the strip has to be very, very long and Gustave came up with the following way of building it. He starts with a string on which all the messages are written. Then he repeatedly builds other strings, either by concatenating copies of two strings, or by making a copy of a section of consecutive characters from another string.

Once Gustave is happy with the final string he gets, he contacts a company to have the string printed on a strip of fabric. Being meticulous, Gustave does not want the company to make a single mistake. He thus computes a checksum out of his string and has the company do the same computation as a verification.

입력

The input consists of the following lines:

  • The first line contains an integer N.
  • The next line contains a string S(0) of lowercase alphabetic characters between ‘a’ and ‘z’.
  • The next N − 1 lines contain instructions to build strings S(1), ..., S(N − 1). The instruction to build string S(i) is either:
    • “SUB x lo hi” with x, lo, hi integers such that 0 6 x < i and 0 6 lo 6 hi 6 length(S(x)), or
    • “APP x y” with x, y integers such that 0 6 x, y < i.

Instruction “SUB x lo hi” means that S(i) is formed using (a copy of) characters of S(x) from index lo (inclusive) to hi (exclusive). Characters are numbered starting from 0. Instruction “APP x y” means that S(i) is formed by concatenating copies of strings S(x) and S(y) in that order, i.e., with S(x) coming first then S(y).

출력

The output should consist of a single line, whose content is an integer, the sum of all ASCII codes of the characters of the final string S(N − 1), modulo 1 000 000 007.

제한

  • 1 ≤ N ≤ 2 500;
  • 1 ≤ length(S(0)) ≤ 1 000;
  • the length of any string S(i) will never exceed 263 − 1.

예제 입력 1

3
foobar
SUB 0 0 3
APP 1 1

예제 출력 1

648

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2018 G번

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

출처

대학교 대회

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

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