結果
| 問題 |
No.784 「,(カンマ)」
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-08-30 17:05:54 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,746 bytes |
| コンパイル時間 | 14,206 ms |
| コンパイル使用メモリ | 379,336 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 11:19:50 |
| 合計ジャッジ時間 | 15,113 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 10 |
ソースコード
//USE https://mirrorless-camera.info/column/14417.html
macro_rules! input {
($($r:tt)*) => {
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(std::io::stdin()));
let mut next = move |is_word: bool| -> String{
if is_word {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
} else {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c| c == &'\n')
.take_while(|c| c != &'\n')
.collect()
}
};
input_inner!{next, $($r)*};
};
}
macro_rules! input_inner {
($next:expr) => {};
($next:expr, ) => {};
($next:expr, static $var:ident : $t:tt $($rest:tt)*) => {
$var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, mut $var:ident : $t:tt $($rest:tt)*) => {
let mut $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, $var:ident : $t:tt $($rest:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
}
macro_rules! read_value {
($next:expr, ( $($t:tt),* )) => {
( $(read_value!($next, $t)),* )
};
($next:expr, [ $t:tt ; all ]) => { {
let mut str = $next(false);
str.split_whitespace().map(|it| it.parse::<$t>().unwrap()).collect::<Vec<_>>()
}
};
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len as usize).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, chars) => {
read_value!($next, String).chars().collect::<Vec<char>>()
};
($next:expr, lines) => {
{
let mut vec = Vec::new();
let mut str = $next(false);
while str != "" {
vec.push(str);
str = $next(false);
}
vec
}
};
($next:expr, line) => {
$next(false)
};
($next:expr, usize1) => {
read_value!($next, usize) - 1
};
($next:expr, $t:ty) => {
$next(true).parse::<$t>().expect("Parse error")
};
}
fn main() {
input! {
n : String
}
let mut out = "".to_string();
for (i, c) in n.chars().rev().collect::<String>().chars().enumerate(){
out.push(c);
if i%3 == 2 && i+1<n.len() {
out.push(',');
}
println!("{}",c)
}
let n_comma = out.chars().rev().collect::<String>();
println!("{}", n_comma);
}
H20