MCPcopy Create free account
hub / github.com/Jonathan-Uy/CSES-Solutions / dfs

Function dfs

String Algorithms/Substring Order II.cpp:73–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void dfs(int u, ll k){
74 if(k < 0) return;
75 for(const auto& [c, v] : node[u].nxt){
76 if(node[v].dp <= k) k -= node[v].dp;
77 else {
78 ans.push_back(c);
79 dfs(v, k-node[v].cnt);
80 return;
81 }
82 }
83}
84
85int main(){
86 scanf(" %s %lld", S, &K);

Callers 1

mainFunction · 0.70

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected