text
stringlengths
49
983k
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> com(n),str(n); set<string> dic; for(int i=0;i<n;i++){ string com,str; cin >> com >> str; if(com[0] == 'i')dic.insert(str); else { auto res = dic.find(str); cout << ((res != dic.end())?"yes":"no") << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string str; set<string> dic; ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> str; if (str == "insert") { cin >> str; dic.insert(str); } else if (str == "find") { cin >> str; cout << (dic.find(str) != dic.end() ? "yes" : "no") << endl; } } return 0; }
#include<iostream> #include<string> #include<set> #include<algorithm> using namespace std; int main(){ int n; set<string> data; cin >> n; for(int i=0;i<n;i++){ string order,inp; cin >> order >> inp; if(order=="insert") data.insert(inp); else cout << (data.find(inp) != data.end() ? "yes" : "no") << endl; } }
#include <iostream> #include <set> using namespace std; int main() { int n; cin >> n; set<string> S; for (int i = 0; i < n; i++) { string cmd, str; cin >> cmd >> str; if(cmd == "insert") { S.insert(str); } else if (cmd == "find") { if(S.find(str) != S.end()){ cout << "yes" << endl; } else { cout << "no" << endl; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d", &n); string cmd, str; set<string> s; for(int i = 0; i < n; i++) { cin >> cmd >> str; if(cmd == "insert") s.insert(str); else if(cmd == "find") printf("%s\n", (s.find(str) != s.end()) ? "yes" : "no"); } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); map <string, int> M; int n; cin >> n; for (int i = 0; i < n; i++) { string s, t; cin >> s >> t; if (s == "insert") M[t] = 1; else cout << (M[t] ? "yes" : "no") << '\n'; } return 0; }
#include <iostream> #include <set> using namespace std; int main() { set<string> S; int n; cin >> n; while (n--) { string com, word; cin >> com >> word; if (com[0] == 'i') { S.insert(word); } else { cout << (S.count(word) ? "yes" : "no") << endl; } } return 0; }
#include <iostream> #include <set> using namespace std; int main(){ int n; cin >> n; set<string> st; for(int i = 0; i < n; i++){ string s,t; cin >> s >> t; if(s == "insert") st.insert(t); else{ if(st.count(t)) cout << "yes\n"; else cout << "no\n"; } } return 0; }
#include <iostream> #include <cstdio> #include <string> #include <set> using namespace std; int main() { int n; string com,word; set<string> dic; scanf("%d",&n); for(int i=0; i<n; ++i) { cin >> com >> word; if(com=="insert") { dic.insert(word); } else if(com=="find") { if(dic.find(word)!=dic.end()) { printf("yes\n"); } else { printf("no\n"); } } } return 0; }
#include<bits/stdc++.h> using namespace std; set<string> dic; int main() { int n; string s1,s2; cin >> n; for(int i=0;i<n;i++){ cin >> s1 >> s2; if(s1.length() == 6){ dic.insert(s2); }else{ set<string>::iterator it = dic.find(s2); if(it == dic.end()){ cout << "no" << "\n"; }else{ cout << "yes" << "\n"; } } } }
#include <stdio.h> #include <string.h> int n; bool used[22370000]; char com[7], s[13]; int main() { scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%s %s", com, s); int h = 0, l = strlen(s); for(int j = 0; j < l; j++) { h *= 4; if(s[j] > 'A') h++; if(s[j] > 'C') h++; if(s[j] > 'G') h++; } h += (1 << (2 * l)); if(com[0] == 'i') used[h] = true; else puts(used[h] ? "yes" : "no"); } }
#include <string> #include <set> #include <iostream> using namespace std; int main() { int n; string cmd; set<string> dic; cin>>n; for(int i=0;i<n;i++) { cin>>cmd; if(cmd=="insert") { string temp; cin>>temp; dic.insert(temp); } else if(cmd=="find") { string temp; cin>>temp; if(dic.count(temp)==0) cout<<"no"<<endl; else cout<<"yes"<<endl; } } }
#include <iostream> #include <unordered_set> #include <string> int main(){ std::unordered_set<std::string> s; int n; std::cin >> n; std::string command, str; for(int i=0; i<n; ++i){ std::cin >> command >> str; if(command == "insert"){ s.insert(str); }else{ std::cout << ((s.count(str) == 1) ? "yes" : "no") << std::endl; } } }
#include <bits/stdc++.h> using namespace std; int main(){ map<string,bool> dict; int n; char com[10],key[13]; scanf("%d",&n); for(int i = 0; i < n ; i++){ scanf("%s %s",com,key); if(com[0]=='i'){ dict[string(key)] = true; }else if(com[0] == 'f'){ if(dict[string(key)]){ printf("yes\n"); }else{ printf("no\n"); } } } }
#include<string> #include<iostream> #include<algorithm> #include<set> using namespace std; int main(){ std::ios_base::sync_with_stdio(false); set<string> st; int n; cin >> n; while(n--){ string BUFF,c; cin >> BUFF >> c; if(BUFF=="insert")st.insert(c); else cout << (st.find(c)!=st.end()?"yes":"no") << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { set<string> dict; int n; cin >> n; string com, key; for (int i = 0; i < n; i++) { cin >> com >> key; if (com[0] == 'i') { dict.insert(key); } else { if (dict.count(key)) { cout << "yes" << endl; } else { cout << "no" << endl; } } } }
#include <stdio.h> #include <string.h> int n, r[128]; bool used[22370000]; char com[7], s[13]; int main() { scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3; for(int i = 0; i < n; i++) { scanf("%s %s", com, s); int h = 0, l = strlen(s); for(int j = 0; j < l; j++) h = h * 4 + r[s[j]]; for(int j = 0; j < l; j++) h += 1 << (2 * l); if(com[0] == 105) used[h] = true; else puts(used[h] ? "yes" : "no"); } }
#include <iostream> #include <map> using namespace std; int main () { map<string, bool> M; //輸入 int n; cin >> n; while(n--) { //輸入 string cmd, str; cin >> cmd >> str; //處理 if (cmd == "insert") { M[str] = true; } else { //輸出 if (M[str]) cout << "yes\n"; else cout << "no\n"; } } return 0; }
#include<map> #include<iostream> #include<string> int main(){ int num; std::cin >> num; std::map<std::string,int> dic; for(int i=0;i<num;i++){ std::string process,key; std::cin >> process >> key; if(process[0]=='i'){ dic[key]=1; }else{ if(dic[key]==0){ std::cout << "no" << std::endl; }else{ std::cout << "yes" << std::endl; } } } return 0; }
#include <iostream> #include <unordered_set> #include <algorithm> #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; int n; unordered_set<string> s; int main(){ ios_base::sync_with_stdio(false); cin >> n; rep(i, n){ string c, d; cin >> c >> d; if(c == "insert"){ s.insert(d); } else{ cout << (s.find(d) != s.end() ? "yes" : "no") << endl; } } return 0; }
#include <iostream> #include <string> #include <set> using namespace std; typedef set<string> set_t; set_t A; int main() { int n; string cmd,word; cin >> n; for(int i=0;i<n;i++) { cin >> cmd >> word; if (cmd == "insert") { A.insert(word); } if (cmd == "find") { if (A.count(word)==1) { cout << "yes" << endl; } else { cout << "no" << endl; } } } return 0; }
#include<iostream> #include<string> #include<set> int main() { std::string cmd, str; std::set<std::string> mp; int n, i; std::cin >> n; for (i = 0; i < n; i++) { std::cin >> cmd >> str; if (cmd == "insert") mp.insert(str); else if (cmd == "find") { if (mp.count(str) > 0) std::cout << "yes\n"; else std::cout << "no\n"; } } return 0; }
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for(int i=0;i<(n);i++) int n; string order; set<string> A; string str; int main() { cin >> n; rep(i, n) { cin >> order>>str; if (order == "insert") A.insert(str); else if (order == "find") { int ans = A.count(str); if (ans == 1) cout << "yes" << endl; else cout << "no" << endl; } } return 0; }
#include <iostream> #include <set> #include <string> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; set<string> st; while(n--){ string order; string str; cin>>order; cin>>str; if(order=="insert"){ st.insert(str); }else{ if(st.find(str)!=st.end()){ cout<<"yes"<<endl; }else{ cout<<"no"<<endl; } } } return 0; }
#include<bits/stdc++.h> using namespace std; int main(void){ int n; string s,t; set<string>ss; int i; cin>>n; for(i=0;i<n;i++){ cin>>s>>t; if(s=="insert") ss.insert(t); else{ auto it=ss.find(t); cout<<((it!=ss.end())?"yes":"no")<<endl; } } return 0; }
#include<iostream> #include<string> #include<set> using namespace std; int main(){ int n; string a,b; set<string> st; cin>>n; while(n--){ cin>>a>>b; if(a=="insert")st.insert(b); if(a=="find"){ if(st.find(b)==st.end())cout<<"no"<<endl; else cout<<"yes"<<endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> m; for( int i = 0; i < n; i++ ) { string cmd, str; cin >> cmd >> str; if( cmd == "insert" ) { m[str]++; } else { string ans = "yes"; if( m.count( str ) == 0 ) { ans = "no"; } cout << ans << endl; } } }
#include<iostream> #include<cstdio> #include<string> #include<map> using namespace std; int main() { int n; char str[10], com[13]; map<string, bool> t; cin >> n; for (int i = 0; i < n; i++) { cin >> com; if (com[0] == 'i') { cin >> str; t[string(str)] = true; } else { cin >> str; if (t[str]) cout << "yes\n"; else cout << "no\n"; } } return 0; }
#include <stdio.h> #include <string.h> int n, r[128]; bool used[22370000]; char com[7], s[13]; int main() { scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3; for(int i = 0; i < n; i++) { scanf("%s %s", com, s); int h = 0, l = strlen(s); for(int j = 0; j < l; j++) h = (h << 2) + r[s[j]]; h += (1 << (2 * l)); if(com[0] == 'i') used[h] = true; else puts(used[h] ? "yes" : "no"); } }
#include <bits/stdc++.h> using namespace std; int main(){ set<string>st; int n; cin>>n; while(n--){ string s,t; cin>>s>>t; if(s=="insert")st.insert(t); else cout<<(st.count(t)?"yes":"no")<<endl; } }
#include<iostream> #include<string> #include<set> using namespace std; int main(){ set<string>s; int n; cin >> n; for (int i = 0; i < n; i++){ string a, b; cin >> a >> b; if (a[0] == 'i') s.insert(b); else{ if (s.find(b) != s.end())cout << "yes\n"; else cout << "no\n"; } } }
#include <bits/stdc++.h> using namespace std; int main() { set< string > dict; int n; cin >> n; char buf1[128], buf2[128]; for (int i = 0; i < n; ++i) { scanf("%s %s", buf1, buf2); string op(buf1), str(buf2); if (op == "insert") { dict.insert(str); } if (op == "find") { if (dict.count(str)) puts("yes"); else puts("no"); } } }
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int n; cin >> n; map<string, int> mp; for (int i = 0; i < n; ++i) { string com, str; cin >> com >> str; if (com[0] == 'i') mp[str]++; else { if (mp[str] > 0) cout << "yes" << endl; else cout << "no" << endl; } } }
#include <bits/stdc++.h> using namespace std; int n; unordered_map<string,int> m; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>n; string s; for(int i=0;i<n;i++){ cin>>s; if(s=="insert"){ cin>>s; m[s]=1; }else{ cin>>s; if(m[s])cout<<"yes"<<"\n"; else cout<<"no"<<"\n"; } } return 0; }
#include<iostream> #include<string> #include<map> using namespace std; int main() { int n; cin >> n; map<string, bool> Dic; string com, word; while( n-- ) { cin>>com>>word; if(com[0] == 'i' ) Dic[word]=true; else { if( Dic[word] ) cout << "yes" << endl; else cout << "no" <<endl; } } }
#include <iostream> #include <map> #include <string> using namespace std; void find(map<string, int> T){ } int main(){ int n; cin>>n; map<string, int> T; char str[10],com[13]; for(int i=0;i<n;i++){ cin>>com>>str; if(com[0]=='i') T[string(str)]=true; else{ if(T[string(str)]) cout<<"yes"<<endl; else cout<<"no"<<endl; } } return 0; }
#include <iostream> #include <map> using namespace std; int main() { int num; string com,key; map <string,int> a; cin>>num; for(int i=0;i<num;i++) { cin >> com>>key; if(com=="insert") a.insert(make_pair(key,i)); if(com=="find")cout<<(a.find(key)!=a.end()?"yes":"no")<<endl; } return 0; }
#include <iostream> #include <map> #include <cstdio> using namespace std; int main(){ int n;scanf("%d", &n); char s[7], str[13]; map<string, bool> m; for(int i = 0;i < n;i++){ scanf("%s %s", s, str); if(s[0] == 'i')m[str] = true; else puts(m[str] ? "yes" : "no"); } return 0; } //1.78 //0.87
#include<iostream> #include<unordered_set> #include<string> using namespace std; int main() { int n; unordered_set<string> d; string ope, contents; cin >> n; for (int i = 0; i < n; i++) { cin >> ope >> contents; if (ope == "insert") d.insert(contents); else if (ope == "find") { if (d.count(contents) >= 1) cout << "yes" << endl; else cout << "no" << endl; } } return 0; }
#include<string> #include<iostream> #include<algorithm> #include<set> using namespace std; int main(){ std::ios_base::sync_with_stdio(false); set<string> st; int n; cin >> n; while(n--){ string BUFF,c; cin >> BUFF >> c; if(BUFF=="insert") st.insert(c); else cout << (st.find(c)!=st.end()?"yes":"no") << endl; } }
#include<iostream> #include<cstdio> #include<string> #include<set> using namespace std; int main(){ int n; string query, word; set<string> dict; cin>>n; for(;n--;){ cin>>query>>word; if(query=="insert")dict.insert(word); else{ if(dict.find(word)==dict.end())puts("no"); else puts("yes"); } } }
#include<string> #include<iostream> #include<algorithm> #include<set> using namespace std; int main(){ set<string> s; int n; cin >> n; while(n--){ string a,b; cin >> a >> b; if(a=="insert") s.insert(b); else cout << (s.find(b)!=s.end()?"yes":"no") << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { set<string> S; string g; string memo; int n; cin>>n; for(int i=0;i<n;i++){ cin >>g>>memo; if(g[0]=='i'){ S.insert(memo); } else if(g[0]=='f'){ if(S.count(memo)){ cout<<"yes"<<endl; } else{cout<<"no"<<endl;} } } }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<string> ans; map<string,int> mp; for(int i=0;i<n;++i){ string s,s1; cin >> s >> s1; if(s=="insert"){ mp[s1]++; }else{ if(mp[s1]>0) ans.push_back("yes"); else ans.push_back("no"); } } for(int i=0;i<ans.size();++i){ cout << ans[i] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(){ int n; string inp; string ord; map<string,bool> m; cin >> n; for(int i = 0;i < n;i++){ cin >> inp; if(inp =="insert"){ cin >> ord; m[ord] = 1; }else if(inp == "find"){ cin >> ord; if(m[ord]){ cout << "yes" << endl; }else{ cout << "no" << endl; } } } return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); set<string> s; int n; string a,b; cin>>n; while(n--){ cin>>a>>b; if(a=="insert"){ s.insert(b); }else { if(s.count(b)){ cout<<"yes\n"; }else{ cout<<"no\n"; } } } return 0; }
#include <iostream> #include <map> #include <string> using namespace std; int main(void){ int n; string text,key; cin >> n; getline(cin, text); map <string, char> S; for (int i=0; i<n; i++){ getline(cin, text); switch (text[0]){ case 'i': S[text.substr(7)] = 1; break; case 'f': if (S.find(text.substr(5)) == S.end()) cout << "no" <<endl; else cout << "yes" << endl; } } return 0; }
#include <stdio.h> #include <string.h> int n, r[128]; bool used[22370000]; char com[7], s[13]; int main() { scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3; for(int i = 0; i < n; i++) { scanf("%s %s", com, s); int h = 0, l = strlen(s); for(int j = 0; j < l; j++) h = h * 4 + r[s[j]]; h += 1 << (2 * l); if(com[0] == 105) used[h] = true; else puts(used[h] ? "yes" : "no"); } }
#include<bits/stdc++.h> using namespace std; int main(){ int N;cin>>N; set<string> A; string s,t; for(int i=0;i<N;i++){ cin>>s>>t; if(s=="insert")A.insert(t); else{ if(A.count(t))cout<<"yes"<<endl; else cout<<"no"<<endl; } } return 0; }
#include <iostream> #include <cstdio> #include <map> #include <string> using namespace std; int main(void){ map<string, bool> dict; int n; char com[13], str[10]; cin >> n; for (int i = 0; i < n; i++) { scanf("%s %s", com, str); if (com[0] == 'i') { dict[string(str)] = true; } else { if (dict[string(str)]) printf("yes\n"); else printf("no\n"); } } return 0; }
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<string> #include<map> using namespace std; int main() { int n; char str[10], com[13]; map<string, bool>T; cin >> n; for (int i = 0; i < n; i++) { scanf("%s%s", com, str); if (com[0] == 'i')T[string(str)] = true; else { if (T[string(str)])printf("yes\n"); else printf("no\n"); } } return 0; }
#include <iostream> #include <set> using namespace std; int main() { set<string> st; int n; cin>>n; while (n--) { string cmd, str; cin>>cmd>>str; if (cmd=="insert") { st.insert(str); } else { cout<<(st.find(str)!=st.end()?"yes":"no")<<endl; } } return 0; }
#include <iostream> #include <cstdio> #include <string> #include <set> using namespace std; #define rep(x,to) for(int x=0; x<(to); (x)++) int main() { int n; char s[10]; string t; set<string> Set; cin >> n; rep(i,n) { scanf("%s", s); if(s[0] == 'i') { cin >> t; Set.insert(t); } else { cin >> t; if(Set.find(t) == Set.end()) printf("no\n"); else printf("yes\n"); } } return 0; }
#include <bits/stdc++.h> using namespace std; #define _GLIBCXX_DEBUG int main() { int n; cin>>n; set<string> dict; for (int i = 0; i < n ; i++) { string ope, word; cin>>ope>>word; if(ope=="insert")dict.insert(word); else cout<<(dict.count(word) ? "yes" : "no")<<endl; } }
#include <bits/stdc++.h> using namespace std; #define LLI long long int const int _mx = 2e6; int arr[_mx+5]; int main() { // freopen("in.txt", "r", stdin); int n; map <string, int> m; string a, b; for (cin >> n; n--; ) { cin >> a >> b; if (a[0] == 'i') m[b]++; else if (a[0] == 'f') cout << (m[b] ? "yes\n" : "no\n"); } return 0; }
#include <iostream> #include <unordered_set> int main() { int n; std::unordered_set<std::string> s; std::string t, u; std::cin >> n; while (n-- > 0) { std::cin >> t >> u; if (t == "insert") { s.insert(u); } else { std::cout << ((s.find(u) == s.end()) ? "no" : "yes") << std::endl; } } }
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define ll long long using namespace std; int main(){ int n; char str[10],com[13]; map<string,int> T; cin>>n; rep(i,n){ scanf("%s%s",com,str); if(com[0]=='i') T[string(str)]=true; else{ if (T[string(str)]) printf("yes\n"); else printf("no\n"); } } return 0; }
#include <cstdio> #include <iostream> #include <unordered_set> int main() { int n; std::scanf("%d", &n); std::string a, b; std::unordered_set<std::string> us; while (n--) { std::cin >> a >> b; if (a.at(0) == 'i') us.insert(b); else std::cout << (us.find(b) != us.end() ? "yes" : "no") << std::endl; } }
#include <iostream> #include <set> using namespace std; int main(){ int n;cin>>n; set<string> a; for(int i = 0; n > i; i++){ string s,t;cin>>s>>t; if(s=="insert"){ a.insert(t); }else{ if(a.count(t)!=0)cout << "yes" << endl; else cout << "no" << endl; } } }
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<cmath> #include<unordered_map> using namespace std; int main() { unordered_map<string, bool> mp; int n; cin >> n; while (n--) { string str, target; cin >> str >> target; if (str == "insert") { mp[target] = true; } else { cout << ((mp[target]) ? "yes" : "no") << endl; } } return 0; }
#include <unordered_set> #include <string> #include <iostream> using namespace std; int main(){ typedef unordered_set<string> set_t; set_t A; int n; cin >> n; string inst, word; for(int i=0; i<n; i++){ cin >> inst >> word; if(inst == "insert"){ A.insert(word); } else{ int m = A.count(word); if(m==0)cout << "no" << endl; else cout << "yes" << endl; } } }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); int n; cin >> n; map<string, bool> M; while (n--) { string op, e; cin >> op >> e; if (op == "insert") { M[e] = true; } else if (op == "find") { if (M[e]) cout << "yes" << endl; else cout << "no" << endl; } } return 0; }
#include<iostream> #include<string> #include<set> using namespace std; int main(){ int n; cin>>n; set<string> s; string v,w; for(int i=0;i<n;i++){ cin>>v>>w; if(v=="insert"){ s.insert(w); } else{ if(s.count(w)){cout<<"yes"<<endl;} else{cout<<"no"<<endl;} } } }
#include<map> #include<iostream> using namespace std; int main(){ int n,i; string S; char t[20]; map<string,bool> mp; cin>>n; for(i=0;i<n;i++){ cin>>t; if(t[0]=='i'){ cin>>S; mp[string(S)]=true; } else{ cin>>S; if(mp[string(S)]) cout<<"yes"<<endl; else cout<<"no"<<endl; } } }
#include<iostream> #include<stdio.h> #include<string.h> #include<set> using namespace std; int main(){ int n,i,cou=0; string x,y,b="insert",c="find"; set<string> a; cin>>n; int ans[n]; for(i=0;i<n;i++){ cin>>x; if(x==b){ cin>>y; a.insert(y); } if(x==c){ cin>>y; if(a.find(y)!=a.end()){ printf("yes\n"); } else printf("no\n"); } } return(0); }
#include<iostream> #include<set> #include<string> using namespace std; int main(){ set<string> st; int n; cin >> n; for(int i=0;i<n;i++){ string MODE,input; cin >> MODE >> input; if(MODE == "insert") st.insert(input); if(MODE == "find"){ if(st.count(input)){cout << "yes" << endl; continue;} cout << "no" << endl; } } return 0; }
#include <iostream> #include <map> using namespace std; int main() { int N; string cmd, param; map<string, int> d; cin >> N; for(int i = 0; i < N; ++i) { cin >> cmd >> param; if(cmd == "insert") { d[param] = 1; } else { if(d.find(param) == d.end()) { cout << "no" << endl; } else { cout << "yes" << endl; } } } return 0; }
#include<bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i++) //using ll = long long; using namespace std; int main(){ set<string> s; int n; string in_c, in_t; cin >> n; rep(i, n){ cin >> in_c >> in_t; if(in_c == "insert"){ s.insert(in_t); }else if(in_c == "find"){ if(s.count(in_t) == 0){ cout << "no" << endl; }else{ cout << "yes" << endl; } } } return 0; }
#include <iostream> #include <string> #include <set> using namespace std; int n; string order, str; set<string> dic; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> order >> str; if (order == "insert") { dic.insert(str); } else if (order == "find") { cout << (dic.find(str) != dic.end() ? "yes" : "no") << endl; } } return 0; }
#include<bits/stdc++.h> using namespace std; int main() { map<string,bool> dic; int N; cin >> N; string com, s; for (int i = 0; i < N; i++) { cin >> com >> s; if (com[0] == 'i') { dic[s] = true; } else { if (dic[s])cout << "yes" << endl; else cout << "no" << endl; } } }
#include<iostream> #include<map> #include<string> #include<set> using namespace std; int main(){ set<string>st; int n; cin>>n; while(n--){ string BUFF,c; cin>>BUFF>>c; if(BUFF=="insert"){ st.insert(c); } else{ cout<<(st.find(c)!=st.end()?"yes":"no")<<endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; // char com[9] string com, key; map<string, bool> dict; for(int i = 0; i < n; i ++) { cin >> com >> key; if (com[0] == 'i') dict[key] = true; else if (com[0] == 'f') { if(dict[key]) cout << "yes" << endl; else cout << "no" << endl; } } }
#include <iostream> #include <set> #include <string> using namespace std; int main() { int n; cin >> n; set<string> tmp1; for (int i = 0; i < n; ++i) { string tmp2, str; cin >> tmp2 >> str; if (tmp2 == "find") { if (tmp1.count(str)) cout << "yes"; else cout << "no"; cout << endl; } else tmp1.insert(str); } }
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;i++) using namespace std; char t[20], s[20]; int main() { int n; scanf("%d", &n); set<string>se; rep(i, n) { scanf("%s%s", t, s); if (!strcmp(t, "insert"))se.insert(s); else puts(se.find(s) != se.end() ? "yes" : "no"); } }
#include <iostream> #include <string> #include <set> using namespace std; int main(){ int n; cin >> n; string x; set<string> data; for(int i = 0; i < n; i++){ cin >> x; string tmp; cin >> tmp; if(x == "insert"){ data.insert(tmp); }else{ (data.find(tmp) != data.end()) ? (x = "yes") : (x = "no"); cout << x << endl; } } return 0; }
#include<iostream> #include<map> using namespace std; int main() { map<string, bool> dict; int n; string x, y; cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; if(x == "insert") dict[y] = 1; else { if(dict[y] == 1) cout << "yes" << endl; else cout << "no" << endl; } } }
#include<iostream> #include<vector> #include<string> #include<unordered_set> using namespace std; int main() { int a; cin >> a; unordered_set<string>b; for (int c = 0; c < a; c++) { string d, e; cin >> d >> e; if (d == "insert")b.insert(e); else { if (b.find(e) == b.end())cout << "no" << endl; else cout << "yes" << endl; } } }
# include <iostream> # include <string> # include <set> using namespace std; int main(void) { int n; set<string> a; string str,s; scanf("%d",&n); while(n--) { cin>>str>>s; if(str == "insert") a.insert(s); else { if(a.find(s) == a.end()) printf("no\n"); else printf("yes\n"); } } return 0; }
#include <iostream> #include <unordered_set> using namespace std; int main() { int n; cin >> n; string s, t; unordered_set<string> d; while (n--) { cin >> s >> t; switch(s[0]) { case 'i': d.insert(t); break; case 'f': cout << (d.find(t) != d.end() ? "yes" : "no") << endl; } } }
#include<iostream> #include<map> #include<string> using namespace std; int main() { string fir, sec; map<string, string> cpp; int q; cin >> q; while (q--) { cin >> fir >> sec; if (fir[0] == 'i')cpp[sec] = "yes"; else if (fir[0] == 'f') { if (cpp.find(sec) != cpp.end())cout << "yes" << endl; else cout << "no" << endl; } } return 0; }
#include <iostream> #include <set> #include <string> using namespace std; int main() { int n; cin>>n; set<string> S; for (int i=0; i<n; i++) { string cmd, str; cin>>cmd>>str; if (cmd=="insert") S.insert(str); else cout<<(S.count(str)>0 ? "yes" : "no")<<endl; } }
#include <iostream> #include <map> #include <string> using namespace std; int main() { map<string, bool> T; int n; string com, str; cin >> n; for(int i = 0; i < n; ++ i) { cin >> com >> str; if(com[0] == 'i') { T[str] = true; } else if(com[0] == 'f') { if(T[str]) cout << "yes" << endl; else cout << "no" << endl; } } return 0; }
#include <iostream> #include <set> using namespace std; int main() { int n; cin >> n; string cmd, str; set<string> dic; int i; for (i = 0; i < n; i++) { cin >> cmd >> str; if (cmd == "insert") { dic.insert(str); } else { cout << (dic.find(str) != dic.end() ? "yes" : "no") << endl; } } return 0; }
#include<bits/stdc++.h> using namespace std; int n;set<string> d;string s,t; int main(){ cin>>n; while(n--){ cin>>s>>t; if(s[0]=='f')cout<<(d.find(t)!=d.end()?"yes":"no")<<endl; else d.insert(t); } }
#include<iostream> #include<set> using namespace std; int main(){ int n; set<string> S; cin>>n; for(int i=0;i<n;i++){ string s1,s2; cin>>s1>>s2; if(s1[0]=='i'){ S.insert(s2); } else if(s1[0]=='f'){ if(S.find(s2)!=S.end())cout<<"yes"<<endl; else cout<<"no"<<endl; } } return 0; }
#include <iostream> #include <string> #include <set> #define rep(i,a) for(int i=0;i<(a);++i) int n; std::set<std::string> S; int main() { std::cin >> n; rep( i, n ) { std::string cmd, str; std::cin >> cmd >> str; if( cmd == "insert" ) S.insert( str ); else puts( S.count(str) ? "yes" : "no" ); } return 0; }
#include <iostream> #include <string> #include <map> using namespace std; int main(){ int m; cin>>m; string meirei,moji; map<string,int> dic; while(m--){ cin>>meirei>>moji; if(meirei=="insert"){ dic.insert(make_pair(moji,1)); }else{ if(dic.find(moji)!=dic.end()){ cout<<"yes"<<endl; }else{ cout<<"no"<<endl; } } } }
#include <iostream> #include <set> #include <string> using namespace std; int n; string S,T; int main(){ cin >> n; set<string> s; for(int i=1;i<=n;i++){ cin >> S >> T; if(S=="insert") s.insert(T); else{ decltype(s)::iterator it = s.find(T); if(it!=s.end()) cout << "yes" << endl; else cout << "no" << endl; } } }
#include<iostream> #include<map> #include<string> using namespace std; int main() { int n; cin >> n; map<string, bool> T; for (int i = 0; i < n; i++) { char str[10]; char C[13]; cin >> str >> C; if (str[0] == 'i') { T[string(C)] = true; } else { if (T.find(C) != T.end()) { cout << "yes" << endl; } else cout << "no" << endl; } } return 0; }
#include<iostream> #include<set> using namespace std; int main() { ios::sync_with_stdio( false ); int n; cin>>n; set< string > dict; string cmd, key; for( int i=0; i<n; i++ ) { cin>>cmd>>key; if( "insert" == cmd ) { dict.insert( key ); } else { if( dict.end() != dict.find( key ) ) { cout<<"yes\n"; } else { cout<<"no\n"; } } } return 0; }
#include<iostream> #include<set> #include<string> using namespace std; int main() { set<string> dic; string word; int n; cin >> n; for(int i = 0; i < n; i++) { cin >> word; if(word == "insert"){ cin >> word; dic.insert(word); } else { cin >> word; if(dic.count(word)) cout << "yes" <<endl; else cout << "no" << endl; } } return 0; }
#include <stdio.h> #include <string.h> int n, r[128]; bool used[22370000]; char com[7], s[13]; int main() { scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3; for(int i = 0; i < n; i++) { scanf("%s %s", com, s); int h = 0, l = strlen(s); for(int j = 0; j < l; j++) h = h * 4 + r[s[j]]; h += (1 << (2 * l)); if(com[0] == 'i') used[h] = true; else puts(used[h] ? "yes" : "no"); } }
#include <iostream> #include <map> using namespace std; int main() { int n; cin >> n; map<string, int> dic; string s; for (int i = 0; i < n; i++) { cin >> s; if (s[0] == 'i') { cin >> s; dic[s] = 1; }else{ cin >> s; if (dic.count(s)) cout << "yes" << endl; else cout << "no" << endl; } } }
#include<bits/stdc++.h> using namespace std; int main(){ set<string> st; int n; cin >> n; while(n--){ string com,s; cin >> com >> s; if(com == "insert") st.insert(s); else cout << (st.find(s)!=st.end()?"yes":"no") << endl; } return 0; }
#include <iostream> #include <string> #include <set> using namespace std; set<string> S; int main() { ios::sync_with_stdio(false), cin.tie(0); int N; string com, str; cin >> N; while(N--){ cin >> com >> str; if(com[0] == 'i') S.insert(str); else cout << (S.count(str) == 0 ? "no" : "yes") << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; char str[10]; string in; map<string,int> maps; map<string,int>::iterator iter; for(int i=0;i<n;i++) { cin>>str>>in; if(str[0]=='i') { maps.insert(pair<string,int>(in,i)); }else if(str[0]=='f') { iter = maps.find(in); if(iter==maps.end()) printf("no\n"); else printf("yes\n"); } } return 0; }
#include <cstdio> bool d[33554432]; char k[128]; int c(char str[12]){ int ans = str[0], i = 1; for(i;str[i] != '\0';i++){ans <<= 2;ans += k[str[i]];} return ans; } int main(){ k['A'] = 0;k['C'] = 1;k['G'] = 2;k['T'] = 3; int n;scanf("%d", &n); char s[7], str[12]; while(n--){ scanf("%s %s", s, str); if(s[0] == 'i')d[c(str)] = true; else puts(d[c(str)] ? "yes" : "no"); } return 0; }
#include<bits/stdc++.h> using namespace std; const int MAXN_O=10,MAXN_S=15; char o[MAXN_O],s[MAXN_S]; map<string,string> d; int main() { //input int N_line; cin>>N_line; while(N_line--) { //aligorithm cin>>o; cin>>s; if(o[0]=='i') d[s]="whatever"; else if(o[0]=='f') { if(d.count(s)) cout<<"yes\n"; else cout<<"no\n"; } } return 0; }
#include <iostream> #include <algorithm> #include <unordered_set> using namespace std; #define ll long long int main(){ ll n; cin >> n; unordered_set<string> us; for(ll i = 0; i < n; i++){ string a,b; cin >> a >> b; if(a == "insert"){ us.insert(b); }else{ if(us.find(b) == us.end()){ cout << "no\n"; }else{ cout << "yes\n"; } } } }
#include <iostream> #include <unordered_set> using namespace std; int main() { unordered_set<string> dict; int n; cin >> n; while (n--) { string op, str; cin >> op >> str; if (op.at(0) == 'i') { dict.insert(str); } else { cout << (dict.find(str) != dict.end() ? "yes" : "no") << endl; } } return 0; }