## 题解：

#include<bits/stdc++.h>
using namespace std;

int mp[520][520];
int cnt[520];
int flag[520];
int n,m;
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d%d",&x,&y);
mp[x][y]=1;
mp[y][x]=1;
cnt[x]++;
cnt[y]++;
}
for(int i=1;i<=n;i++)
if(cnt[i]==n-1)
flag[i]=2;
int now=0;
for(int i=1;i<=n;i++)
if(flag[i]!=2)
{
now=i;
break;
}
if(now==0)
{
printf("Yes\n");
for(int i=1;i<=n;i++)
cout<<"b";
cout<<endl;
return 0;
}
flag[now]=1;
for(int i=1;i<=n;i++)
{
if(now==i)continue;
if(!mp[i][now])flag[i]=3;
else if(flag[i]==0)flag[i]=1;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==j)continue;
if(mp[i][j])
{
if(abs(flag[j]-flag[i])>1)
return puts("No");
}
else
{
if(abs(flag[j]-flag[i])<=1)
return puts("No");
}
}
}
printf("Yes\n");
for(int i=1;i<=n;i++)
if(flag[i]==1)printf("a");
else if(flag[i]==2)printf("b");
else printf("c");
printf("\n");
}

#### AIM Tech Round (Div. 2) C. Graph and String（二分图染色 | 贪心）

2016-02-05 04:24:14

#### Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

#### Educational Codeforces Round 36 (Rated for Div. 2) 题解

2018-01-13 23:16:24

#### Codeforces Round #465 (Div. 2) C. Fifa and Fafa(圆问题，数论)

2018-02-20 16:16:48

#### Codeforces Round #475 (Div. 2) C. Alternating Sum(求逆元)

2018-04-18 09:29:30

#### Codeforces Round #447 (Div. 2) C. Marco and GCD Sequence (构造 贪心)

2017-11-20 13:19:26

#### Codeforces Round #482 (Div. 2)

2018-05-15 12:51:24

#### Codeforces Round #377 (Div. 2)C. Sanatorium(贪心）

2016-10-26 20:08:59

#### AIM Tech Round (Div. 2)C - Graph and String（二分图染色）

2016-02-05 16:44:06

#### Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 2) C. Alternating Sum

2018-04-18 11:14:58

## 不良信息举报

AIM Tech Round (Div. 2) C. Graph and String 二分图染色