Time Limit: 3000MS   Memory Limit: 10000K Total Submissions: 4901   Accepted: 2765 Description Once upon a time there was a famous actress. As you may expect, she played mostly Antique Comedies most of all. All the people loved her. But she was not i…
题目大意: 给出一个长度为N的字符串,求其字典序最小的循环同构. N<=10W. 算法讨论: 算法一.最小表示法.定义题. 算法二.后缀自动机. Codes: #include <iostream> #include <algorithm> #include <cstdlib> #include <cstdio> #include <cstring> #include <cassert> using namespace std;…
题目大意:求循环同构的字符串的最小字典序. 解题关键:最小表示法模板题. #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<iostream> using namespace std; typedef long long ll; ]; int get_min(char *s){ int le…
最小表示法就是直接扫过去 后缀自动机就是每次找最字典序最小儿子输出 最小表示法 /* 最小表示法裸题, 我好像学过来着?? 怎么忘得这么干净 */ #include<cstdio> #include<algorithm> #include<cstring> #include<queue> #include<iostream> #define ll long long #define M 300010 #define mmp make_pair u…
字符串最小表示 后缀自动机 O(n) 把串复制一次,链接在后面之后,建立SAM,贪心地在SAM上转移,每次贪心地选择最小的字符,转移的长度为n时停止. 输出时由于要最靠前的,所以要在endpos集合中挑一个最小的,这个在slink_tree上递推一下就能轻松获得. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define MAXL 10000 #define M…
Glass Beads Time Limit: 3000MS   Memory Limit: 10000K Total Submissions: 4314   Accepted: 2448 Description Once upon a time there was a famous actress. As you may expect, she played mostly Antique Comedies most of all. All the people loved her. But s…
题目链接: https://vjudge.net/problem/POJ-1509 题目大意: 给你一个循环串,然后找到一个位置,使得从这个位置开始的整个串字典序最小. 解题思路: 最小表示法模板 注意模板返回的下标是从0开始,答案要求从1开始 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<string> #include<…
题目链接:http://poj.org/problem?id=1509 题目意思就是求循环字符串的最小表示. 我们用字符串S+S建立SAM,然后从root开始走n步,每次尽量选最小的. 由于 SAM 可以接受 SS 所有的子串,而字典序最小的字符串也必定是 SS 的子串,因此按照上面的规则移动就可以找到一个字典序最小的子串. 这里的right等价类的len显然可以直接扩展到串首,于是开始的位置就是T[o].len-n+1. #include<cstdio> #include<cstrin…
题意: 给一个字符串S,每次可以将它的第一个字符移到最后面,求这样能得到的字典序最小的字符串.输出开始下标 练习SAM第一题! SS构造SAM,然后从开始尽量走最小走n步就可以啦 什么?开始位置?!Right集合中最左的位置-len 直接t[u].val-n+1,为什么啊没有一个人的题解解释呜呜呜呜呜呜 想了想,这个最小串Right等价类的最长串一定到了开头位置,卡不掉吧,最小串唯一一定成立,如果不唯一好像只可能是自己吧 #include <iostream> #include <cst…
题目分析: 模板练手.看最长能走多远. 代码: #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string> using namespace std; ; ],fa[maxn],maxlen[maxn],root,num; string str; int addnew(int dt){maxlen[++num] = dt;retur…