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. 团队合作-如何避免JS冲突

    解决JS冲突的演化过程 1.用匿名函数将脚本包裹起来,可以有效控制全局变量,避免冲突隐患 (function(){})(): 2.定义一个全局作用域的变量str,可以帮助我们在不同匿名函数间通信 严格 ...

  2. AngularJS 控制器通信

    指令与控制器之间通信,无非是以下几种方法: 基于scope继承的方式 基于event传播的方式 service的方式 基于scope继承的方式 最简单的让控制器之间进行通信的方法是通过scope的继承 ...

  3. iOS 读书笔记-国际化

    吐槽一下:国际化-我想说学习的这个project好痛苦. 也许是百度的原因,总是不能找到自己想要东西. 找到的内容不是不具体就是时间有点久了.让我这种小白非常头痛. 以下记录一下整个过程. 国际化是什 ...

  4. oracle 10g下范围分区扫描的几种方式

    oracle 10g下有几种扫描方式,注意最后一种扫描方式,当对分区的列进行计算时,会不走分区.这跟对索引列进行计算会导致无法用索引一样. --扫描单个分区  PARTITION RANGE SING ...

  5. MySQL Study之--MySQL schema_information数据库

    MySQL Study之--MySQL schema_information数据库       information_schema数据库是在mysql的版本号5.0之后产生的,一个虚拟数据库,物理上 ...

  6. Sql去重

    distinct:用于返回唯一不同的值. 注意:1.语句中select显示的字段只能是distinct指定的字段,其他字段是不可能出现的. 2.distinct必须放在开头 如select disti ...

  7. Python笔记·第三章—— 逻辑运算

    一.逻辑运算符的种类及优先级 ▷逻辑运算符包括 not and or  ▷他们的优先级是 () > not > and > or 二.普通逻辑运算 ▷A and B --->  ...

  8. 微信小程序教学第三章第三节(含视频):小程序中级实战教程:视图与数据关联

    § 视图与数据关联 本文配套视频地址: https://v.qq.com/x/page/z0554wyswib.html 开始前请把 ch3-3 分支中的 code/ 目录导入微信开发工具 首先 首先 ...

  9. 教程:安装禅道zentao项目管理软件github上的开发版

    该文章转自:吕滔博客 直接从github拉下来的禅道的源码,是跑不起来的.除非你按我的教程来做...哈哈哈(不要脸)~~~~ 禅道官网提供的版本包是带了有安装文件,并有打包合成一些css.js文件的. ...

  10. 利用aop插入异常日志的2种方式

    AOP是面向切面编程,利用这个技术可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各个部分的耦合性降低,提高代码的可重用性,同时提高开发效率(来自百度百科). Spring AOP有两种实现方式,一 ...