MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / count

Method count

code/strings/suffix_automaton.cpp:33–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 link[q] = link[cur] = clone;
32 } } last = cur; }
33 void count(){
34 cnt=vi(sz, -1); stack<ii> S; S.push(ii(0,0));
35 map<char,int>::iterator i;
36 while(!S.empty()){
37 ii cur = S.top(); S.pop();
38 if(cur.second){
39 for(i = next[cur.first].begin();
40 i != next[cur.first].end();++i){
41 cnt[cur.first] += cnt[(*i).second]; } }
42 else if(cnt[cur.first] == -1){
43 cnt[cur.first] = 1; S.push(ii(cur.first, 1));
44 for(i = next[cur.first].begin();
45 i != next[cur.first].end();++i){
46 S.push(ii((*i).second, 0)); } } } }
47 string lexicok(ll k){
48 int st = 0; string res; map<char,int>::iterator i;
49 while(k){

Callers 2

header.cppFile · 0.80
extendMethod · 0.80

Calls 4

pushMethod · 0.45
emptyMethod · 0.45
topMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected