Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- map<string, set<string>> words;
- map<string, int> kol;
- int q;
- cin >> q;
- for (int i = 0; i < q; i++) {
- string comand;
- cin >> comand;
- if (comand == "ADD") {
- string s1, s2;
- cin >> s1 >> s2;
- words[s1].insert(s2);
- words[s2].insert(s1);
- kol[s1]++;
- kol[s2]++;
- }
- else if (comand == "COUNT") {
- string s;
- cin >> s;
- cout << kol[s] << endl;
- //cout << words[s].size() << endl;
- }
- else if (comand == "CHECK") {
- string s1, s2;
- cin >> s1 >> s2;
- if (words[s1].count(s2) == 0) {
- cout << "NO" << endl;
- }
- else {
- cout << "YES" << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement