結果
| 問題 |
No.3191 Operation Puzzle
|
| ユーザー |
akakimidori
|
| 提出日時 | 2025-06-27 23:01:48 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,346 bytes |
| コンパイル時間 | 11,354 ms |
| コンパイル使用メモリ | 400,352 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-27 23:02:52 |
| 合計ジャッジ時間 | 13,554 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 |
コンパイルメッセージ
warning: unused import: `std::io::Write`
--> src/main.rs:1:5
|
1 | use std::io::Write;
| ^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused variable: `a`
--> src/main.rs:11:9
|
11 | a: [usize; n],
| ^
|
help: `a` is captured in macro and introduced a unused variable
--> src/main.rs:46:13
|
9 | / input! {
10 | | n: usize,
11 | | a: [usize; n],
12 | | x: usize,
13 | | }
| |_____- in this macro invocation
...
46 | let $var = read_value!($iter, $t);
| ^^^^
= note: `#[warn(unused_variables)]` 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: unused variable: `i`
--> src/main.rs:15:9
|
15 | for i in 0..4 {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
warning: type alias `Map` is never used
--> src/main.rs:4:6
|
4 | type Map<K, V> = BTreeMap<K, V>;
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: type alias `Set` is never used
--> src/main.rs:5:6
|
5 | type Set<T> = BTreeSet<T>;
| ^^^
warning: type alias `Deque` is never used
--> src/main.rs:6:6
|
6 | type Deque<T> = VecDeque<T>;
| ^^^^^
ソースコード
use std::io::Write;
use std::collections::*;
type Map<K, V> = BTreeMap<K, V>;
type Set<T> = BTreeSet<T>;
type Deque<T> = VecDeque<T>;
fn main() {
input! {
n: usize,
a: [usize; n],
x: usize,
}
println!("Yes");
for i in 0..4 {
use util::*;
println!("{}", (0..4).map(|_| x).join(" "));
}
}
// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[macro_export]
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
input_inner!{iter, $($r)*}
};
($($r:tt)*) => {
let 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_export]
macro_rules! input_inner {
($iter:expr) => {};
($iter:expr, ) => {};
($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
let $var = read_value!($iter, $t);
input_inner!{$iter $($r)*}
};
}
#[macro_export]
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, bytes) => {
read_value!($iter, String).bytes().collect::<Vec<u8>>()
};
($iter:expr, usize1) => {
read_value!($iter, usize) - 1
};
($iter:expr, $t:ty) => {
$iter.next().unwrap().parse::<$t>().expect("Parse error")
};
}
// ---------- end input macro ----------
mod util {
pub trait Join {
fn join(self, sep: &str) -> String;
}
impl<T, I> Join for I
where
I: Iterator<Item = T>,
T: std::fmt::Display,
{
fn join(self, sep: &str) -> String {
let mut s = String::new();
use std::fmt::*;
for (i, v) in self.enumerate() {
if i > 0 {
write!(&mut s, "{}", sep).ok();
}
write!(&mut s, "{}", v).ok();
}
s
}
}
}
akakimidori