結果
| 問題 |
No.729 文字swap
|
| ユーザー |
|
| 提出日時 | 2018-10-09 19:53:49 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,566 bytes |
| コンパイル時間 | 16,405 ms |
| コンパイル使用メモリ | 379,452 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 16:39:30 |
| 合計ジャッジ時間 | 17,316 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 |
コンパイルメッセージ
warning: variable does not need to be mutable
--> src/main.rs:25:13
|
25 | let mut $var = read_value!($iter, $t);
| ----^^^^
| |
| help: remove this `mut`
...
60 | / input!{
61 | | s: chars,
62 | | i: usize,
63 | | j: usize,
64 | | }
| |_____- in this macro invocation
|
= note: `#[warn(unused_mut)]` on by default
= note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: variable does not need to be mutable
--> src/main.rs:25:13
|
25 | let mut $var = read_value!($iter, $t);
| ----^^^^
| |
| help: remove this `mut`
...
60 | / input!{
61 | | s: chars,
62 | | i: usize,
63 | | j: usize,
64 | | }
| |_____- in this macro invocation
|
= note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
input_inner!{iter, $($r)*}
};
($($r:tt)*) => {
#[allow(unused_mut)]
let mut s = {
use std::io::Read;
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
s
};
let mut iter = s.split_whitespace();
input_inner!{iter, $($r)*}
};
}
macro_rules! input_inner {
($iter:expr) => {};
($iter:expr, ) => {};
($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
#[allow(non_snake_case)]
let mut $var = read_value!($iter, $t);
input_inner!{$iter $($r)*}
};
}
macro_rules! read_value {
($iter:expr, ( $($t:tt),* )) => {
( $(read_value!($iter, $t)),* )
};
($iter:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
};
($iter:expr, chars) => {
read_value!($iter, String).chars().collect::<Vec<char>>()
};
($iter:expr, usize1) => {
read_value!($iter, usize) - 1
};
($iter:expr, $t:ty) => {
$iter.next().unwrap().parse::<$t>().expect("Parse error")
};
}
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
fn main() {
input!{
s: chars,
i: usize,
j: usize,
}
s.swap(i, j);
let ans: String = s.into_iter().collect();
println!("{}", ans);
}