A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the…
用扩展KMP做简单省力..... D. Prefixes and Suffixes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character.…
Infinite Maze time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We've got a rectangular n × m-cell maze. Each cell is either passable, or is a wall (impassable). A little boy found the maze…
传送门 题意: 给你一个无限大的整数序列 p = {1, 2, 3, ...}: 有 n 次操作,每次操作交换第 ai 个数和第 aj 个数: 求序列中逆序对的个数: 题解: 考虑交换完后的序列,存在连续的区间 [ i , j ] 使得 p[ i ] = i , 那么分下一下这种区间的特点 假设 i 之前有 x 个数大于 p[ i ],那么可知对于第 i 个数有 x 个逆序对,同理,因为 p[ i+1 ] = p[ i ] 所以 i+1 之前也一定有且只有 x 个数大于 p[ i+1 ],那么…