#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;
}
#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;
}
0 回复
0 转发
1 喜欢
2 阅读



