Submission #743188


Source Code Expand

Copy
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}

macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

struct UnionFind { table: Vec<i32> }
impl UnionFind {

    fn new(n: usize) -> UnionFind {
        UnionFind { table: vec![-1; n], }
    }

    fn root(&mut self, x: i32) -> i32 {
        if self.table[x as usize] < 0 {
            x
        } else {
            let px = self.table[x as usize];
            let r = self.root(px);
            self.table[x as usize] = r;
            r
        }
    }

    fn merge(&mut self, x: i32, y: i32) {
        let mut rx = self.root(x) as usize;
        let mut ry = self.root(y) as usize;
        if rx != ry {
            if self.table[ry] < self.table[rx] { swap!(rx, ry) }
            self.table[rx] += self.table[ry];
            self.table[ry] = rx as i32;
        }
    }

    fn size(&mut self, x: i32) -> i32 {
        let r = self.root(x);
        return -self.table[r as usize]
    }

}

fn main() {
    let mut sc = Scanner::new();
    let a: i32 = sc.cin();
    let b: i32 = sc.cin();
    let c: i32 = sc.cin();
    let d: i32 = sc.cin();

    let bl = a == c || a==d || b==c || b==d;

    println!("{}", if bl { "YES" } else { "NO" });
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}

Submission Info

Submission Time
Task B - ディスプレイ
User cympfh
Language Rust (1.15.1)
Score 100
Code Size 2524 Byte
Status
Exec Time 4 ms
Memory 380 KB

Compile Error

./Main.rs:1:22: 1:27 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:1 use std::io::{ self, Write };
                                 ^~~~~
./Main.rs:3:17: 3:20 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:3 use std::cmp::{ min, max };
                            ^~~
./Main.rs:3:22: 3:25 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:3 use std::cmp::{ min, max };
                                 ^~~
./Main.rs:4:25: 4:35 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:4 use std::collections::{ BinaryHeap, VecDeque };
                                    ^~~~~~~~~~
./Main.rs:14:1: 14:37 warning: struct is never used: `UnionFind`, #[warn(dead_code)] on by default
./Main.rs:14 struct UnionFind { table: Vec<i32> }
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.rs:17:5: 19:6 warning: method is never used: `new`, #[warn(dead_code)] on by default
./Main.rs:17     fn new(n: usize) -> UnionFind {
./Main.rs...

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample0.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
All 100 / 100 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
sample0.txt 4 ms 380 KB
sample1.txt 4 ms 380 KB
sample2.txt 4 ms 380 KB
sample3.txt 4 ms 380 KB
sample4.txt 4 ms 380 KB
subtask1_0.txt 4 ms 380 KB
subtask1_1.txt 4 ms 380 KB
subtask1_10.txt 4 ms 380 KB
subtask1_11.txt 4 ms 380 KB
subtask1_12.txt 4 ms 380 KB
subtask1_13.txt 4 ms 380 KB
subtask1_14.txt 4 ms 380 KB
subtask1_2.txt 4 ms 380 KB
subtask1_3.txt 4 ms 380 KB
subtask1_4.txt 4 ms 380 KB
subtask1_5.txt 4 ms 380 KB
subtask1_6.txt 4 ms 380 KB
subtask1_7.txt 4 ms 380 KB
subtask1_8.txt 4 ms 380 KB
subtask1_9.txt 4 ms 380 KB