Skip to content

Commit b2e9059

Browse files
committed
Solve B in abc258
1 parent 91f7c8b commit b2e9059

File tree

1 file changed

+30
-1
lines changed
  • atcoder/rust/abc258/src/bin

1 file changed

+30
-1
lines changed

atcoder/rust/abc258/src/bin/b.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::cmp::*;
44
use std::collections::*;
5-
use std::io::Write;
5+
use std::io::{BufRead, Write};
66
use std::ops::Bound::*;
77

88
use itertools::*;
@@ -11,9 +11,38 @@ use itertools_num::ItertoolsNum;
1111
use proconio::*;
1212
use proconio::marker::*;
1313
use superslice::*;
14+
use whiteread::parse_string;
1415

1516
fn main() {
1617
input! {
18+
n: usize,
19+
a: [Chars; n],
20+
}
21+
22+
let a_nums = a.iter().
23+
map(|s| s.iter().map(|c| c.to_string().parse().unwrap()).collect::<Vec<usize>>()).
24+
collect::<Vec<Vec<usize>>>();
1725

26+
let n = n as i64;
27+
let mut max_total = 0usize;
28+
for y in 0..n {
29+
for x in 0..n {
30+
for (y_diff, x_diff) in vec![(1, 0), (0, 1), (1, 1), (0, -1), (-1, 1), (-1, 0), (1, -1), (-1, -1)].iter() {
31+
let mut total = 0usize;
32+
let mut cur_y = y;
33+
let mut cur_x = x;
34+
for i in 0..n {
35+
total *= 10;
36+
total += a_nums[cur_y as usize][cur_x as usize];
37+
cur_y = (cur_y + n + y_diff) % n;
38+
cur_x = (cur_x + n + x_diff) % n;
39+
}
40+
if total > max_total {
41+
max_total = total;
42+
}
43+
}
44+
}
1845
}
46+
47+
println!("{}", max_total);
1948
}

0 commit comments

Comments
 (0)