Submission #61203019


Source Code Expand

use std::collections::{BTreeMap, HashMap};

use proconio::{input, marker::Chars};

pub fn main() {
    input! {
        n: usize,
        m: usize,
        mut yxcm: [(usize, usize, char); m]
    };
    yxcm.sort_by(|a, b| b.0.cmp(&a.0).then(a.1.cmp(&b.1)));
    let mut w_row_forbidden_map: BTreeMap<usize, usize> = BTreeMap::new();
    let mut b_row_forbidden_map: BTreeMap<usize, usize> = BTreeMap::new();
    let mut w_column_forbidden_map: BTreeMap<usize, usize> = BTreeMap::new();
    let mut b_column_forbidden_map: BTreeMap<usize, usize> = BTreeMap::new();
    for &(y, x, c) in yxcm.iter().cycle().take(2 * n) {
        if c == 'W' {
            if let Some((k, v)) = w_row_forbidden_map.range(&x..).next() {
                if *v > y {
                    println!("{}", "No");
                    return;
                }
            }
            if let Some(v) = b_row_forbidden_map.get_mut(&x) {
                if *v < y {
                    *v = y;
                }
            } else {
                b_row_forbidden_map.insert(x, y);
            }
            if let Some((k, v)) = w_column_forbidden_map.range(&y..).next() {
                if *v > x {
                    println!("{}", "No");
                    return;
                }
            }
            if let Some(v) = b_column_forbidden_map.get_mut(&y) {
                if *v < x {
                    *v = x;
                }
            } else {
                b_column_forbidden_map.insert(y, x);
            }
        } else {
            if let Some((k, v)) = b_row_forbidden_map.range(..=&x).rev().next() {
                if *v < y {
                    println!("{}", "No");
                    return;
                }
            }
            if let Some(v) = w_row_forbidden_map.get_mut(&x) {
                if *v > y {
                    *v = y;
                }
            } else {
                w_row_forbidden_map.insert(x, y);
            }
            if let Some((k, v)) = b_column_forbidden_map.range(..=&y).rev().next() {
                if *v < x {
                    println!("{}", "No");
                    return;
                }
            }
            if let Some(v) = w_column_forbidden_map.get_mut(&y) {
                if *v > x {
                    *v = x;
                }
            } else {
                w_column_forbidden_map.insert(y, x);
            }
        }
    }
    println!("{}", "Yes");
}

Submission Info

Submission Time
Task D - Diagonal Separation
User macaroon
Language Rust (rustc 1.70.0)
Score 0
Code Size 2519 Byte
Status TLE
Exec Time 2210 ms
Memory 25372 KiB

Compile Error

warning: unused import: `HashMap`
 --> src/main.rs:1:34
  |
1 | use std::collections::{BTreeMap, HashMap};
  |                                  ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `marker::Chars`
 --> src/main.rs:3:23
  |
3 | use proconio::{input, marker::Chars};
  |                       ^^^^^^^^^^^^^

warning: unused variable: `k`
  --> src/main.rs:18:26
   |
18 |             if let Some((k, v)) = w_row_forbidden_map.range(&x..).next() {
   |                          ^ help: if this is intentional, prefix it with an underscore: `_k`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `k`
  --> src/main.rs:31:26
   |
31 |             if let Some((k, v)) = w_column_forbidden_map.range(&y..).next() {
   |                          ^ help: if this is intentional, prefix it with an underscore: `_k`

warning: unused variable: `k`
  --> src/main.rs:45:26
   |
45 |             if let Some((k, v)) = b_row_forbidden_map.range(..=&x).rev().next() {
   |                          ^ help: if this is intentional, prefix it with an underscore: `_k`

warning: unused variable: `k`
  --> src/main.rs:58:26
   |
58 |             if let Some((k, v)) = b_column_forbidden_map.range(..=&y).rev().next() {
   |                          ^ help: if this is intentional, prefix it with an underscore: `_k`

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
AC × 4
AC × 43
TLE × 20
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt, 01_test_46.txt, 01_test_47.txt, 01_test_48.txt, 01_test_49.txt, 01_test_50.txt, 01_test_51.txt, 01_test_52.txt, 01_test_53.txt, 01_test_54.txt, 01_test_55.txt, 01_test_56.txt, 01_test_57.txt, 01_test_58.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 0 ms 1928 KiB
00_sample_01.txt AC 0 ms 1864 KiB
00_sample_02.txt AC 0 ms 1980 KiB
00_sample_03.txt AC 0 ms 1852 KiB
01_test_00.txt AC 0 ms 1856 KiB
01_test_01.txt AC 0 ms 1972 KiB
01_test_02.txt AC 0 ms 2104 KiB
01_test_03.txt AC 0 ms 1900 KiB
01_test_04.txt AC 29 ms 10440 KiB
01_test_05.txt AC 26 ms 9736 KiB
01_test_06.txt AC 21 ms 8096 KiB
01_test_07.txt AC 8 ms 4168 KiB
01_test_08.txt AC 13 ms 5720 KiB
01_test_09.txt AC 11 ms 5212 KiB
01_test_10.txt AC 32 ms 12872 KiB
01_test_11.txt AC 20 ms 8564 KiB
01_test_12.txt AC 31 ms 12868 KiB
01_test_13.txt AC 10 ms 5204 KiB
01_test_14.txt TLE 2208 ms 25156 KiB
01_test_15.txt TLE 2208 ms 22440 KiB
01_test_16.txt TLE 2208 ms 25372 KiB
01_test_17.txt TLE 2208 ms 15036 KiB
01_test_18.txt AC 52 ms 16476 KiB
01_test_19.txt AC 7 ms 4128 KiB
01_test_20.txt AC 38 ms 12860 KiB
01_test_21.txt AC 24 ms 8568 KiB
01_test_22.txt TLE 2208 ms 23712 KiB
01_test_23.txt TLE 2210 ms 6424 KiB
01_test_24.txt TLE 2208 ms 23788 KiB
01_test_25.txt TLE 2208 ms 7540 KiB
01_test_26.txt AC 38 ms 12820 KiB
01_test_27.txt AC 76 ms 18496 KiB
01_test_28.txt AC 72 ms 18644 KiB
01_test_29.txt AC 17 ms 7180 KiB
01_test_30.txt TLE 2208 ms 23776 KiB
01_test_31.txt TLE 2208 ms 13608 KiB
01_test_32.txt TLE 2208 ms 23816 KiB
01_test_33.txt TLE 2208 ms 13020 KiB
01_test_34.txt TLE 2208 ms 18208 KiB
01_test_35.txt TLE 2208 ms 14740 KiB
01_test_36.txt TLE 2208 ms 18108 KiB
01_test_37.txt TLE 2207 ms 5512 KiB
01_test_38.txt AC 44 ms 12852 KiB
01_test_39.txt AC 33 ms 9336 KiB
01_test_40.txt AC 39 ms 12708 KiB
01_test_41.txt AC 11 ms 5024 KiB
01_test_42.txt TLE 2208 ms 16412 KiB
01_test_43.txt TLE 2207 ms 4404 KiB
01_test_44.txt TLE 2208 ms 16444 KiB
01_test_45.txt TLE 2208 ms 8392 KiB
01_test_46.txt AC 67 ms 19920 KiB
01_test_47.txt AC 23 ms 8140 KiB
01_test_48.txt AC 65 ms 19408 KiB
01_test_49.txt AC 24 ms 10148 KiB
01_test_50.txt AC 38 ms 12824 KiB
01_test_51.txt AC 51 ms 15772 KiB
01_test_52.txt AC 87 ms 24380 KiB
01_test_53.txt AC 60 ms 17932 KiB
01_test_54.txt AC 36 ms 12888 KiB
01_test_55.txt AC 7 ms 3212 KiB
01_test_56.txt AC 80 ms 16980 KiB
01_test_57.txt AC 14 ms 4584 KiB
01_test_58.txt AC 0 ms 1916 KiB