結果

問題 No.18 うーさー暗号
コンテスト
ユーザー tshig
提出日時 2016-08-24 13:55:05
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 713 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,771 ms
コンパイル使用メモリ 188,928 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-28 21:19:43
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn run(args: &Vec<String>) -> Vec<String> {
    let ref s = args[0];

    let ca = 'A' as u32;
    let cz = 'Z' as u32;
    let a = cz - ca + 1;

    let cs = s
        .chars().enumerate()
        .map(|(i, c)| {
            let c1 = (c as u32) - ca;
            let c2 = (c1 + a - (i as u32) % a - 1) % a;
            (c2 + ca) as u8
        })
        .collect();
    vec!(String::from_utf8(cs).unwrap())
}

fn main() {
    let args = lines(BufReader::new(io::stdin()));
    for line in run(&args) {
        println!("{}", line);
    }
}

fn lines<R: Read>(reader: BufReader<R>) -> Vec<String> {
    reader.lines().map(|l| l.unwrap()).collect()
}
0