HYSBZ 2160 拉拉隊排練 回文樹

2021-09-25 15:02:29 字數 939 閱讀 4353

題意:前k長的 奇數長度 的回文串 長度的乘積

題解:因為k很大,所以我們儲存,每個本質不同字串的長度和數量,然後排序,從大到小列舉一遍即可

#include using namespace std;

const int n = 1000010;

typedef long long ll;

struct pt

// 初始化

void init()

// 失配後找乙個盡可能長的

int get_fail(int x)

void add(int c)

last = nex[cur][c];

cnt[last]++;

sum += num[last];

} void count()

}a;char s[n];

int slen;

struct node

bool operator <(const node &b) const

}b[n];

int len;

bool cmp(int x, int y)

ll ksm(ll x, ll y, ll mod) return res;}

int mod;

ll k;

int main()

len = 0;

a.count();

for(int i = 2; i < a.p; i++)

} sort(b + 1, b + 1 + len);

ll res = 1;

for(int i = 1; i <= len; i++)

if(k) res = -1;

printf("%lld\n", res); }

return 0;

}

HYSBZ 2160 拉拉隊排練(回文樹)

time limit 10 sec memory limit 259 mb submit 825 solved 324 submit status discuss 艾利斯頓商學院籃球隊要參加一年一度的市籃球比賽了。拉拉隊是籃球比賽的乙個看點,好的拉拉隊往往能幫助球隊增加士氣,贏得最終的比賽。所以作為...

HYSBZ 2160 拉拉隊排練 回文自動機

題目大意 給出乙個字串 s 和乙個整數 k,現在要求出所有長度為奇數的回文子串從大到小開始數前 k 個回文子串的長度的乘積 題目分析 回文自動機跑一遍字串 s 後把長度為奇數的結點的長度和出現次數拿出來,配合上快速冪遍歷一遍求答案就好了 include include include include...

BZOJ 2160 拉拉隊排練

time limit 10 sec memory limit 259 mb submit 832 solved 326 submit status discuss 艾利斯頓商學院籃球隊要參加一年一度的市籃球比賽了。拉拉隊是籃球比賽的乙個看點,好的拉拉隊往往能幫助球隊增加士氣,贏得最終的比賽。所以作為...