Submission #61539837


Source Code Expand

#[allow(unused_imports)]
use proconio::{input, marker::Chars};

fn main() {
    input!{
        c: Chars
    }
    println!("{}UPC" , c[0]);
}
pub trait Debuggable {
    fn debug_string(&self) -> String;
}

impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for Vec<T> {
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        use std::iter::repeat;
        if let Some(max_size) = self.iter()
            .enumerate()
            .map(|(i, x)| (format!("{:?}", x).len()).max(format!("{:?}", i).len()))
            .max() {
                let mut idx = String::from("idx |");   
                let mut val = String::from("val |");   
                for (i, xi) in self.iter().enumerate() {
                    idx.push_str(
                        &format!(" {:>w$} |", i, w=max_size)
                    );
                    val.push_str(
                        &format!(" {:>w$} |", xi, w=max_size)
                    );
                }

                format!("{}\n{}\n{}\n", idx, repeat('-').take(idx.len()).join(""), val)
            } else {
                format!("idx | \nval |\n")
            }
    }
}

impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for std::collections::BTreeSet<T> {
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        format!("{{ {} }}", self.iter().join(", "))
    }
}

impl<T, U> Debuggable for std::collections::BTreeMap<T, U> 
where T: std::fmt::Debug + std::fmt::Display, U: std::fmt::Debug + std::fmt::Display
{
    fn debug_string(&self) -> String {
        use itertools::Itertools;
        format!(
            "{{\n{}\n }}", self.iter()
                .map(|(k, v)| format!("{k} -> {v}, "))
                .join("\n")
        )
    }
}

// lg! マクロの定義
#[macro_export]
macro_rules! lg {
    ($val:expr) => {
        #[cfg(feature = "local")]
        {
            {
                use Debuggable;
                let val = &$val;
                eprintln!(
                    "[{}:{}] {} = \n{}",
                    file!(),
                    line!(),
                    stringify!($val),
                    val.debug_string()
                );
                val
            }
        }
    }
}
    

Submission Info

Submission Time
Task A - ?UPC
User ardRiriy
Language Rust (rustc 1.70.0)
Score 100
Code Size 2240 Byte
Status AC
Exec Time 1 ms
Memory 2076 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 2
AC × 14
Set Name Test Cases
Sample sample00.txt, sample01.txt
All sample00.txt, sample01.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 1908 KiB
sample01.txt AC 1 ms 1780 KiB
testcase00.txt AC 1 ms 1924 KiB
testcase01.txt AC 1 ms 1996 KiB
testcase02.txt AC 1 ms 1928 KiB
testcase03.txt AC 1 ms 2072 KiB
testcase04.txt AC 1 ms 1892 KiB
testcase05.txt AC 1 ms 2076 KiB
testcase06.txt AC 1 ms 1864 KiB
testcase07.txt AC 1 ms 1924 KiB
testcase08.txt AC 1 ms 1840 KiB
testcase09.txt AC 1 ms 1916 KiB
testcase10.txt AC 1 ms 1924 KiB
testcase11.txt AC 1 ms 2064 KiB