BZOJ1493 [NOI2007] Necklace Factory

Source: Internet
Author: User

Not to be continued ...

1493: [NOI2007] Necklace factory time limit:30 Sec Memory limit:64 MB
submit:1320 solved:576
[Submit] [Status] [Discuss] Descriptiont Company is a company specializing in the production of color beads necklace, the production of the necklace design novel, diverse styles, affordable, widely loved by young people. Recently, T Company intends to launch a self-service necklace production system, using the system customers can design their own beautiful necklace in mind. The Necklace self-production system includes hardware system and software system, software system interacts with user and control hardware system, hardware system accepts the command of software system to produce the specified necklace. The system's hardware system has been completed, and the software system has not been developed, T company's people have been participating in the National Information Science competition, you can help T company to write a software simulation system? A necklace contains N beads, and the color of each bead is one of the 1,2,...,c. The necklace is fixed on a flat plate, where the plate is labeled position 1, and the other position in the clockwise direction is recorded as 2,3,...,n. The software system you are about to write should support the following command: The first line of the input file contains two integer n,c, each representing the number of beads and the number of colors that the necklace contains. The second line contains n integers, x1,x2,...,xn, representing the color of the beads from position 1 to position N, 1≤xi≤c. The third line contains an integer Q, which indicates the number of commands. The next line of Q is one command per line, as described above. n≤500000, q≤500000,c≤1000 Output

For each C and CS command, an integer should be output to represent the corresponding answer.

Sample Input5 3
1 2 3) 2 1
4
C
R2
P 5 5 2
CS 4 1Sample Output4
1HINT

Note The rotate command rotates the bead but does not change the number of position, and the invert command always has the axis of symmetry at position 1. For example, when n=10, the item
Position number 1 on the chain:


Note, however, that the position number on the necklace is still 1, so the symmetric axis of the flip is unchanged. Thus the color of the necklace when the "F" command is executed again
As shown in 4.
2. About the countsegment Command CS command indicates how many "parts" of a "segment" are queried. Note especially when the length of the query
Equals N, we still understand the query part as a "segment". For example, in the case shown in Figure 4, execute the "CS 1 10" command, the query from the bit
Set 1 start to position 10 end of this line length of 10 is how many "parts", and then get the return value of 3. The contrast is
, the return value is 2 if the "C" command is executed

BZOJ1493 [NOI2007] Necklace Factory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.