File tree 5 files changed +493
-557
lines changed
5 files changed +493
-557
lines changed Original file line number Diff line number Diff line change @@ -3,34 +3,55 @@ extern crate santa17;
3
3
use santa17:: * ;
4
4
5
5
fn main ( ) {
6
- let g = construct_graph ( ) ;
6
+ let ( g1 , g2 ) = construct_graph ( ) ;
7
7
let ps = read_solution ( & std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) ) ;
8
- let mut count = vec ! [ 0 ; N2 ] ;
9
- for i in 0 ..N1 {
10
- if ps[ i] != !0 {
8
+ let mut count = vec ! [ 0 ; N ] ;
9
+ let mut err = false ;
10
+ for i in 0 ..N {
11
+ if ps[ i] == !0 {
12
+ err = true ;
13
+ } else {
11
14
count[ ps[ i] ] += 1 ;
12
15
}
13
16
}
14
- for j in 0 ..N2 {
17
+ if err {
18
+ println ! ( "mismatch!" ) ;
19
+ }
20
+ err = false ;
21
+ for j in 0 ..N {
15
22
assert ! ( count[ j] <= 1000 ) ;
16
23
}
17
- let mut err = false ;
18
- for i in 0 ..K /2 {
19
- if ps[ i * 2 ] != ps[ i * 2 + 1 ] || ps[ i * 2 ] == !0 {
24
+ for i in 0 ..N3 {
25
+ if ps[ i * 3 ] != ps[ i * 3 + 1 ] || ps[ i * 3 ] != ps[ i * 3 + 2 ] {
20
26
err = true ;
21
27
}
22
28
}
23
29
if err {
24
- println ! ( "error !" ) ;
30
+ println ! ( "triple !" ) ;
25
31
}
26
- let mut cost = 0 ;
27
- for i in 0 ..N1 {
28
- for & ( j, w) in & g[ i] {
32
+ err = false ;
33
+ for i in 0 ..N2 {
34
+ if ps[ N3 * 3 + i * 2 ] != ps[ N3 * 3 + i * 2 + 1 ] {
35
+ err = true ;
36
+ }
37
+ }
38
+ if err {
39
+ println ! ( "twin!" ) ;
40
+ }
41
+ let mut score1 = 0 ;
42
+ let mut score2 = 0 ;
43
+ for i in 0 ..N {
44
+ for & ( j, w) in & g1[ i] {
45
+ if j == ps[ i] {
46
+ score1 += w;
47
+ }
48
+ }
49
+ for & ( j, w) in & g2[ i] {
29
50
if j == ps[ i] {
30
- cost += w;
51
+ score2 += w;
31
52
}
32
53
}
33
54
}
34
- println ! ( "{}" , cost_to_score ( cost ) ) ;
35
- println ! ( "{}" , cost ) ;
55
+ println ! ( "{} {} " , score1 , score2 ) ;
56
+ println ! ( "{}" , get_score ( score1 , score2 ) ) ;
36
57
}
You can’t perform that action at this time.
0 commit comments