11use anyhow:: Result ;
22use colored:: * ;
33use prettytable:: { format, row, table, Table } ;
4- use regex:: Regex ;
54use std:: collections:: HashMap ;
65use std:: io:: Write ;
76use std:: process:: { Command , Stdio } ;
@@ -18,55 +17,15 @@ use crate::util::split_one_line_command;
1817pub enum Status {
1918 AC ,
2019 WA ,
21- TLE ,
22- RE ,
2320 CE ,
24- WJ ,
2521}
2622
2723impl Status {
28- pub fn as_str ( & self ) -> & str {
29- match self {
30- Status :: AC => "AC" ,
31- Status :: WA => "WA" ,
32- Status :: TLE => "TLE" ,
33- Status :: RE => "RE" ,
34- Status :: CE => "CE" ,
35- Status :: WJ => "WJ" ,
36- }
37- }
3824 pub fn as_display_string ( & self ) -> ColoredString {
3925 match self {
4026 Status :: AC => "AC" . green ( ) ,
4127 Status :: WA => "!! WA !!" . red ( ) ,
42- Status :: TLE => "!! TLE !!" . yellow ( ) ,
43- Status :: RE => "!! RE !!" . yellow ( ) ,
4428 Status :: CE => "!! CE !!" . yellow ( ) ,
45- Status :: WJ => "WJ" . into ( ) ,
46- }
47- }
48-
49- pub fn from_table_str ( v : & str ) -> Self {
50- match v {
51- "AC" => Status :: AC ,
52- "WA" => Status :: WA ,
53- "RE" => Status :: RE ,
54- "TLE" => Status :: TLE ,
55- "CE" => Status :: CE ,
56- "WJ" => Status :: WJ ,
57- _ => {
58- let re = Regex :: new ( r"^(\d+) */ *(\d+) *(.*)$" ) . unwrap ( ) ;
59- if let Some ( caps) = re. captures ( v) {
60- let status = caps[ 3 ] . trim ( ) ;
61- if status. is_empty ( ) {
62- Status :: AC
63- } else {
64- Status :: from_table_str ( status)
65- }
66- } else {
67- Status :: WJ
68- }
69- }
7029 }
7130 }
7231}
@@ -75,14 +34,10 @@ pub struct FailedDetail {
7534 pub index : usize ,
7635 pub input : String ,
7736 pub expected : String ,
78- #[ allow( dead_code) ]
79- pub status : Status ,
8037 pub output : String ,
8138}
8239
8340pub struct SampleResults {
84- #[ allow( dead_code) ]
85- pub size : usize ,
8641 pub total_status : Status ,
8742 pub failed_details : Vec < FailedDetail > ,
8843}
@@ -187,7 +142,6 @@ pub fn sample_check(
187142 table = add_total_status_to_table ( table, & total_status) ;
188143 table. printstd ( ) ;
189144 return Ok ( SampleResults {
190- size : 0 ,
191145 total_status,
192146 failed_details : vec ! [ ] ,
193147 } ) ;
@@ -229,7 +183,6 @@ pub fn sample_check(
229183 failed_details. push ( FailedDetail {
230184 index : sample_id,
231185 input : samples. inputs [ i] . clone ( ) . 1 ,
232- status : Status :: WA ,
233186 expected,
234187 output : output_str,
235188 } ) ;
@@ -242,7 +195,6 @@ pub fn sample_check(
242195 table. printstd ( ) ;
243196
244197 Ok ( SampleResults {
245- size : samples. size ,
246198 total_status,
247199 failed_details,
248200 } )
0 commit comments