Skip to content

Commit 24e17a1

Browse files
committed
add abc398d.rs
1 parent 1b52cd4 commit 24e17a1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/abc/abc398d.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/** THIS IS AN OUTPUT FILE. NOT EDIT THIS FILE DIRECTLY. **/
2+
use proconio::input;
3+
use proconio::marker::*;
4+
use std::marker::PhantomData;
5+
use std::cmp::*;
6+
use std::collections::*;
7+
8+
fn main() {
9+
input! {
10+
n:usize,
11+
r:isize,
12+
c:isize,
13+
s:Chars
14+
}
15+
16+
let mut map = HashMap::new();
17+
map.insert('N',(-1,0));
18+
map.insert('W',(0,-1));
19+
map.insert('S',(1,0));
20+
map.insert('E',(0,1));
21+
22+
let tr = r;
23+
let tc = c;
24+
25+
let mut cx = 0;
26+
let mut cy = 0;
27+
let mut result = vec![];
28+
let mut set = HashSet::new();
29+
set.insert((cx,cy));
30+
for c in s {
31+
if let Some(&(ai,aj)) = map.get(&c) {
32+
cx += ai;
33+
cy += aj;
34+
35+
set.insert((-1*cx, -1*cy));
36+
}
37+
38+
let rr = tr - cx;
39+
let rc = tc - cy;
40+
if set.contains(&(rr,rc)) {
41+
result.push(format!("1"));
42+
} else {
43+
result.push(format!("0"));
44+
}
45+
}
46+
println!("{}", result.into_iter().collect::<String>());
47+
}

0 commit comments

Comments
 (0)