#include using namespace std; typedef unsigned int uint; typedef long long int ll; typedef unsigned long long int ull; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<>=1,k++)s=(s<<1)|(u&1);for(;0>=1)cout<<(s&1);}} #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) template ostream& operator <<(ostream &o,const pair p){o<<"("< radius; manacher(){} manacher(const string& str){make(str);} void make(const string& str){ // TODO:ざっくりとしか理解してないのでほぼコピペ // http://snuke.hatenablog.com/entry/2014/12/02/235837 // abaaaa int length = str.size()*2-1; radius.resize(length); int c = 0; for (int i = 0; i < length; i++) { int l = c - (i-c); if (i+radius[l] < c+radius[c]) { radius[i] = radius[l]; } else { int j = c+radius[c] - i; for (;i-j >= 0 && i+j < length ; j++){ if (((i^j)&1)==1) continue; if (str[(i-j)/2] != str[(i+j)/2]) break; } radius[i] = j; c = i; } } } int operator[](int idx) const{ return radius[idx]; } size_t size() const{ return radius.size(); } void print(const string& str){ for (int i=0;i= i-index+1){ result += calc3(i-index+i+2); } } return result; } // 1st P ll calc1(){ int i; ll result = 0; for (i=0;i> str; manatee.make(str); //manatee.print(str); gen_back_imos(); //debuga(back_imos,29); cout << calc1() << endl; return 0; }