結果

問題 No.18 うーさー暗号
ユーザー SarievoSarievo
提出日時 2023-05-19 20:32:08
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,497 bytes
コンパイル時間 12,914 ms
コンパイル使用メモリ 391,852 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-10 04:40:20
合計ジャッジ時間 13,907 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: constant `DX` is never used
 --> src/main.rs:1:7
  |
1 | const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1];
  |       ^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: constant `DY` is never used
 --> src/main.rs:2:7
  |
2 | const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1];
  |       ^^

ソースコード

diff #

const DX: [i32; 8] = [0, 1, 0, -1, 1, 1, -1, -1];
const DY: [i32; 8] = [1, 0, -1, 0, 1, -1, -1, 1];

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.chars();
    let s = s.iter().enumerate().map(|(i, c)|
        'A' as u8 + (26 + (*c as u8 - 'A' as u8) - (i as u8 + 1) % 26) % 26
    ).collect();
    println!("{}", String::from_utf8(s).unwrap());
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self { Self(r, std::io::BufWriter::new(w)) }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.0.by_ref().bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }.parse().ok().expect("Parse error.")
    }
    pub fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() }
    pub fn usize0(&mut self) -> usize { self.read::<usize>() - 1 }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
}
0