Submission #67362363
Source Code Expand
use std::{collections::VecDeque}; #[allow(unused_imports)] use proconio::input; use proconio::marker::Usize1; fn main() { input!{ h: usize, w: usize, k: usize, rc: [(Usize1, Usize1); k], } let mut seen = vec![vec![INF; w]; h]; let mut que = VecDeque::new(); for &(r, c) in rc.iter() { que.push_back((r,c,0)); } // eprintln!("{}", seen.iter().map(|v| v.iter().map(|x| if *x==INF { -1 } else {*x as i64}).join(" ")).join("\n")); // eprintln!(); while let Some((pi,pj, c)) = que.pop_front() { if seen[pi][pj] != INF { continue; } seen[pi][pj] = c; // dbg!(&que); // eprintln!("{}", seen.iter().map(|v| v.iter().map(|x| if *x==INF { -1 } else {*x as i64}).join(" ")).join("\n")); // eprintln!(); for r in 0..4 { let ni = pi.wrapping_add(DI[r]); let nj = pj.wrapping_add(DJ[r]); if ni >= h || nj >= w || seen[ni][nj] != INF { continue; } let mut v = vec![]; for rr in 0..4 { let nni = ni.wrapping_add(DI[rr]); let nnj = nj.wrapping_add(DJ[rr]); if nni >= h || nnj >= w || seen[nni][nnj] == INF { continue; } v.push(seen[nni][nnj]); } if v.len() >= 2 { v.sort(); // dbg!((ni,nj)); que.push_back((ni, nj, v[1]+1)); } } } let ans = seen.iter().flatten().map(|x| if *x==INF { 0 } else { *x }).sum::<u64>(); println!("{}", ans); } pub static INF: u64 = 1e18 as u64; pub static DI: &[usize] = &[0, !0, 0, 1, !0, 1, !0, 1]; pub static DJ: &[usize] = &[!0, 0, 1, 0, !0, !0, 1, 1]; pub static DC: &[char] = &['L', 'U', 'R', 'D'];
Submission Info
Submission Time | |
---|---|
Task | F - No Passage |
User | ardRiriy |
Language | Rust (rustc 1.70.0) |
Score | 525 |
Code Size | 1959 Byte |
Status | AC |
Exec Time | 605 ms |
Memory | 72756 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 525 / 525 | ||||
Status |
|
|
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_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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 1932 KiB |
00_sample_01.txt | AC | 0 ms | 1940 KiB |
00_sample_02.txt | AC | 0 ms | 1932 KiB |
01_test_00.txt | AC | 0 ms | 2000 KiB |
01_test_01.txt | AC | 0 ms | 1932 KiB |
01_test_02.txt | AC | 1 ms | 2024 KiB |
01_test_03.txt | AC | 1 ms | 2004 KiB |
01_test_04.txt | AC | 1 ms | 2168 KiB |
01_test_05.txt | AC | 0 ms | 2000 KiB |
01_test_06.txt | AC | 1 ms | 2064 KiB |
01_test_07.txt | AC | 1 ms | 1992 KiB |
01_test_08.txt | AC | 1 ms | 2136 KiB |
01_test_09.txt | AC | 1 ms | 2268 KiB |
01_test_10.txt | AC | 4 ms | 4852 KiB |
01_test_11.txt | AC | 3 ms | 3476 KiB |
01_test_12.txt | AC | 1 ms | 2256 KiB |
01_test_13.txt | AC | 2 ms | 2788 KiB |
01_test_14.txt | AC | 5 ms | 7244 KiB |
01_test_15.txt | AC | 3 ms | 3712 KiB |
01_test_16.txt | AC | 2 ms | 2976 KiB |
01_test_17.txt | AC | 5 ms | 8804 KiB |
01_test_18.txt | AC | 9 ms | 14800 KiB |
01_test_19.txt | AC | 7 ms | 11352 KiB |
01_test_20.txt | AC | 23 ms | 43076 KiB |
01_test_21.txt | AC | 4 ms | 6424 KiB |
01_test_22.txt | AC | 37 ms | 7204 KiB |
01_test_23.txt | AC | 141 ms | 28196 KiB |
01_test_24.txt | AC | 310 ms | 46548 KiB |
01_test_25.txt | AC | 537 ms | 69872 KiB |
01_test_26.txt | AC | 39 ms | 72568 KiB |
01_test_27.txt | AC | 38 ms | 72564 KiB |
01_test_28.txt | AC | 37 ms | 72656 KiB |
01_test_29.txt | AC | 39 ms | 72524 KiB |
01_test_30.txt | AC | 1 ms | 2172 KiB |
01_test_31.txt | AC | 40 ms | 7516 KiB |
01_test_32.txt | AC | 120 ms | 63124 KiB |
01_test_33.txt | AC | 148 ms | 72656 KiB |
01_test_34.txt | AC | 584 ms | 72756 KiB |
01_test_35.txt | AC | 605 ms | 72540 KiB |
01_test_36.txt | AC | 1 ms | 1992 KiB |
01_test_37.txt | AC | 0 ms | 2152 KiB |
01_test_38.txt | AC | 1 ms | 2228 KiB |
01_test_39.txt | AC | 38 ms | 72388 KiB |
01_test_40.txt | AC | 0 ms | 2036 KiB |