Submission #59169332


Source Code Expand

use proconio::input;

pub fn main() {
    input! {
        n: usize,
        m: usize,
        abm: [(usize, usize); m]
    }
    let mut visited = std::collections::HashSet::new();
    for ab in abm.clone() {
        visited.insert(ab);
    }
    for (a, b) in abm {
        if a + 2 <= n && b + 1 <= n {
            visited.insert((a + 2, b + 1));
        }
        if a + 2 <= n && b - 1 >= 1 {
            visited.insert((a + 2, b - 1));
        }
        if a.saturating_sub(2) >= 1 && b + 1 <= n {
            visited.insert((a.saturating_sub(2), b + 1));
        }
        if a.saturating_sub(2) >= 1 && b - 1 >= 1 {
            visited.insert((a.saturating_sub(2), b - 1));
        }
        if a + 1 <= n && b + 2 <= n {
            visited.insert((a + 1, b + 2));
        }
        if a + 1 <= n && b.saturating_sub(2) >= 1 {
            visited.insert((a + 1, b.saturating_sub(2)));
        }
        if a - 1 >= 1 && b + 2 <= n {
            visited.insert((a - 1, b + 2));
        }
        if a - 1 >= 1 && b.saturating_sub(2) >= 1 {
            visited.insert((a - 1, b.saturating_sub(2)));
        }
    }
    println!("{}", n * n - visited.len());
}

Submission Info

Submission Time
Task C - Avoid Knight Attack
User macaroon
Language Rust (rustc 1.70.0)
Score 300
Code Size 1207 Byte
Status AC
Exec Time 200 ms
Memory 61072 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 2080 KiB
00_sample_01.txt AC 1 ms 1784 KiB
00_sample_02.txt AC 0 ms 1880 KiB
01_random_03.txt AC 71 ms 16140 KiB
01_random_04.txt AC 131 ms 32480 KiB
01_random_05.txt AC 199 ms 59304 KiB
01_random_06.txt AC 197 ms 59808 KiB
01_random_07.txt AC 195 ms 60632 KiB
01_random_08.txt AC 200 ms 61032 KiB
01_random_09.txt AC 18 ms 6332 KiB
01_random_10.txt AC 106 ms 31724 KiB
01_random_11.txt AC 118 ms 56708 KiB
01_random_12.txt AC 13 ms 8944 KiB
01_random_13.txt AC 154 ms 58612 KiB
01_random_14.txt AC 18 ms 9312 KiB
01_random_15.txt AC 0 ms 1932 KiB
01_random_16.txt AC 1 ms 1916 KiB
01_random_17.txt AC 0 ms 1908 KiB
01_random_18.txt AC 0 ms 1920 KiB
01_random_19.txt AC 1 ms 1928 KiB
01_random_20.txt AC 0 ms 1916 KiB
01_random_21.txt AC 1 ms 1924 KiB
01_random_22.txt AC 1 ms 1984 KiB
01_random_23.txt AC 71 ms 16252 KiB
01_random_24.txt AC 130 ms 32488 KiB
01_random_25.txt AC 187 ms 59380 KiB
01_random_26.txt AC 194 ms 59872 KiB
01_random_27.txt AC 198 ms 60520 KiB
01_random_28.txt AC 189 ms 61072 KiB
01_random_29.txt AC 1 ms 2148 KiB
01_random_30.txt AC 18 ms 6312 KiB
01_random_31.txt AC 106 ms 32320 KiB
01_random_32.txt AC 5 ms 3892 KiB
01_random_33.txt AC 1 ms 1884 KiB
01_random_34.txt AC 92 ms 32672 KiB