2018南京ICPCMediocre String Problem 马拉车
Posted qldabiaoge
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018南京ICPCMediocre String Problem 马拉车相关的知识,希望对你有一定的参考价值。
hash+二分求出最长公共前缀
然后马拉车+前缀和计数
1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <cmath> 5 #include <algorithm> 6 #include <set> 7 #include <iostream> 8 #include <map> 9 #include <stack> 10 #include <string> 11 #include <vector> 12 #define pi acos(-1.0) 13 #define eps 1e-9 14 #define fi first 15 #define se second 16 #define rtl rt<<1 17 #define rtr rt<<1|1 18 #define bug printf("****** ") 19 #define mem(a,b) memset(a,b,sizeof(a)) 20 #define name2str(x) #x 21 #define fuck(x) cout<<#x" = "<<x<<endl 22 #define f(a) a*a 23 #define sf(n) scanf("%d", &n) 24 #define sff(a,b) scanf("%d %d", &a, &b) 25 #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c) 26 #define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d) 27 #define pf printf 28 #define FRE(i,a,b) for(i = a; i <= b; i++) 29 #define FREE(i,a,b) for(i = a; i >= b; i--) 30 #define FRL(i,a,b) for(i = a; i < b; i++)+ 31 #define FRLL(i,a,b) for(i = a; i > b; i--) 32 #define FIN freopen("data.txt","r",stdin) 33 #define gcd(a,b) __gcd(a,b) 34 #define lowbit(x) x&-x 35 using namespace std; 36 typedef long long LL; 37 typedef unsigned long long ULL; 38 const int mod = 1e9 + 7; 39 const int maxn = 2e5 + 10; 40 const int INF = 0x3f3f3f3f; 41 const LL INFLL = 0x3f3f3f3f3f3f3f3fLL; 42 int lens, lent; 43 char s[maxn << 1], t[maxn], ss[maxn << 1]; 44 int d[maxn], r[maxn << 1]; 45 46 int Init() { 47 int len = strlen ( s + 1 ); 48 ss[0] = ‘$‘; 49 ss[1] = ‘#‘; 50 int j = 2; 51 for ( int i = 1; i <= len; i++ ) ss[j++] = s[i], ss[j++] = ‘#‘; 52 ss[j] = ‘