FIGUREFUL
Don and his friends had some sort of code word to describe the girls who pass towards their class.
Anitha passed - killer told.. “Dude, 5 2 is going”
Chitra passed - Jumbo told.. “Dude, 6 4 is awesome”
Divya passed - Baabi told.. “Machi 1 6 is my dream girl”
Girls couldn’t understand those code words. To crack the code word, girls decide to record all the code words and the girls' name whenever they call.
The silencer in the class watched all these and got angry. He mugged up all the code words, went to teacher and complained about the naughty boys and naughty girls.
Teacher : Who is the girl with code word 1 6?
Silencer: Divya
Teacher: Who is the girl with code word 5 2?
Silencer: Anitha
Teacher: What is the code word for me??
Silencer: (puzzled)
Now you have to pretend that you are the Silencer to solve this problem. Record the code words and answer the questions the teacher asks you.(She may ask the same question any number of times)
Note: There can be any number of code words for a same girl. If there exist more than one girl for a same code word, then that code word belongs to the latest girl.
Input Specification:
The first line contains an integer n, the number of figures. Then in each of the next n lines there will be 2 integers and a figure name.
After that there will be an integer t, the number of test cases. For each test case, there will be two integers representing the code word. Print the figure’s name corresponding to the code word.
Output Specification:
For each test case output the figure name.
Input Constraints:
1<=n<=100000
1<=t<=100000
-1000000<=code1, code2<=1000000
The figure’s name will not exceed 20 characters
Sample Input:
6
5 2 Anitha
6 4 Yamuna
6 4 Chitra
1 6 Divya
-2 0 Teacher
7 4 Anitha
2
-2 0
6 4
Sample Output:
Teacher
Chitra
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+15;
map<int,map<int,string> >m;
map<int,string> mm;
int main(){
int t,n; int i,j,k;
scanf("%d",&t);
while(t--){
string name;
scanf("%d%d",&i,&j);
cin>>name;
(m[i])[j]=name;
}
scanf("%d",&n);
while(n--){
scanf("%d %d",&i,&j);
cout<<m[i][j]<<endl;
}
return 0;
}
参考:https://blog.csdn.net/intelligentgirl/article/details/88710500