luogu#P3496. [POI2010] GIL-Guilds
[POI2010] GIL-Guilds
题目描述
King Byteasar faces a serious matter.
Two competing trade organisations, The Tailors Guild and The Sewers Guild asked, at the same time, for permissions to open their offices in each town of the kingdom.
There are towns in Byteotia.
Some of them are connected with bidirectional roads.
Each of the guilds postulate that every town should:
have an office of the guild, or be directly connected to another town that does.
The king, however, suspects foul play. He fears that if there is just a single town holding the offices of both guilds, it could lead to a clothing cartel.
For this reason he asks your help.
给一张无向图,要求你用黑白灰给点染色,且满足对于任意一个黑点,至少有一个白点和他相邻;对于任意一个白点,至少有一个黑点与他相邻,对于任意一个灰点,至少同时有一个黑点和白点和灰点与他相邻,问能否成功
输入格式
Two integers, n(<=200000) and m(<=500000), are given in the first line of the standard input. These denote the number of towns and roads in Byteotia, respectively.
The towns are numbered from 1 to n.
Then the roads are given as follows: the input line no. i+1 describes the i-th road;
输出格式
Your program should print out one word in the first line of the standard output:
TAK (yes in Polish) - if the offices can be placed in towns according to these rules, or NIE (no in Polish) - in the opposite case.
If the answers is TAK, then the following nlines should give an exemplary placement of the offices. Thus the line no. i+1 should hold:
the letter K if there should be an office of The Tailors Guild in the town i, or the letter S if there should be an office of The Sewers Guild in the town i, or the letter N if there should be no office in the town i.
7 8
1 2
3 4
5 4
6 4
7 4
5 6
5 7
6 7
TAK
K
S
K
S
K
K
N
提示
题目spj贡献者@mengbierr