-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0008.cpp
More file actions
37 lines (35 loc) · 728 Bytes
/
Copy path0008.cpp
File metadata and controls
37 lines (35 loc) · 728 Bytes
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
#include <set>
#include <iostream>
#include <string>
using namespace std;
// 在此处补充你的代码
class myComp{
public:
bool operator()(const pair<int,int>& p1,const pair<int,int>& p2){
return p1.first + p1.second < p2.first + p2.second;
}
};
int main() {
string cmd;
set<pair<int, int>, myComp> S;
while (cin >> cmd) {
if (cmd == "A") {
int x, y;
cin >> x >> y;
S.insert(make_pair(x, y));
} else if (cmd == "Qx") {
int x;
cin >> x;
cout << S.lower_bound(make_pair(x, -1))->second << endl;
} else if (cmd == "Qy") {
int y;
cin >> y;
cout << S.lower_bound(make_pair(-1, y))->first << endl;
} else {
int x, y;
cin >> x >> y;
S.erase(make_pair(x, y));
}
}
return 0;
}