版本比较
题解:P9016 [USACO23JAN] Find and Replace G
正文
增加 10 行删除 10 行
25 行未改动262728293030313233343536373838394040414243444545464748496 行未改动5657585960606162636452 行未改动1171181191201211211221231241251261271281291301311311321331331341351361371381381391401411426 行未改动14915015115215315315415515615711 行未改动25 行未改动 long long n2=now; add(now,siz[to[x][i]]); if(now>=l){ if(!to[x][i])cout<<s[x][i]; else dfs(to[x][i],n2); else dfs(to[x][i],n2); } }}int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin>>l>>r>>n;
siz[0]=1;
s[1]="a"; to[1].push_back(0); q[0].push({1,0}); n++;
for(int i=2;i<=n;i++){ char c; cin>>c>>s[i]; to[i].resize(s[i].size());6 行未改动 for(int j=0;j<s[i].size();j++){ q[s[i][j]-'a'].push({i,j}); } }
for(int i=n;i>=1;i--){ for(int j:to[i]){ add(siz[i],siz[j]); }52 行未改动 if(now>=l){ if(!to[x][i]){ ans+=s[x][i]; } else dfs(to[x][i],n2); else dfs(to[x][i],n2); } } int ed=ans.size(); if(_)mem[x]={st,ed-st};}int main(){ cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin>>l>>r>>n;
siz[0]=1;
s[1]="a"; to[1].push_back(0); q[0].push({1,0}); n++;
for(int i=2;i<=n;i++){ char c; cin>>c>>s[i]; to[i].resize(s[i].size());6 行未改动 for(int j=0;j<s[i].size();j++){ q[s[i][j]-'a'].push({i,j}); } }
for(int i=n;i>=1;i--){ for(int j:to[i]){ add(siz[i],siz[j]); }11 行未改动