alphacademy-cpp/quito/12.5.cpp

35 lines
665 B
C++
Raw Permalink Normal View History

2023-03-02 13:58:39 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<string, string>>allatok(n);
set<string>kaja;
set<string> out;
for (int i =0; i < n ;i++) {
cin >> allatok[i].first;
//cout<<"s";
cin >> allatok[i].second;
kaja.insert(allatok[i].first);
}
for (int i = 0; i < n;i++) {
if (kaja.count(allatok[i].second)) {
//cout<<endl<<allatok[i].second<< " is in the set: "<<kaja.count(allatok[i].second);
out.insert(allatok[i].first);
}
}
cout<<out.size()<<endl;
for (string x : out) {
cout<<x<<endl;
}
}