CF623A Graph and String 【题解】

题目描述

One day student Vasya was sitting on a lecture and mentioned a string s 1 s 2 . . .   s n s_{1}s_{2}...\ s_{n} s1s2... sn, consisting of letters “a”, “b” and “c” that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties:

  • G has exactly n vertices, numbered from 1 to n .
  • For all pairs of vertices i and j , where i≠j , there is an edge connecting them if and only if characters s i s_{i} si and s j s_{j} sj are either equal or neighbouring in the alphabet. That is, letters in pairs “a”-“b” and “b”-“c” are neighbouring, while letters “a”-“c” are not.
    Vasya painted the resulting graph near the string and then erased the string. Next day Vasya’s friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya’s adventure and now he wants to find out whether it could be the original graph G , painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s , such that if Vasya used this s s he would produce the given graph G .

输入输出格式

输入格式:

The first line of the input contains two integers n and m 在这里插入图片描述 — the number of vertices and edges in the graph found by Petya, respectively.

Each of the next m lines contains two integers u i u_{i} ui and v i v_{i} vi ( 1 &lt; = u i , v i &lt; = n , u i ≠ v i ) (1&lt;=u_{i},v_{i}&lt;=n,u_{i}≠v_{i}) (1<

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值