Pagini recente » Cod sursa (job #1424394) | Cod sursa (job #1757305) | Cod sursa (job #1720719) | Cod sursa (job #1230841) | Cod sursa (job #3246002)
#include <bits/stdc++.h>
const std :: string FILENAME = "";
std :: ifstream in (FILENAME + ".in");
std :: ofstream out (FILENAME + ".out");
struct nod
{
int fr = 0;
nod * st = nullptr;
nod * dr = nullptr;
};
int n;
int cer;
int x;
int y;
std :: string s;
std :: string to_string(int x)
{
std :: string aux = "";
while(x)
{
if(x % 2 == 1)
{
aux += '1';
}
else
{
aux += '0';
}
x /= 2;
}
while(aux.size() < 26)
{
aux += '0';
}
return aux;
}
void add(nod * & trie, int poz)
{
trie -> fr ++;
if(poz < s.size())
{
if(s[poz] == '0')
{
if(trie -> st == nullptr)
{
trie -> st = new nod;
}
add(trie -> st, poz + 1);
}
else
{
if(trie -> dr == nullptr)
{
trie -> dr = new nod;
}
add(trie -> dr, poz + 1);
}
}
}
void rem(nod * & trie, int poz)
{
trie -> fr --;
if(poz < s.size())
{
if(s[poz] == '0')
{
rem(trie -> st, poz + 1);
}
else
{
rem(trie -> dr, poz + 1);
}
}
}
int query(nod * trie, int poz)
{
if(poz < s.size())
{
if(s[poz] == '0')
{
if(trie -> dr -> fr && trie -> st -> fr)
{
if(cnt )
}
else if(trie -> dr -> fr)
{
}
else
{
}
}
else
{
if(trie -> st)
{
}
else
{
}
}
}
}
int main()
{
std :: ios_base :: sync_with_stdio(false);
std :: cin.tie(NULL);
nod * trie = new nod;
std :: cin >> n;
for(int i = 1; i <= n; i ++)
{
std :: cin >> cer;
if(cer == 1)
{
std :: cin >> x;
s = to_string(x);
add(trie, 0);
}
else if(cer == 2)
{
std :: cin >> x;
s = to_string(x);
rem(trie, 0);
}
else
{
std :: cin >> x >> y;
s = to_string(x);
std :: cout << query(trie, 0) << '\n';
}
}
return 0;
}