FIGUREFUL(map)

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

习惯了用scanf输入,这里数据量不大,用cin或者scanf都行,区别不大

#include<iostream>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n,t,c1,c2;
    char len[21];
    string s;
    scanf("%d",&n);
    map<pair<int,int>,string >m;
    pair<int,int>p;
    while(n--)
    {
        scanf("%d %d",&c1,&c2);
        getchar();
        gets(len);
        s=len;
        p=make_pair(c1,c2);//#1
        m[p]=s;//#2
        /*#1#2另一种表达
        m[c1][c2]=s*/
        
    }
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&c1,&c2);
        p=make_pair(c1,c2);//#1
        cout<<m[p]<<endl;//#2
        /*#1#2另一种表达
        cout<<m[c1][c2]<<endl;*/
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值