字典额外UI哦

你的任务是编写一个简单的字典程序,它实现以下指令:
insert str:在字典中插入一个字符串str。
find str:如果字典包含str,则打印'yes',否则打印'no'。
输入
在第一行 n 中,给出了指令的数量。
在接下来的 n 行中,n 条指令以上述格式给出。
输出
为一行中的每个查找指令打印"yes"或"no"。
约束
字符串由“A”、“C”、“G”或“T”组成
1 ≤ 字符串长度 ≤ 12
n ≤ 1000000

输入样例

 

13 insert AAA insert AAC insert AGA insert AGG insert TTT find AAA find CCC find CCC insert CCC find CCC insert T find TTT find T

输出样例

 

yes no no yes yes yes

#include<stdio.h>
#include<iostream>
using namespace std;
#include<string>
#include<string.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
const int maxn=100005;
typedef long long ll;
int main()
{
    char zifu[20];
    char zhiling[20];
    ll t;
    cin>>t;
    set<string>s;
    while(t--)
    {
        cin>>zhiling>>zifu;
        if(zhiling[0]=='i')
            {
                s.insert(zifu);
            }
        else if(zhiling[0]=='f')
            {
                if(s.find(zifu)!=s.end())
                    cout<<"yes"<<endl;
                else 
                    cout<<"no"<<endl;    
            }    
    }
    return 0;
}

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值