https://codeforces.com/contest/1234/problem/D
Wrote a stupid giant tree line (indeed the garbage), it is necessary to remind yourself this question how do
#include<iostream> #include<cstdio> #include<string> #include<set> #include<algorithm> using namespace std; const int maxn = 32; set<int> st[maxn]; int main() { string words; cin>>words; words = '.' + words; int len = words.size() - 1; for(int i=1;i<=len;++i) st[words[i]-'a'].insert(i); int q,cmd,pos,l,r; char ch; scanf("%d",&q); for(int k=0;k!=q;++k) { scanf("%d",&cmd); if(cmd==1) { scanf("%d",&pos); getchar(); Scanf ( "% C", & CH); ST [words [POS] - 'A'] ERASE (POS);. words [POS] = CH; . ST [words [POS] - 'A'] INSERT (POS) ; } the else { int ANS = 0; Scanf ( "% D% D", & L, & R & lt); for (int I = 0; I = 26 is;! ++ I) { Auto IT = ST [I] .lower_bound ( l); // MDZZ no longer direct use of a dichotomy algorithm, much faster in the container, a Buddha IF (ST IT == [I] .end ()) Continue; l // find the start character or greater , because they do not repeat, so only you need to find a like (ORZ) int = X * IT; IF (X <= R & lt) ++ ANS; } COUT ANS << << '\ n-'; } } }
If I refuse, crying friends