結果
問題 | No.1455 拡張ROTN |
ユーザー |
![]() |
提出日時 | 2021-03-31 21:18:12 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 4,221 bytes |
コンパイル時間 | 11,701 ms |
コンパイル使用メモリ | 398,664 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-15 14:10:44 |
合計ジャッジ時間 | 12,641 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#![allow(unused_macros)]#![allow(dead_code)]#![allow(unused_imports)]// # ファイル構成// - use 宣言// - lib モジュール// - main 関数// - basic モジュール//// 常に使うテンプレートライブラリは basic モジュール内にあります。// 問題に応じて使うライブラリ lib モジュール内にコピペしています。// ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder// Twitter はこちら → https://twitter.com/RheoTommyuse std::collections::*;use std::io::{stdout, BufWriter, Write};use crate::basic::*;use crate::lib::*;pub mod lib {}fn main() {let mut sc = Scanner::new();let mut s = sc.next_chars();let mut n = sc.next_usize();while n > 0 && s.iter().any(|ci| ci.is_digit(10)) {let mut t = String::new();for si in s {if 'a' <= si && si <= 'y' {t.push((si as u8 + 1) as char);} else if si == 'z' {t.push('a');} else if 'A' <= si && si <= 'Y' {t.push((si as u8 + 1) as char);} else if si == 'Z' {t.push('A')} else if si.is_digit(10) {if si.to_digit(10).unwrap() == 9 {for ti in "CpCzNkSuTbEoA".chars() {t.push(ti);}} else {t.push_str(&(si.to_digit(10).unwrap() + 1).to_string());}}}n -= 1;s = t.chars().collect();}if n == 0 {println!("{}", s.into_iter().collect::<String>());return;}// eprintln!("{:?}", s);let s = s.into_iter().map(|ci| {if ci.is_lowercase() {(b'a' + (((ci as u8 - b'a') as usize + n) % 26) as u8) as char} else {(b'A' + (((ci as u8 - b'A') as usize + n) % 26) as u8) as char}}).collect::<String>();println!("{}", s);}pub mod basic {pub const U_INF: u64 = (1 << 60) + (1 << 30);pub const I_INF: i64 = (1 << 60) + (1 << 30);pub struct Scanner {buf: std::collections::VecDeque<String>,reader: std::io::BufReader<std::io::Stdin>,}impl Scanner {pub fn new() -> Self {Self {buf: std::collections::VecDeque::new(),reader: std::io::BufReader::new(std::io::stdin()),}}fn scan_line(&mut self) {use std::io::BufRead;let mut flag = 0;while self.buf.is_empty() {let mut s = String::new();self.reader.read_line(&mut s).unwrap();let mut iter = s.split_whitespace().peekable();if iter.peek().is_none() {if flag >= 5 {panic!("There is no input!");}flag += 1;continue;}for si in iter {self.buf.push_back(si.to_string());}}}pub fn next<T: std::str::FromStr>(&mut self) -> T {self.scan_line();self.buf.pop_front().unwrap().parse().unwrap_or_else(|_| panic!("Couldn't parse!"))}pub fn next_usize(&mut self) -> usize {self.next()}pub fn next_int(&mut self) -> i64 {self.next()}pub fn next_uint(&mut self) -> u64 {self.next()}pub fn next_chars(&mut self) -> Vec<char> {self.next::<String>().chars().collect()}pub fn next_string(&mut self) -> String {self.next()}pub fn next_char(&mut self) -> char {self.next()}pub fn next_float(&mut self) -> f64 {self.next()}pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {(0..n).map(|_| self.next()).collect::<Vec<_>>()}}}