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 =(ll a)
- {
- depth = a;
- }
- void add(string& str)
- {
- if (str.size() == depth) return;
- char c = str[depth];
- childs[c] = depth + 1;
- childs[c].uses++;
- childs[c].add(str);
- }
- ll check(string& str)
- {
- if (depth == str.size() && childs.size() > 0) return (-10e6);
- 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