Advertisement
Alexvans

Untitled

Sep 3rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <utility>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main () {
  8.     ios_base::sync_with_stdio(0);
  9.     cin.tie(0);
  10.     cout.tie(0);
  11.  
  12.     map<int, string> tree;
  13.  
  14.     int N;
  15.     cin >> N;
  16.  
  17.     for (int i = 1; i <= N; i++) {
  18.         string temp;
  19.         cin >> temp;
  20.         tree.insert( make_pair( i, temp ) );
  21.     }
  22.  
  23.     int M;
  24.     cin >> M;
  25.  
  26.     for (int T = 0; T < M; T++) {
  27.         char op; cin >> op;
  28.         if (op == 'P') {
  29.             int pos; cin >> pos;
  30.             auto it = tree.lower_bound( pos );
  31.             cout << it->second << '\n';
  32.         }
  33.         else if(op == 'M'){
  34.             int pos; cin >> pos;
  35.             auto it = tree.lower_bound( pos );
  36.             tree.erase(it);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement