ログインしてください。
提出 #16382713
ソースコード 拡げる
#![allow(clippy::many_single_char_names)]
// ngtio {{{
#[allow(dead_code)]
mod ngtio {
use ::std::collections::VecDeque;
pub struct Buffer {
buf: VecDeque<String>,
}
impl Buffer {
pub fn new() -> Self {
Self {
buf: VecDeque::new(),
}
}
fn load(&mut self) {
while self.buf.is_empty() {
let mut s = String::new();
let length = ::std::io::stdin().read_line(&mut s).unwrap();
if length == 0 {
break;
}
self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
}
}
pub fn string(&mut self) -> String {
self.load();
self.buf
.pop_front()
.unwrap_or_else(|| panic!("入力が終了したのですが。"))
}
pub fn char(&mut self) -> char {
let string = self.string();
let mut chars = string.chars();
let res = chars.next().unwrap();
assert!(
chars.next().is_none(),
"char で受け取りたいのも山々なのですが、さては 2 文字以上ありますね?"
);
res
}
pub fn read<T: ::std::str::FromStr>(&mut self) -> T
where
<T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
{
self.string()
.parse::<T>()
.expect("Failed to parse the input.")
}
pub fn read_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
where
<T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
{
(0..len).map(|_| self.read::<T>()).collect()
}
}
macro_rules! define_primitive_reader {
($($ty:tt,)*) => {
impl Buffer {
$(
#[inline]
pub fn $ty(&mut self) -> $ty {
self.read::<$ty>()
}
)*
}
}
}
define_primitive_reader! {
u8, u16, u32, u64, usize,
i8, i16, i32, i64, isize,
}
impl Default for Buffer {
fn default() -> Self {
Self::new()
}
}
}
// }}}
fn main() {
let mut buf = ngtio::Buffer::new();
let n = buf.usize();
let s = buf.string();
let mut s = s.chars().collect::<Vec<_>>();
for i in 0..=n - 3 {
if &s[i..i + 3] == ['j', 'o', 'i'] {
s[i] = 'J';
s[i + 1] = 'O';
s[i + 2] = 'I';
}
}
let s = s.iter().collect::<String>();
println!("{}", s);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - キャピタリゼーション (Capitalization) |
| ユーザ | ngtkana |
| 言語 | Rust (1.42.0) |
| 得点 | 100 |
| コード長 | 2798 Byte |
| 結果 | AC |
| 実行時間 | 9 ms |
| メモリ | 2112 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 100 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample-01.txt, sample-02.txt, sample-03.txt |
| All | 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, sample-01.txt, sample-02.txt, sample-03.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01-01.txt | AC | 9 ms | 2044 KiB |
| 01-02.txt | AC | 2 ms | 2032 KiB |
| 01-03.txt | AC | 1 ms | 2108 KiB |
| 01-04.txt | AC | 1 ms | 1892 KiB |
| 01-05.txt | AC | 2 ms | 1892 KiB |
| 01-06.txt | AC | 1 ms | 1996 KiB |
| 01-07.txt | AC | 1 ms | 2000 KiB |
| 01-08.txt | AC | 1 ms | 1892 KiB |
| 01-09.txt | AC | 1 ms | 2072 KiB |
| 01-10.txt | AC | 2 ms | 2044 KiB |
| 01-11.txt | AC | 1 ms | 2112 KiB |
| 01-12.txt | AC | 1 ms | 2044 KiB |
| 01-13.txt | AC | 1 ms | 1988 KiB |
| 01-14.txt | AC | 2 ms | 2028 KiB |
| 01-15.txt | AC | 1 ms | 1996 KiB |
| 01-16.txt | AC | 2 ms | 1960 KiB |
| 01-17.txt | AC | 1 ms | 2056 KiB |
| 01-18.txt | AC | 3 ms | 2072 KiB |
| 01-19.txt | AC | 2 ms | 2012 KiB |
| 01-20.txt | AC | 1 ms | 2060 KiB |
| sample-01.txt | AC | 1 ms | 2056 KiB |
| sample-02.txt | AC | 1 ms | 2044 KiB |
| sample-03.txt | AC | 1 ms | 2004 KiB |