题目链接:http://codeforces.com/contest/781/problem/B
去tmd 2-SAT
直接贪心就可以过去了,优先选择第二种情况。
然而....可以被叉掉(数据水了)
ABC DDD
ABD DOG
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<map>
using namespace std;
#define maxn 1001000
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m;
string a,s1,s2,la,b;
string ans[maxn];
map<string,bool>ma,mma; int main()
{
yyj("D");
cin>>n;
for (llg k=;k<=n;k++)
{
s1.clear(),s2.clear();
cin>>s1>>s2;
a.clear();
a=s1.substr(,);
b=s1.substr(,)+s2[];
if (!ma[b])
{
ma[b]=;
ans[k]=b;
mma[a]=;
}
else
{
if (ma[a] || mma[a]){cout<<"NO"; return ;}
ans[k]=a;
ma[a]=;
} }
cout<<"YES"<<endl;
for (llg i=;i<=n;i++)
{
cout<<ans[i]<<endl;
}
return ;
}