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