Code Lock HDU 3461
Posted Heilce
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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?
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.
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
以上是关于Code Lock HDU 3461的主要内容,如果未能解决你的问题,请参考以下文章
hdu 3461 Code Lock 并查集(有点难想到)★★