UVa 交换学生

#include 
#include 
using namespace std;
map Lu;
char Hui, Yi;
int main(){
	int n;
	scanf("%d", &n);
	int num = 0;
	for (int i = 1; i <= n; i++){
		cin >> Hui >> Yi;
		if (Lu[Yi] == Hui){
			num++;
		}
		Lu[Hui] = Yi;
	}
	if (num == n/2 && n%2 == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

你可能感兴趣的:(UVa 交换学生)