1 #include <iostream>
 2 #include <set>
 3 #include <cstdio>
 4 using namespace std;
 5 bool wasAdd[100001];
 6 
 7 int main(){
 8     multiset<int> mset;
 9     int n,x;string order;
10     scanf("%d",&n);
11     while(n --){
12         cin >> order >> x;
13         if(order == "add"){
14             mset.insert(x);
15             wasAdd[x] = true;
16             printf("%d\n",mset.count(x));
17         }
18         else if(order == "del"){
19             printf("%d\n",mset.erase(x));    
20         }
21         else{ //ask
22             int t = wasAdd[x] == false ? 0 : 1;
23             printf("%d ",t); 
24             if(t == 1)  printf("%d\n",mset.count(x));
25             else        printf("0\n");
26         }
27     }
28     return 0;
29 }

 

 1 #include <iostream>
 2 #include <set>
 3 #include <cstdio>
 4 using namespace std;
 5 
 6 int main(){
 7     multiset<int> mset;
 8     set<int> set2;
 9     int n,x;string order;
10     scanf("%d",&n);
11     while(n --){
12         cin >> order >> x;
13         switch(order[1]){
14             case 'd':
15                 mset.insert(x);
16                 set2.insert(x);
17                 printf("%d\n",mset.count(x));
18                 break;
19             case 'e':
20                 printf("%d\n",mset.erase(x));
21                 break;
22             case 's':
23                 int t = set2.find(x) == set2.end() ? 0 : 1;
24                 printf("%d ",t); 
25                 if(t == 1)  printf("%d\n",mset.count(x));
26                 else        printf("0\n");
27                 break;
28         }
29     }
30     return 0;
31 }

 

原文地址:http://www.cnblogs.com/balabalabubalabala/p/16919703.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性