@lychee123
2017-10-02T21:44:08.000000Z
字数 612
阅读 998
STL
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i,j;
char s[44];
scanf("%d",&t);
map<string,set<string> >mp;
while(t--)
{
scanf("%s",s);
if(s[0]=='H')
{
int ans=mp.size();
printf("%d\n",ans);
}
else if(s[0]=='J')
{
scanf("%s",s);
char *pos=strstr(s,"]");
///strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串。如果是,则该函数返回str2在str1中首次出现的地址;否则,返回NULL。
string school(s+1,pos);
string name(pos+1,s+strlen(s));
mp[school].insert(name);
}
else
{
scanf("%s",s);
char *pos=strstr(s,"]");
string school(s+1,pos);
string name(pos+1,s+strlen(s));
mp[school].erase(name);
if(mp[school].size()==0)
mp.erase(school);
}
}
return 0;
}