Submission #2011977


Source Code Expand

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
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 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(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = 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 < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

#[allow(dead_code)]
const M: u64 = 1_000_000_007;

fn main() {
    let n = get!(usize);
    let mut aa = get!(u64; n);
    let mut bb = get!(u64; n);

    for x in &mut aa {
        *x += 1;
    }

    for x in &mut bb {
        *x += 1;
    }

    aa.sort();
    bb.sort();

    let mut seq = Vec::new();

    while !aa.is_empty() || !bb.is_empty() {
        if aa.last().cloned().unwrap_or(0) > bb.last().cloned().unwrap_or(0) {
            aa.pop();
            seq.push(true);
        } else {
            bb.pop();
            seq.push(false);
        }
    }

    let mut ans = 1;
    let mut t = 0i64;
    let mut y = 0;
    for &x in &seq {
        if x {
            t += 1;
        } else {
            t -= 1;
        }

        y += 1;
        if t == 0 {
            ans = ans * (y / 2) % M;
            y = 0;
        }
    }

    println!("{}", ans);
}

Submission Info

Submission Time
Task A - 1D Matching
User hatoo
Language Rust (1.15.1)
Score 0
Code Size 2936 Byte
Status WA
Exec Time 42 ms
Memory 6396 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 3
WA × 11
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt WA 25 ms 4352 KB
001.txt WA 10 ms 4352 KB
002.txt WA 13 ms 4352 KB
003.txt WA 15 ms 4352 KB
004.txt WA 37 ms 6396 KB
005.txt WA 42 ms 6396 KB
006.txt WA 42 ms 6396 KB
007.txt WA 42 ms 6396 KB
008.txt WA 42 ms 6396 KB
009.txt WA 42 ms 6396 KB
010.txt WA 41 ms 6396 KB
011.txt AC 42 ms 6396 KB
example0.txt AC 2 ms 4352 KB
example1.txt AC 2 ms 4352 KB