首页 > 代码库 > Code Lock HDU 3461

Code Lock HDU 3461

给定由N个字母组成的密码锁,如【abcdef】每一位字母都可以转动,转动该字母时,将变成它的下一个字母,如‘a‘转动后是b,x转动后是y,

接着给定M个区间,每次转动给定区间内的所有字母,如密码锁【abcdef】,给定区间【1,3】转动这个区间一次后变为【bcddef】;

 

题解:  要是用并查集蒙的话,有可能就很容易的蒙出来了,但是要是证明的话还是有点难度的。。。。

待续:

 

Problem Description
A lock you use has a code system to be opened instead of a key. The lock contains a sequence of wheels. Each wheel has the 26 letters of the English alphabet ‘a‘ through ‘z‘, in order. If you move a wheel up, the letter it shows changes to the next letter in the English alphabet (if it was showing the last letter ‘z‘, then it changes to ‘a‘).
At each operation, you are only allowed to move some specific subsequence of contiguous wheels up. This has the same effect of moving each of the wheels up within the subsequence.
If a lock can change to another after a sequence of operations, we regard them as same lock. Find out how many different locks exist?
 

 

Input
There are several test cases in the input.

Each test case begin with two integers N (1<=N<=10000000) and M (0<=M<=1000) indicating the length of the code system and the number of legal operations. 
Then M lines follows. Each line contains two integer L and R (1<=L<=R<=N), means an interval [L, R], each time you can choose one interval, move all of the wheels in this interval up.

The input terminates by end of file marker.
 

 

Output
For each test case, output the answer mod 1000000007
 

 

Sample Input
1 1 1 1 2 1 1 2
 

 

Sample Output
1 26
 

 

Author
hanshuai
 

 

Source
2010 ACM-ICPC Multi-University Training Contest(3)——Host by WHU

Code Lock HDU 3461