intgetnum(char x) { if (x >= 'A' && x <= 'Z') { return x - 'A'; } elseif (x >= 'a' && x <= 'z') { return x - 'a' + 26; } else { return x - '0' + 52; } }
voidinsert(string s) { int p = 0, len = s.size(); for (int i = 0; i < len; i++) { int c = getnum(s[i]); if (!trie[p][c]) { trie[p][c] = ++cnt; } p = trie[p][c]; exist[p]++; } }
intfind(string s) { int p = 0, len = s.size(); for (int i = 0; i < len; i++) { int c = getnum(s[i]); if (!trie[p][c]) { return0; } p = trie[p][c]; } return exist[p]; }
int q, n, nex[500010][65], exist[500010], cnt; string s;
intgetnum(char x) { if (x >= 'A' && x <= 'Z') { return x - 'A'; } elseif (x >= 'a' && x <= 'z') { return x - 'a' + 26; } else { return x - '0' + 52; } }
voidinsert(string s) { int p = 0, len = s.size(); for (int i = 0; i < len; i++) { int c = getnum(s[i]); if (!nex[p][c]) { nex[p][c] = ++cnt; } p = nex[p][c]; } exist[p]++; }
intfind(string s) { int p = 0, len = s.size(); for (int i = 0; i < len; i++) { int c = getnum(s[i]); if (!nex[p][c]) { return0; } p = nex[p][c]; } return exist[p]; }
voidsolve() { cin >> n; for (int i = 1; i <= n; i++) { cin >> s; insert(s); } cin >> q; map<string, int> mp; for (int i = 1; i <= q; i++) { cin >> s; int k = find(s); if (mp.find(s) != mp.end()) { cout << "REPEAT" << endl; } elseif (k == 1) { cout << "OK" << endl; mp[s]++; } elseif (k == 0) { cout << "WRONG" << endl; } } return; }
voidinsert(int num) { int p = 0; for (int i = 30; i >= 0; i--) { int c = (num >> i) & 1; if (!nex[p][c]) { nex[p][c] = ++cnt; } p = nex[p][c]; } return; }
intfind(int num) { int p = 0; int ans = 0; for (int i = 30; i >= 0; i--) { int c = (num >> i) & 1; if (nex[p][!c]) { ans = ans * 2 + 1; p = nex[p][!c]; } else { ans *= 2; p = nex[p][c]; } } return ans; }
voidsolve() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; insert(a[i]); } int mymax = 0; for (int i = 1; i <= n; i++) { mymax = max(find(a[i]), mymax); } cout << mymax << endl; return; }