|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||3||1||1||33.333%|
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:
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.
3 foobar SUB 0 0 3 APP 1 1