题目链接:uva 1314 - Hidden Password
题目大意:给定一个字符串,求该字符串的最小表示法。
解题思路:以两个指针交替移动,逐个比较,直到比较出大小后转移起始位置。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5+5;
int N;
char s[maxn];
int main () {
int cas;
scanf("%d", &cas);
while (cas--) {
scanf("%d%s", &N, s);
int p = 0, i = 1;
while (p < N && i < N) {
......
阅读全文