【bzoj 1692】【bzoj 1640】【poj 3617】【poj 3623】Best Cow Line 好牛队 双倍经验水水水
2016-10-30 00:00
281 查看
这破题虐了我一晚上……
读完题就正解了……
一晚上没调出来……
猜猜怎么回事……
我现在仍然在被DQS学长嘲笑……
QAQ……
DQS学长花了五分钟打出来了……
打出来了……
我我我我我我我……
QAQ……
大神为何要虐蒟蒻……
读完题就正解了……
一晚上没调出来……
猜猜怎么回事……
我现在仍然在被DQS学长嘲笑……
QAQ……
DQS学长花了五分钟打出来了……
打出来了……
我我我我我我我……
QAQ……
大神为何要虐蒟蒻……
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cctype> using namespace std; const int MAXN = 100000 + 5; int n,k; int tot; int sa[MAXN],rank[MAXN],tmp[MAXN]; bool cmp_sa(int a,int b) { if(rank[a] != rank[b]) return rank[a] < rank[b]; else { int x = a + k <= n ? rank[a + k] : -1; int y = b + k <= n ? rank[b + k] : -1; return x < y; } } void make_sa(char s[]) { for(int i = 0;i <= n;i ++) { rank[i] = i < n ? s[i] : -1; sa[i] = i; } for(k = 1;k <= n;k <<= 1) { sort(sa,sa + n + 1,cmp_sa); tmp[sa[0]] = 0; for(int i = 1;i <= n;i ++) tmp[sa[i]] = tmp[sa[i - 1]] + cmp_sa(sa[i - 1],sa[i]); for(int i = 0;i <= n;i ++) rank[i] = tmp[i]; } return; } char s[MAXN]; int main() { scanf("%d",&n); int l = 0,r = n - 1; for(int i = 0;i < n;i ++) { char c = getchar(); while(!isalpha(c)) c = getchar(); s[i] = c; } s = 0; for(int i = 1;i <= n;i ++) s[n + i] = s[n - i]; n <<= 1; make_sa(s); while(l <= r) { if(s[l] < s[r])//注意这里不是rank!!!!!!别问我为啥调一晚上!!! { putchar(s[l++]); } else if(s[l] > s[r]) { putchar(s[r--]); } else { if(rank[l] < rank[n - r]) putchar(s[l ++]); else putchar(s[r --]); } tot++; if(tot == 80) tot = 0,puts(""); } return 0; } /* eabbe */
相关文章推荐
- 【bzoj 1692】【bzoj 1640】【poj 3617】【poj 3623】Best Cow Line 好牛队 双倍经验水水水
- bzoj:1692 [Usaco2007 Dec]队列变换&&1640 [Usaco2007 Nov]Best Cow Line 队列变换
- poj 3623 Best Cow Line, Gold (题意和3617一样只要代码中的范围改一下)
- POJ:3617 Best Cow Line
- POJ 3623 Best Cow Line, Gold(贪心)
- POJ 3617 Best Cow Line ||POJ 3069 Saruman's Army贪心
- POJ 3617 best cow line 贪心法
- poj 3623 Best Cow Line, Gold
- POJ 3623 Best Cow Line, Gold(模拟)
- POJ 3617 - Best Cow Line(贪心)
- POJ 3617 Best Cow Line(贪心)
- 1640: [Usaco2007 Nov]Best Cow Line 队列变换 &&&& 1692: [Usaco2007 Dec]队列变换
- poj 3617 Best Cow Line(贪心)
- poj 3617 Best Cow Line 解题报告
- poj 3623 Best Cow Line, Gold
- POj 3617 Best Cow Line
- POJ 3617 Best Cow Line(水)
- poj 3623 Best Cow Line, Gold 暴力枚举
- POJ-3617-Best Cow Line
- POJ 3617 Best Cow Line