题解 2021 CCPC 威海站 VP记录( 二 )


#include<bits/stdc++.h>using namespace std;typedef long long unsigned ll;#define rep(i,a,b) for(ll i=a;i<=b;++i)#define per(i,a,b) for(ll i=a;i>=b;--i)const ll N=1000005,base=131,mod=212370440130137957ll;ll n,m,k,q,now=0,c[N];char s[N];signed main(){//ios::sync_with_stdio(false);scanf("%s",s+1);n=strlen(s+1);ll a=0,b=0,w=1;for(ll i=1;i<=n;++i){a=(a*base+s[i]);//cout<<a<<" ";b=((w*s[n-i+1])+b);w=(w*base);//cout<<b<<endl;if(a==b)c[i]=++now;else c[i]=now;}//for(ll i=1;i<=n;++i)cout<<c[i]<<" ";cout<<endl;scanf("%lld",&q);for(ll i=1;i<=q;++i){ll x;scanf("%lld",&x);ll mi=min(x,n-x+1)-1;printf("%lld\n",c[mi]);}//cerr<<endl<<"carnation13"<<endl;return 0;}总结:新队伍的第二场vp,比上一场签完到就各种痛苦wa不会写的情况要好一点,五题其实是在三个小时多点的时候完成的,如果是实际比赛可能能出更多的题(可能吧),这个赛季加油了 。

经验总结扩展阅读