Pagini recente » Cod sursa (job #159960) | Cod sursa (job #1423624) | Profil tvlad | Cod sursa (job #1982293) | Cod sursa (job #3274703)
#include <fstream>
#include <string.h>
#include <map>
using namespace std;
ifstream cin ("trie.in");
ofstream cout ("trie.out");
int long long c,x,mod=1000000009,l,n;
map<int,int>m1;
map<int,int>m2;
char s[30];
int main()
{
while (cin>>c)
{
cin>>s;
n=strlen(s);
x=l=0;
for (int i=0; i<n; i++)
{
x=x*31+(s[i]-'a'+1);
x=x%mod;
if (c==0) m1[x]++;
if (c==1) m1[x]--;
if (c==3 && m1[x]) l++;
}
if (c==0) m2[x]++;
if (c==1) m2[x]--;
if (c==2) cout<<m2[x]<<'\n';
if (c==3) cout<<l<<'\n';
}
return 0;
}