/
itp2_8d.cpp
39 lines (38 loc) · 937 Bytes
/
itp2_8d.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ITP2 8_D
// C++14
#include <bits/stdc++.h>
using namespace std;
int main() {
multimap<string, int> M;
int Q; cin >> Q;
for (int i = 0; i < Q; i++) {
int q; cin >> q;
if (q == 0) {
string key; cin >> key;
int x; cin >> x;
M.insert(make_pair(key, x));
}
if (q == 1) {
string key; cin >> key;
auto l = M.lower_bound(key);
auto r = M.upper_bound(key);
for (auto iter = l; iter != r; iter++) {
cout << (*iter).second << endl;
// cout << iter->second << endl;
}
}
if (q == 2) {
string key; cin >> key;
M.erase(key);
}
if (q == 3) {
string L, R; cin >> L >> R;
auto l = M.lower_bound(L);
auto r = M.upper_bound(R);
for (auto iter = l; iter != r; iter++) {
cout << (*iter).first << " " << (*iter).second << endl;
// cout << iter->first << " " << iter->second << endl;
}
}
}
}