Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef long long ll;
- struct VK
- {
- map<char, VK> childs;
- ll uses = 0, depth = 0;
- void operator ++()
- {
- uses++;
- }
- void operator =(ll a)
- {
- depth = a;
- }
- void add(string& str)
- {
- if (str.size() == depth) return;
- char c = str[depth];
- childs[c] = depth + 1;
- childs[c]++;
- childs[c].add[str];
- }
- ll check(string& str)
- {
- char c = str[depth];
- if (str.size() == depth) return (uses == 1);
- return (childs[c].check(str) + (uses == 1));
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement