A851.Interesting Graph and Apples

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs to one cycle only — a funny ring — and does not belong to any other cycles. A funny ring is a cycle that goes through all the vertices just once. Moreover, loops are funny rings too.

She has already drawn the apples and some of the graph edges. But now it is not clear, how to connect the rest of the vertices to get an interesting graph as a result. The answer should contain the minimal amount of added edges. And furthermore, the answer should be the lexicographically smallest one. The set of edges (x1,y1),(x2,y2),...,(xn,yn)(x_{1},y_{1}),(x_{2},y_{2}),...,(x_{n},y_{n}) , where xi<=yix_{i}<=y_{i} , is lexicographically smaller than the set (u1,v1),(u2,v2),...,(un,vn)(u_{1},v_{1}),(u_{2},v_{2}),...,(u_{n},v_{n}) , where ui<=viu_{i}<=v_{i} , provided that the sequence of integers x1,y1,x2,y2,...,xn,ynx_{1},y_{1},x_{2},y_{2},...,x_{n},y_{n} is lexicographically smaller than the sequence u1,v1,u2,v2,...,un,vnu_{1},v_{1},u_{2},v_{2},...,u_{n},v_{n} . If you do not cope, Hexadecimal will eat you. ...eat you alive.

输入格式

The first line of the input data contains a pair of integers nn and mm ( 1<=n<=501<=n<=50 , 0<=m<=25000<=m<=2500 ) — the amount of vertices and edges respectively. The following lines contain pairs of numbers xix_{i} and yiy_{i} ( 1<=xi1<=x_{i} , yi<=ny_{i}<=n ) — the vertices that are already connected by edges. The initial graph may contain multiple edges and loops.

输出格式

In the first line output «YES» or «NO»: if it is possible or not to construct an interesting graph. If the answer is «YES», in the second line output kk — the amount of edges that should be added to the initial graph. Finally, output kk lines: pairs of vertices xjx_{j} and yjy_{j} , between which edges should be drawn. The result may contain multiple edges and loops. kk can be equal to zero.

输入输出样例

  • 输入#1

    3 2
    1 2
    2 3
    

    输出#1

    YES
    1
    1 3
    

说明/提示

提示说明

首页