CF587D.Duff in Mafia

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Duff is one if the heads of Mafia in her country, Andarz Gu. Andarz Gu has nn cities (numbered from 1 to nn ) connected by mm bidirectional roads (numbered by 11 to mm ).

Each road has a destructing time, and a color. ii -th road connects cities viv_{i} and uiu_{i} and its color is cic_{i} and its destructing time is tit_{i} .

Mafia wants to destruct a matching in Andarz Gu. A matching is a subset of roads such that no two roads in this subset has common endpoint. They can destruct these roads in parallel, i. e. the total destruction time is a maximum over destruction times of all selected roads.

They want two conditions to be satisfied:

  1. The remaining roads form a proper coloring.
  2. Destructing time of this matching is minimized.

The remaining roads after destructing this matching form a proper coloring if and only if no two roads of the same color have same endpoint, or, in the other words, edges of each color should form a matching.

There is no programmer in Mafia. That's why Duff asked for your help. Please help her and determine which matching to destruct in order to satisfied those conditions (or state that this is not possible).

输入格式

The first line of input contains two integers nn and mm ( 2<=n<=5×1042<=n<=5×10^{4} and 1<=m<=5×1041<=m<=5×10^{4} ), number of cities and number of roads in the country.

The next mm lines contain the the roads. ithi-th of them contains four integers vi,ui,civ_{i},u_{i},c_{i} and tit_{i} ( 1<=vi,ui<=n1<=v_{i},u_{i}<=n , viuiv_{i}≠u_{i} and 1<=ci,ti<=1091<=c_{i},t_{i}<=10^{9} for each 1<=i<=m1<=i<=m ).

输出格式

In the first line of input, print "Yes" (without quotes) if satisfying the first condition is possible and "No" (without quotes) otherwise.

If it is possible, then you have to print two integers tt and kk in the second line, the minimum destructing time and the number of roads in the matching ().

In the third line print kk distinct integers separated by spaces, indices of the roads in the matching in any order. Roads are numbered starting from one in order of their appearance in the input.

If there's more than one solution, print any of them.

输入输出样例

  • 输入#1

    5 7
    2 1 3 7
    3 1 1 6
    5 4 1 8
    4 5 1 1
    3 2 2 3
    4 5 2 5
    2 3 2 4
    

    输出#1

    Yes
    3 2
    4 5
    
  • 输入#2

    3 5
    3 2 1 3
    1 3 1 1
    3 2 1 4
    1 3 2 2
    1 3 2 10
    

    输出#2

    No
    

说明/提示

Graph of Andarz Gu in the first sample case is as follows:

A solution would be to destruct the roads with crosses.

Graph of Andarz Gu in the second sample case is as follows:

首页