File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ /** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+ use proconio:: input;
3+ use proconio:: marker:: * ;
4+ use std:: marker:: PhantomData ;
5+ use std:: cmp:: * ;
6+ use std:: collections:: * ;
7+ use itertools:: Itertools ;
8+
9+
10+ fn main ( ) {
11+ input ! {
12+ n: usize ,
13+ m: usize ,
14+ ab: [ ( Usize1 , Usize1 ) ; m]
15+ }
16+
17+ if m != n {
18+ println ! ( "No" ) ;
19+ return ;
20+ }
21+
22+ let mut g = vec ! [ vec![ ] ; n] ;
23+ for ( a, b) in ab {
24+ g[ a] . push ( b) ;
25+ g[ b] . push ( a) ;
26+ }
27+
28+ for i in 0 ..n {
29+ if g[ i] . len ( ) != 2 {
30+ println ! ( "No" ) ;
31+ return ;
32+ }
33+ }
34+
35+
36+ let mut seen = vec ! [ false ; n] ;
37+ let mut ci = 0 ;
38+ let mut li = 10usize . pow ( 9 ) ;
39+ while !seen[ ci] {
40+ seen[ ci] = true ;
41+ for & ni in & g[ ci] {
42+ if li != ni {
43+ li = ci;
44+ ci = ni;
45+ break ;
46+ }
47+ }
48+ }
49+
50+ for f in seen {
51+ if !f {
52+ println ! ( "No" ) ;
53+ return ;
54+ }
55+ }
56+ println ! ( "Yes" ) ;
57+ }
You can’t perform that action at this time.
0 commit comments