Submission #63068955
Source Code Expand
use std::collections::VecDeque; use itertools::Itertools; use proconio::{input, marker::Chars}; fn main() { input!{ n: usize, c: [Chars; n], } let mut seen = vec![vec![INF; n]; n]; let mut que = VecDeque::new(); for i in 0..n { seen[i][i] = 0; que.push_back((i, i)); } for i in 0..n { for j in 0..n { if i == j { continue; } if c[i][j] != '-' { seen[i][j] = 1; que.push_back((i, j)); } } } while let Some((pi, pj)) = que.pop_front() { for ni in 0..n { for nj in 0..n { if c[ni][pi] == c[pj][nj] && c[ni][pi] != '-' && seen[ni][nj] == INF { seen[ni][nj] = seen[pi][pj] + 2; que.push_back((ni, nj)); } } } } println!("{}", seen.iter().map(|v| v.iter().map(|vi| if vi == &INF { -1 } else { *vi as i64 }).join(" ")).join("\n")); } 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 | E - Palindromic Shortest Path |
User | ardRiriy |
Language | Rust (rustc 1.70.0) |
Score | 450 |
Code Size | 1200 Byte |
Status | AC |
Exec Time | 160 ms |
Memory | 2348 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt |
All | sample00.txt, sample01.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt, testcase44.txt, testcase45.txt, testcase46.txt, testcase47.txt, testcase48.txt, testcase49.txt, testcase50.txt, testcase51.txt, testcase52.txt, testcase53.txt, testcase54.txt, testcase55.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 1748 KiB |
sample01.txt | AC | 1 ms | 2100 KiB |
testcase00.txt | AC | 1 ms | 1916 KiB |
testcase01.txt | AC | 1 ms | 1936 KiB |
testcase02.txt | AC | 4 ms | 1920 KiB |
testcase03.txt | AC | 160 ms | 2224 KiB |
testcase04.txt | AC | 1 ms | 1976 KiB |
testcase05.txt | AC | 2 ms | 2056 KiB |
testcase06.txt | AC | 3 ms | 2256 KiB |
testcase07.txt | AC | 3 ms | 2064 KiB |
testcase08.txt | AC | 5 ms | 2012 KiB |
testcase09.txt | AC | 9 ms | 2204 KiB |
testcase10.txt | AC | 2 ms | 2008 KiB |
testcase11.txt | AC | 10 ms | 2128 KiB |
testcase12.txt | AC | 6 ms | 2088 KiB |
testcase13.txt | AC | 10 ms | 2100 KiB |
testcase14.txt | AC | 2 ms | 1816 KiB |
testcase15.txt | AC | 11 ms | 1996 KiB |
testcase16.txt | AC | 1 ms | 1988 KiB |
testcase17.txt | AC | 4 ms | 2168 KiB |
testcase18.txt | AC | 1 ms | 2060 KiB |
testcase19.txt | AC | 5 ms | 2092 KiB |
testcase20.txt | AC | 9 ms | 2076 KiB |
testcase21.txt | AC | 95 ms | 2184 KiB |
testcase22.txt | AC | 34 ms | 2220 KiB |
testcase23.txt | AC | 103 ms | 2192 KiB |
testcase24.txt | AC | 9 ms | 2088 KiB |
testcase25.txt | AC | 111 ms | 2336 KiB |
testcase26.txt | AC | 12 ms | 2032 KiB |
testcase27.txt | AC | 96 ms | 2300 KiB |
testcase28.txt | AC | 35 ms | 2220 KiB |
testcase29.txt | AC | 104 ms | 2244 KiB |
testcase30.txt | AC | 15 ms | 2076 KiB |
testcase31.txt | AC | 111 ms | 2288 KiB |
testcase32.txt | AC | 29 ms | 2044 KiB |
testcase33.txt | AC | 95 ms | 2252 KiB |
testcase34.txt | AC | 13 ms | 2176 KiB |
testcase35.txt | AC | 104 ms | 2120 KiB |
testcase36.txt | AC | 25 ms | 2152 KiB |
testcase37.txt | AC | 111 ms | 2288 KiB |
testcase38.txt | AC | 41 ms | 2088 KiB |
testcase39.txt | AC | 97 ms | 2148 KiB |
testcase40.txt | AC | 99 ms | 2192 KiB |
testcase41.txt | AC | 105 ms | 2256 KiB |
testcase42.txt | AC | 23 ms | 2084 KiB |
testcase43.txt | AC | 114 ms | 2276 KiB |
testcase44.txt | AC | 12 ms | 2044 KiB |
testcase45.txt | AC | 31 ms | 2208 KiB |
testcase46.txt | AC | 13 ms | 1944 KiB |
testcase47.txt | AC | 92 ms | 2308 KiB |
testcase48.txt | AC | 62 ms | 2184 KiB |
testcase49.txt | AC | 99 ms | 2132 KiB |
testcase50.txt | AC | 39 ms | 2128 KiB |
testcase51.txt | AC | 101 ms | 2124 KiB |
testcase52.txt | AC | 11 ms | 2040 KiB |
testcase53.txt | AC | 104 ms | 2348 KiB |
testcase54.txt | AC | 64 ms | 2188 KiB |
testcase55.txt | AC | 110 ms | 2264 KiB |