Submission #1869348
Source Code Expand
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
use std::io::stdin;
use std::str::FromStr;
use std::fmt::Debug;
#[allow(dead_code)]
pub fn line() -> String {
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
#[allow(dead_code)]
pub fn gets<T: FromStr>() -> Vec<T>
where
<T as FromStr>::Err: Debug,
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse().unwrap())
.collect()
}
}
#[allow(unused_macros)]
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
(
$(iter.next().unwrap().parse::<$t>().unwrap(),)*
)
}
};
($t:ty; $n:expr) => {
(0..$n).map(|_|
get!($t)
).collect::<Vec<_>>()
};
($($t:ty),*; $n:expr) => {
(0..$n).map(|_|
get!($($t),*)
).collect::<Vec<_>>()
};
($t:ty ;;) => {
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|t| t.parse::<$t>().unwrap())
.collect::<Vec<_>>()
}
};
}
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
fn main() {
let (h, w) = get!(usize, usize);
let aa: Vec<Vec<char>> = (0..h)
.map(|_| util::line().chars().collect::<Vec<_>>())
.collect();
let n = aa.iter()
.map(|v| v.iter().filter(|&&c| c == '#').count())
.sum::<usize>();
let mut stack = vec![(0, 0, 1)];
while let Some((y, x, c)) = stack.pop() {
if y == h - 1 && x == w - 1 && c == n {
println!("Possible");
return;
}
if y < h && x < w && aa[y][x] == '#' {
stack.push((y + 1, x, c + 1));
stack.push((y, x + 1, c + 1));
}
}
println!("Impossible");
}
Submission Info
Submission Time |
|
Task |
A - Shik and Stone |
User |
hatoo |
Language |
Rust (1.15.1) |
Score |
200 |
Code Size |
2830 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
4352 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt, example2.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
2 ms |
4352 KB |
001.txt |
AC |
2 ms |
4352 KB |
002.txt |
AC |
2 ms |
4352 KB |
003.txt |
AC |
2 ms |
4352 KB |
004.txt |
AC |
2 ms |
4352 KB |
005.txt |
AC |
2 ms |
4352 KB |
006.txt |
AC |
2 ms |
4352 KB |
007.txt |
AC |
2 ms |
4352 KB |
008.txt |
AC |
2 ms |
4352 KB |
009.txt |
AC |
2 ms |
4352 KB |
010.txt |
AC |
2 ms |
4352 KB |
011.txt |
AC |
2 ms |
4352 KB |
012.txt |
AC |
2 ms |
4352 KB |
013.txt |
AC |
2 ms |
4352 KB |
014.txt |
AC |
2 ms |
4352 KB |
015.txt |
AC |
2 ms |
4352 KB |
016.txt |
AC |
2 ms |
4352 KB |
017.txt |
AC |
2 ms |
4352 KB |
018.txt |
AC |
2 ms |
4352 KB |
example0.txt |
AC |
2 ms |
4352 KB |
example1.txt |
AC |
2 ms |
4352 KB |
example2.txt |
AC |
2 ms |
4352 KB |