Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <string>
- using namespace std;
- void add(set<set<string>>& m, int& k){
- string str;
- int mycount;
- int flag = 0;
- set<string> s;
- for (int i = 0; i < 2; ++i){
- cin >> str;
- s.insert(str);
- }
- mycount = count(m.begin(), m.end(), s);
- if (mycount == 0){
- m.insert(s);
- }
- }
- void count(const vector<set<string>>& m){
- string str;
- int mycount = 0;
- int sum = 0;
- cin >> str;
- for(auto k : m){
- mycount = count(k.begin(), k.end(), str);
- sum += mycount;
- }
- cout << sum << endl;
- }
- void check(vector<set<string>>& m){
- string str;
- int flag = 0;
- int mycount;
- set<string> s;
- for (int i = 0; i < 2; ++i){
- cin >> str;
- s.insert(str);
- }
- mycount = count(m.begin(), m.end(), s);
- if (mycount == 0){
- cout << "NO" << endl;
- }
- else{
- cout << "YES" << endl;
- }
- }
- int main(){
- vector<set<string>> m;
- int Q;
- int k = 0;
- string str;
- cin >> Q;
- for(int i = 0; i < Q; ++i){
- cin >> str;
- if (str == "ADD"){
- add(m, k);
- }
- if (str == "COUNT"){
- count(m);
- }
- if (str == "CHECK"){
- check(m);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement