博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Aizu - ALDS1_4_C Dictionary 散列法搜索
阅读量:3903 次
发布时间:2019-05-23

本文共 1075 字,大约阅读时间需要 3 分钟。

Search III

Your task is to write a program of a simple dictionary which implements the following instructions:

  • insert str: insert a string str in to the dictionary
  • find str: if the distionary contains str, then print 'yes', otherwise print 'no'

Input

In the first line n, the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format.

Output

Print yes or no for each find instruction in a line.

Constraints

  • A string consists of 'A', 'C', 'G', or 'T'
  • 1 ≤ length of a string ≤ 12
  • n ≤ 1000000

Sample Input 1

5insert Ainsert Tinsert Cfind Gfind A

Sample Output 1

noyes

Sample Input 2

13insert AAAinsert AACinsert AGAinsert AGGinsert TTTfind AAAfind CCCfind CCCinsert CCCfind CCCinsert Tfind TTTfind T

Sample Output 2

yesnonoyesyesyes

 代码如下:

#include 
#include
#include
#include
using namespace std;const int maxn=1046527;int n;char s[15];char op[15];char H[maxn][15];int get (char c){ return c=='A'? 1:(c=='T'?2:(c=='G'?3:4));}long long int getKey (){ int sum=0; for (int i=0;i

 

转载地址:http://mpaen.baihongyu.com/

你可能感兴趣的文章
CENTOS 6.5 配置YUM安装NGINX
查看>>
#ifdef DEBUG的理解
查看>>
Linux 任务控制的几个技巧( &, [ctrl]-z, jobs, fg, bg, kill)
查看>>
慧眼云:基于云计算和大数据分析的主动防御实践
查看>>
58集团监控业务实践:将网站运行信息透明化
查看>>
给Django用户的SQLAlchemy介绍
查看>>
consul http api
查看>>
如何定位问题
查看>>
使用火焰图分析CPU性能回退问题
查看>>
openresty lua zlib整合安装 让lua支持解压服务端压缩过的数据
查看>>
Nginx与Gzip请求
查看>>
最佳日志实践(v2.0)
查看>>
logstash日志分析的配置和使用
查看>>
Nginx问题定位之监控进程异常退出
查看>>
https://imququ.com/post/content-encoding-header-in-http.html
查看>>
如何监控 Nginx?
查看>>
字符编码的前世今生
查看>>
视频笔记:Go 抓包、分析、注入 - John Leon
查看>>
matplotlib 画图
查看>>
linux下模拟丢包,延时命令总结
查看>>