题目链接 Flights for Regular Customers 首先按照$d$的大小升序排序 然后分成$m$个时刻,每条路径一次处理过来. $can[i][j]$表示当前时刻$i$能否走到$j$ $can$通过上一条路径后的$can$和当前的可行路径矩阵的$d$次幂得到. 这由$floyd$求解即可.考虑到$d$很大,用矩阵快速幂加速. TLE on test 10 矩阵乘法的时候用$bitset$优化. 更新答案的时候,我们枚举每个点. 若第$1$个点可以走到第$i$个点,则更新答案.…
In the country there are exactly n cities numbered with positive integers from 1 to n. In each city there is an airport is located. Also, there is the only one airline, which makes m flights. Unfortunately, to use them, you need to be a regular custo…
[CF461E]Appleman and a Game 题意:你有一个字符串t(由A,B,C,D组成),你还需要构造一个长度为n的字符串s.你的对手需要用t的子串来拼出s,具体来说就是每次找一个t的子串放在已经拼出来的串的后面.你想要最大化你的对手拼出s的所需次数,你的对手是绝顶聪明的.输出这个次数. $n\le 10^{18},|t|\le 10^5$ 题解:先从对手的角度考虑,每次它肯定是尽可能的延伸已有的字符串,一直延伸到t中不存在这个子串为止.所以我们可以每次向s中加入[a,b),使得t…
(CodeForces - 5C)Longest Regular Bracket Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output This is yet another problem dealing with regular bracket sequences. We should remind you t…