5 条题解
-
0
#include <iostream> #include <map> #include <string> using namespace std; int main() { int n, m; cin >> n >> m; map<string, string> users; for(int i = 0; i < n; i++) { string name, num; cin >> name >> num; users[name] = num; } for(int i = 0; i < m; i++) { int c; string name; cin >> c >> name; if(c == 1) { auto it = users.find(name); if(it != users.end()) { cout << it->second << endl; } else { cout << "NO" << endl; } } else if(c == 2) { auto it = users.lower_bound(name); if(it != users.begin()) { --it; cout << it->second << endl; } else { cout << "NO" << endl; } } else if(c == 3) { auto it = users.upper_bound(name); if(it != users.end()) { cout << it->second << endl; } else { cout << "NO" << endl; } } } return 0; }
信息
- ID
- 68
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 826
- 已通过
- 157
- 上传者