lbromine
wanted to play It Takes Two, but it takes two. So he went to his friends and asked them if they had played It Takes Two.
It is known that lbromine
has n friends. When he asks a friend, the friend will only answer that he has not played or played It Takes Two with another person.Because some of his friends are forgetful,maybe some friends have played It Takes Two but say no.
lbromine
thinks that a friend has played It Takes Two only when the friend said he had played with another person or another friend oflbromine
said he had played with him.
Now lbromine
wants to count how many friends he thinks have never played It Takes Two so that he can choose the right person to play with.
输入格式
An integer n in the first line indicates that lbromine
has n (1≤n≤105) friends.
The next n line has two strings per line. The first string represents the friend’s name, and the second string represents the answer of the friend.
It is guaranteed that the answer of lbromine's
friends can only be No
or a person’s name (may not be a friend of lbromine
).
A person’s name only contains uppercase and lowercase letters and underscores,and the length cannot exceed 10 characters.
no one names No
.
输出格式
One integer indicates how many friendslbromine
thinks have never played It Takes Two
样例
input
3 CN_Amuzi No komorebi MaverickFW MaverickFW No
output
1
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
struct Person
{
string one, two;
};
int main()
{
int n;
cin >> n;
vector<Person> people(n);
set<string> mySet;
string str1, str2;
for (int i = 0; i < n; i++)
{
cin >> str1 >> str2;
people[i].one = str1;
people[i].two = str2;
if (str2 != "No")
{
mySet.insert(str1);
mySet.insert(str2);
}
}
int sum = 0;
for (int i = 0; i < n; i++)
if (people[i].two == "No" && mySet.find(people[i].one) == mySet.end())
sum++;
cout << sum << endl;
}