Algorithm/백준
C++ 알고리즘 - 백준 26069 붙임성 좋은 총총이
마루설아
2025. 1. 16. 20:41
https://www.acmicpc.net/problem/26069
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
void CPP_INIT() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int main(void) {
CPP_INIT();
int input;
int cnt = 0;
string str1, str2;
map<string, bool> m;
cin >> input;
m["ChongChong"] = true;
for (int i = 0; i < input; i++) {
cin >> str1 >> str2;
if (m.find(str1) == m.end()) {
m.insert({ str1, false });
}
if (m.find(str2) == m.end()) {
m.insert({ str2, false });
}
if (m[str1] == true) m[str2] = true;
if (m[str2] == true) m[str1] = true;
}
for (pair<string, bool> p : m) {
if (p.second == true) cnt++;
}
cout << cnt;
}