結果

問題 No.466 ジオラマ
ユーザー hatoohatoo
提出日時 2017-10-21 19:54:18
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 4,486 bytes
コンパイル時間 12,883 ms
コンパイル使用メモリ 392,412 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 12:34:29
合計ジャッジ時間 17,139 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 1 ms
6,816 KB
testcase_04 AC 1 ms
6,816 KB
testcase_05 AC 1 ms
6,816 KB
testcase_06 AC 13 ms
6,816 KB
testcase_07 AC 9 ms
6,816 KB
testcase_08 AC 20 ms
6,816 KB
testcase_09 AC 11 ms
6,820 KB
testcase_10 AC 14 ms
6,816 KB
testcase_11 AC 12 ms
6,816 KB
testcase_12 AC 16 ms
6,820 KB
testcase_13 AC 9 ms
6,816 KB
testcase_14 AC 7 ms
6,816 KB
testcase_15 AC 10 ms
6,816 KB
testcase_16 AC 2 ms
6,820 KB
testcase_17 AC 8 ms
6,816 KB
testcase_18 AC 9 ms
6,816 KB
testcase_19 AC 10 ms
6,816 KB
testcase_20 AC 10 ms
6,816 KB
testcase_21 AC 9 ms
6,816 KB
testcase_22 AC 14 ms
6,820 KB
testcase_23 AC 10 ms
6,816 KB
testcase_24 AC 16 ms
6,816 KB
testcase_25 AC 17 ms
6,816 KB
testcase_26 AC 9 ms
6,820 KB
testcase_27 AC 18 ms
6,824 KB
testcase_28 AC 13 ms
6,816 KB
testcase_29 AC 18 ms
6,820 KB
testcase_30 AC 12 ms
6,820 KB
testcase_31 AC 12 ms
6,820 KB
testcase_32 AC 12 ms
6,820 KB
testcase_33 AC 10 ms
6,816 KB
testcase_34 AC 13 ms
6,820 KB
testcase_35 AC 11 ms
6,816 KB
testcase_36 AC 6 ms
6,816 KB
testcase_37 AC 1 ms
6,820 KB
testcase_38 AC 9 ms
6,816 KB
testcase_39 AC 1 ms
6,820 KB
testcase_40 AC 13 ms
6,820 KB
testcase_41 AC 1 ms
6,816 KB
testcase_42 AC 10 ms
6,816 KB
testcase_43 AC 1 ms
6,816 KB
testcase_44 AC 9 ms
6,820 KB
testcase_45 AC 1 ms
6,820 KB
testcase_46 AC 5 ms
6,820 KB
testcase_47 AC 1 ms
6,816 KB
testcase_48 AC 13 ms
6,816 KB
testcase_49 AC 1 ms
6,816 KB
testcase_50 AC 12 ms
6,820 KB
testcase_51 AC 1 ms
6,816 KB
testcase_52 AC 10 ms
6,820 KB
testcase_53 AC 1 ms
6,816 KB
testcase_54 AC 10 ms
6,820 KB
testcase_55 AC 1 ms
6,816 KB
testcase_56 AC 3 ms
6,816 KB
testcase_57 AC 1 ms
6,824 KB
testcase_58 AC 2 ms
6,816 KB
testcase_59 AC 1 ms
6,816 KB
testcase_60 AC 5 ms
6,816 KB
testcase_61 AC 1 ms
6,816 KB
testcase_62 AC 4 ms
6,820 KB
testcase_63 AC 1 ms
6,820 KB
testcase_64 AC 3 ms
6,816 KB
testcase_65 AC 1 ms
6,820 KB
testcase_66 AC 14 ms
6,820 KB
testcase_67 AC 1 ms
6,816 KB
testcase_68 AC 10 ms
6,816 KB
testcase_69 AC 1 ms
6,816 KB
testcase_70 AC 8 ms
6,820 KB
testcase_71 AC 1 ms
6,816 KB
testcase_72 AC 6 ms
6,820 KB
testcase_73 AC 1 ms
6,816 KB
testcase_74 AC 12 ms
6,816 KB
testcase_75 AC 1 ms
6,816 KB
testcase_76 AC 1 ms
6,820 KB
testcase_77 AC 1 ms
6,820 KB
testcase_78 AC 1 ms
6,820 KB
testcase_79 AC 1 ms
6,820 KB
testcase_80 AC 1 ms
6,816 KB
testcase_81 AC 1 ms
6,816 KB
testcase_82 WA -
testcase_83 AC 1 ms
6,816 KB
testcase_84 AC 14 ms
6,820 KB
testcase_85 AC 26 ms
6,816 KB
testcase_86 AC 1 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

// std::cmp::Reverse doesn't have Clone.
#[derive(Eq, PartialEq, Clone)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let abcd: Vec<usize> = util::gets();
    let a = abcd[0];
    let b = abcd[1];
    let c = abcd[2];
    let d = abcd[3];

    if a == b && b == c {
        let mut o = Vec::new();

        o.push((0, 1));
        o.push((1, 0));
        for i in 2..c {
            o.push((0, i));
        }

        if o.len() > d {
            println!("-1");
            return;
        }
        println!("{} {}", c, o.len());
        for &(f, t) in &o {
            println!("{} {}", f, t);
        }
        return;
    }

    if a == c {
        let mut o = Vec::new();
        o.push((1, 0));

        let mut v = 2;
        for _ in 0..c - 1 {
            o.push((0, v));
            v += 1;
        }
        for _ in 0..b - 1 - c {
            o.push((1, v));
            v += 1;
        }
        if o.len() > d {
            println!("-1");
            return;
        }
        println!("{} {}", v, o.len());
        for &(f, t) in &o {
            println!("{} {}", f, t);
        }
        return;
    }

    if b == c {
        let mut o = Vec::new();
        o.push((0, 1));

        let mut v = 2;
        for _ in 0..c - 1 {
            o.push((1, v));
            v += 1;
        }
        for _ in 0..a - 1 - c {
            o.push((0, v));
            v += 1;
        }
        if o.len() > d {
            println!("-1");
            return;
        }
        println!("{} {}", v, o.len());
        for &(f, t) in &o {
            println!("{} {}", f, t);
        }
        return;
    }

    let mut o = Vec::new();
    let mut v = 2;
    for _ in 0..a - c - 1 {
        o.push((0, v));
        v += 1;
    }

    for _ in 0..b - c - 1 {
        o.push((1, v));
        v += 1;
    }

    if c > 0 {
        o.push((0, v));
        o.push((1, v));

        v += 1;
        for _ in 1..c {
            o.push((v - 1, v));
            v += 1;
        }
    }
    if o.len() > d {
        println!("-1");
        return;
    }
    println!("{} {}", v, o.len());
    for &(f, t) in &o {
        println!("{} {}", f, t);
    }
    return;



}
0