Description FJ is about to take his N (1 ≤ N ≤ 30,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges. The contest organizers adopted a new registration…
Description 题库链接 给以长度为 \(n\) 的字符串,要求每次只能从两边取一个字符,使得取出来之后字典序最小. \(1\leq n\leq 30000\) Solution 将字符串翻转后加在原字符串后,求个后缀排名.直接比较排名来判断取前还是取后. Code #include <bits/stdc++.h> using namespace std; const int N = (30000+5)<<1; char ch[N]; int n, m, x[N<&l…