Submission #10234171


Source Code Expand

#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let rh = get!(usize, usize; n);
    let mut map = BTreeMap::new();
    for &(r,h) in &rh {
        map.entry(r).or_insert([0;3])[h-1] += 1;
    }

    let mut count = 0;
    let mut res = BTreeMap::new();
    for (k,v) in map {
        let sum = v.iter().sum::<usize>();
        for i in 0..3 {
            let win = count+v[(i+1)%3];
            let lose = n+v[(i+2)%3]-(count+sum);
            let draw = n-win-lose;
            res.insert((k,i+1), (win,lose,draw));
        }
        count += sum;
    }

    for (r,h) in rh {
        let (w,l,d) = res.get(&(r,h)).cloned().unwrap();
        println!("{} {} {}", w,l,d-1);
    }
}

Submission Info

Submission Time
Task B - AtCoderでじゃんけんを
User ikazuya0201
Language Rust (1.15.1)
Score 100
Code Size 2964 Byte
Status AC
Exec Time 368 ms
Memory 36476 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 368 ms 30332 KB
02.txt AC 350 ms 28284 KB
03.txt AC 297 ms 12028 KB
04.txt AC 275 ms 12028 KB
05.txt AC 280 ms 12156 KB
06.txt AC 273 ms 12156 KB
07.txt AC 261 ms 12284 KB
08.txt AC 260 ms 12284 KB
09.txt AC 259 ms 12284 KB
10.txt AC 286 ms 12284 KB
11.txt AC 359 ms 36476 KB
12.txt AC 355 ms 36476 KB
13.txt AC 360 ms 36476 KB
14.txt AC 269 ms 11516 KB
15.txt AC 251 ms 11516 KB
16.txt AC 274 ms 11516 KB
17.txt AC 268 ms 12156 KB
18.txt AC 285 ms 12156 KB
19.txt AC 342 ms 28284 KB
20.txt AC 342 ms 30332 KB
21.txt AC 348 ms 28284 KB
22.txt AC 345 ms 28284 KB
23.txt AC 351 ms 28284 KB
24.txt AC 366 ms 30332 KB
25.txt AC 3 ms 8572 KB
26.txt AC 4 ms 8572 KB
27.txt AC 3 ms 8572 KB
28.txt AC 4 ms 8572 KB
sample_01.txt AC 4 ms 8572 KB
sample_02.txt AC 4 ms 8572 KB
sample_03.txt AC 4 ms 8572 KB