fork(2) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdlib.h>
  4. #include <algorithm>
  5. #include <map>
  6. #include <queue>
  7. #include <iomanip>
  8. #include <string>
  9. #include <math.h>
  10. #include <limits>
  11. #include <map>
  12. #include <float.h>
  13. #include <limits.h>
  14. #include <string.h>
  15. using namespace std;
  16.  
  17. typedef unsigned long long ull;
  18. typedef long long ll;
  19. typedef vector<int> vi;
  20. typedef vector<int> vi;
  21. typedef pair<int, int> ii;
  22. typedef vector<ii> vii;
  23. typedef vector<vii> ADJ;
  24. typedef map<string, int> msi;
  25.  
  26. #define rep(i,a,N) for(int i=a;i<N;++i)
  27. #define TRvii(c,it) for(vii::iterator it=(c).begin();it!=(c).end();it++)
  28. #define TR(c, it) for(typeof(c) it=(c).begin();it!=(c).end();++it )
  29. #define mod 1000000007
  30. #define SIZE 1<<31+10001
  31.  
  32. int main(){
  33. int N,M,count=1,tmp;
  34. char ch;
  35. multimap<int,int> mymap;
  36. scanf("%d %d",&N,&M);
  37. rep(i,0,N){
  38. scanf("%d",&tmp);
  39. mymap.insert(make_pair(tmp,count++));
  40.  
  41. }
  42. while(M--){
  43. scanf(" %c %d",&ch,&tmp);
  44. if(ch=='I'){
  45. mymap.insert(make_pair(tmp,count++));
  46. printf("%d\n",count-1);
  47. }
  48. else if(ch=='S'){
  49. map<int,int>::iterator search;
  50. search = mymap.find(tmp);
  51. if(search!=mymap.end())
  52. printf("%d\n",search->second );
  53. else
  54. printf("NONE\n");
  55. }
  56. else{// D
  57. map<int,int>::iterator search;
  58. search = mymap.find(tmp);
  59. if(search!=mymap.end()){
  60. printf("%d\n",search->second);
  61. mymap.erase(search);
  62. }
  63. else
  64. printf("NONE\n");
  65.  
  66. }
  67. }
  68.  
  69. return 0;
  70. }
Success #stdin #stdout 0s 3432KB
stdin
0 6
S 20
I 3
D 20
D 20
I 2
S 28
stdout
NONE
1
NONE
NONE
2
NONE