Submission #1405152
Source Code Expand
mod reader {
use std::fmt::Debug;
use std::str::FromStr;
use std::collections::VecDeque;
use std::io::{self, Read};
fn _read_line() -> String {
let mut buf = String::new();
let _ = io::stdin().read_to_string(&mut buf);
buf
}
fn _read_vec_deque_string() -> VecDeque<String> {
_read_line()
.split_whitespace()
.map(|s| s.to_string())
.collect()
}
#[allow(dead_code)]
pub struct Reader {
buf: VecDeque<String>,
}
#[allow(dead_code)]
impl Reader {
pub fn new() -> Reader {
Reader { buf: VecDeque::new() }
}
fn update_buf(&mut self) {
if self.buf.is_empty() {
self.buf = _read_vec_deque_string();
}
}
pub fn next<T>(&mut self) -> T
where
T: FromStr,
T::Err: Debug,
{
self.update_buf();
self.buf.pop_front().unwrap().parse::<T>().unwrap()
}
pub fn next_n<T>(&mut self, n: usize) -> Vec<T>
where
T: FromStr,
T::Err: Debug,
{
let mut vec: Vec<T> = Vec::with_capacity(n);
for _ in 0..n {
vec.push(self.next());
}
vec
}
}
}
#[allow(unused_macros)]
macro_rules! p {
([$($x:expr), *]) => {{
let mut f = true;
$(
print!("{}{}", if f {""} else {" "}, $x);
f = false;
)*
print!("\n");
}};
($x:expr) => {{
let mut f = true;
for a in $x.iter() {
print!("{}{}", if f {""} else {" "}, a);
f = false;
}
print!("\n");
}};
}
trait ToChars {
fn to_chars(&self) -> Vec<char>;
}
impl ToChars for String {
fn to_chars(&self) -> Vec<char> {
self.chars().collect::<Vec<char>>()
}
}
use std::collections::BTreeMap;
fn main() {
let mut r = reader::Reader::new();
let _: i32 = r.next();
let mut map: BTreeMap<(i32, i32), Vec<(i32, i32)>> = BTreeMap::new();
// LRUD
map.insert((0, 0), [(-1, 0), (1, 0), (0, 1), (0, -1)].to_vec());
let s = r.next::<String>().to_chars();
let mut cur = (0, 0);
for c in s {
let d = match c {
'L' => 0,
'R' => 1,
'U' => 2,
'D' => 3,
_ => 4,
};
let mut end = false;
while !end {
let nxt = map[&cur][d];
if map.get(&nxt).is_none() {
end = true;
let (x, y) = nxt;
map.insert(nxt, [(x - 1, y), (x + 1, y), (x, y + 1), (x, y - 1)].to_vec());
}
cur = nxt;
for (i, d) in [(-1, 0), (1, 0), (0, 1), (0, -1)].iter().enumerate() {
let x = cur.0 + d.0;
let y = cur.1 + d.1;
if map.get(&(x, y)).is_some() {
map.get_mut(&cur).unwrap()[i] = map[&(x, y)][i];
}
}
}
}
p!([cur.0, cur.1]);
}
Submission Info
Submission Time
2017-07-07 01:45:26+0900
Task
C - 幼稚園児高橋君
User
yuusti
Language
Rust (1.15.1)
Score
0
Code Size
3252 Byte
Status
TLE
Exec Time
4203 ms
Memory
30972 KB
Compile Error
warning: value assigned to `f` is never read, #[warn(unused_assignments)] on by default
--> ./Main.rs:67:13
|
67 | f = false;
| ^
...
131 | p!([cur.0, cur.1]);
| ------------------- in this macro invocation
Judge Result
Set Name
Sample
Subtask1
Score / Max Score
0 / 0
0 / 100
Status
Set Name
Test Cases
Sample
subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
Subtask1
subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt
Case Name
Status
Exec Time
Memory
subtask0_sample_01.txt
AC
2 ms
4352 KB
subtask0_sample_02.txt
AC
2 ms
4352 KB
subtask0_sample_03.txt
AC
2 ms
4352 KB
subtask1_01.txt
AC
2 ms
4352 KB
subtask1_02.txt
AC
2 ms
4352 KB
subtask1_03.txt
AC
2 ms
4352 KB
subtask1_04.txt
AC
2 ms
4352 KB
subtask1_05.txt
AC
2 ms
4352 KB
subtask1_06.txt
AC
2 ms
4352 KB
subtask1_07.txt
AC
463 ms
22780 KB
subtask1_08.txt
AC
483 ms
22780 KB
subtask1_09.txt
AC
538 ms
22780 KB
subtask1_10.txt
AC
445 ms
22780 KB
subtask1_11.txt
AC
506 ms
22780 KB
subtask1_12.txt
AC
552 ms
22780 KB
subtask1_13.txt
AC
493 ms
22780 KB
subtask1_14.txt
AC
86 ms
30972 KB
subtask1_15.txt
AC
72 ms
30972 KB
subtask1_16.txt
AC
258 ms
22780 KB
subtask1_17.txt
TLE
4203 ms
6396 KB
subtask1_18.txt
TLE
4203 ms
6396 KB
subtask1_19.txt
TLE
4203 ms
6396 KB
subtask1_20.txt
TLE
4203 ms
6396 KB
subtask1_21.txt
TLE
4203 ms
6396 KB