Our friend Monk has been made teacher for the day today by his school professors . He is going to teach informatics to his colleagues as that is his favorite subject . Before entering the class, Monk realized that he does not remember the names of all his colleagues clearly . He thinks this will cause problems and will not allow him to teach the class well. However, Monk remembers the roll number of all his colleagues very well . Monk now wants you to help him out. He will initially give you a list indicating the name and roll number of all his colleagues. When he enters the class he will give you the roll number of any of his colleagues belonging to the class. You need to revert to him with the name of that colleague.

Input Format

The first line contains a single integers NN denoting the number of Monk's colleagues. Each of the next NN lines contains an integer and a String denoting the roll number and name of the ii th colleague of Monk. The next Line contains a single integer qq denoting the number of queries Monk shall present to you when he starts teaching in class. Each of the next qq lines contains a single integer xx denoting the roll number of the student whose name Monk wants to know.

Output Format

You need to print qq Strings, each String on a new line, indicating the answers to each of Monk's queries.

Constrains

1≤N≤1051≤N≤105

1≤RollNumber≤1091≤RollNumber≤109

1≤|Name|≤251≤|Name|≤25

1≤q≤1041≤q≤104

1≤x≤1091≤x≤109

Note

The name of each student shall consist of lowercase English alphabets only. It is guaranteed that the roll number appearing in each query shall belong to some student from the class.

其实就是用到了golang 数据集合map,貌似Map的性能不是太好

package main

import "fmt"

func main() {
//fmt.Println("Hello World!")
mapDic := make(map[int]string) var mapCount int fmt.Scanln(&mapCount)
var key int
var value string
for i:=0;i<mapCount;i++{
fmt.Scanln(&key, &value)
mapDic[key] = value
} var searchCount int
fmt.Scanln(&searchCount)
var searchKey int
for j:=0;j<searchCount;j++{
fmt.Scanln(&searchKey)
fmt.Println(mapDic[searchKey])
} }

  

golang map的更多相关文章

  1. 【GoLang】GoLang map 非线程安全 & 并发度写优化

    Catena (时序存储引擎)中有一个函数的实现备受争议,它从 map 中根据指定的 name 获取一个 metricSource.每一次插入操作都会至少调用一次这个函数,现实场景中该函数调用更是频繁 ...

  2. golang map输出排序

    由于GoLang Map 内部存储是无序的,当需要按顺序获得map存储的key -value值时,应该对遍历出来的结果进行重新排序: 在go 1.8版本后,提供的slice sort 功能使排序更简单 ...

  3. Golang Map实现(一)

    本文学习 Golang 的 Map 数据结构,以及map buckets 的数据组织结构. hash 表是什么 从大学的课本里面,我们学到:hash 表其实就是将key 通过hash算法映射到数组的某 ...

  4. Golang Map实现(四) map 的赋值和扩容

    title: Golang Map 实现 (四) date: 2020-04-28 18:20:30 tags: golang map 操作,是map 实现中较复杂的逻辑.因为当赋值时,为了减少has ...

  5. golang map getkeys

    golang 获取map的keys package main import "fmt" import "reflect" func main() { abc : ...

  6. golang map 读写锁与深度拷贝的坑

    0X01 golang中,map(字典)无法并发读写 简单来说,新建万条线程对同一个map又读又写,会报错. 为此,最好加锁,其实性能影响并不明显. type taskCache struct{ sy ...

  7. Golang map 如何进行删除操作?

    Cyeam 关注 2017.11.02 10:02* 字数 372 阅读 2784评论 0喜欢 3 map 的删除操作 Golang 内置了哈希表,总体上是使用哈希链表实现的,如果出现哈希冲突,就把冲 ...

  8. Golang map并发 读写锁

    golang并发 一:只有写操作 var ( count int l = sync.Mutex{} m = make(map[int]int) ) //全局变量并发写 导致计数错误 func vari ...

  9. Golang Map Addressability

    http://wangzhezhe.github.io/blog/2016/01/22/golangmapaddressability-dot-md/ 在golang中关于map可达性的问题(addr ...

随机推荐

  1. JaveScript变量的简介及其变量的简单使用(JS知识点归纳一)

    变量简介 "变量是一个容器" 为什么要有变量? 程序的执行过程中,会使用到许多的数据(用户输入的内容,动态效果的运动数据等),当这些数据需要重复在多个地方使用的时候,就需要一个容器 ...

  2. 【new File(String Path)加载资源问题】

    2017-12-17   15:07:38  [原创-wx] 一.我们在用IO流加载资源的时候,创建文件资源 1 File file = New File("String Path" ...

  3. TP3.2 图片上传及缩略图

    基于TP自带的上传文件的类, Think/Upload.class.php 设置表单的enctype属性 下面是上传的具体方法 /** * 图片上传处理 * @param [String] $path ...

  4. 探索版 webstorm快捷方式

    ctrl + alt + s            打开配置面板 Settings   国内的资料比较少,大概很多人已经放弃了原生快捷方式,不过我打算通关原生快捷方式.   在配置面板中  IDE S ...

  5. 安装phpnow服务[Apache_pn]提示失败的解决方法

    win 7/win 8/Win10 phpnow提示"安装服务[Apache_pn]失败"错误解决办法汇总 常常在安装phpnow的时候,提示"安装服务 [ Apache_pn ] 失败&q ...

  6. SDUTOJ 贪心 -商人小鑫

    题目描写叙述 小鑫是个商人,当然商人最希望的就是多赚钱.小鑫也一样. 这天,他来到了一个遥远的国度.那里有着n件商品,对于第i件商品须要付出ci的价钱才干得到. 当然.对于第i件商品,小鑫在自己心中有 ...

  7. char a[] = "ab\0123\098"; 求a的长度

      原因: \0表示后面的字符是八进制(\ddd); 8进制=10进制( 10是'\n' 的ASCII码): 当\0后面有数字,且数字范围在0~7之间时,为8进制转义.如'\012': 当\0后面没有 ...

  8. XMind常用快捷方式汇总

    快捷键(Windows) 快捷键(Mac) 描述 Ctrl+N Command+N 建立新工作簿 Ctrl+O Command+O 开启工作簿 Ctrl+S Command+S 储存目前工作簿 Ctr ...

  9. mybatis关联

    title: mybatis关联 date: 2017-12-18 18:00:30 tags: - [mybatis] categories: - [编程] - [开发工具] permalink: ...

  10. 项目管理: Alpha,Beta,RC,GA,Release

    Alpha:                    Alpha是内部测试版,一般不向外部发布.也可以认为是演示版本.允许存在一定的问题(例如功能组合.异常流程处理.稳定性.性能存在部分问题)      ...