結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
![]() |
提出日時 | 2021-02-19 23:52:26 |
言語 | Rust (1.83.0 + proconio) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,581 bytes |
コンパイル時間 | 12,542 ms |
コンパイル使用メモリ | 390,160 KB |
最終ジャッジ日時 | 2024-11-15 00:05:36 |
合計ジャッジ時間 | 13,792 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: format argument must be a string literal --> src/main.rs:17:34 | 17 | Err(e) => panic!(e), | ^ | help: you might be missing a string literal to format with | 17 | Err(e) => panic!("{}", e), | +++++ error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
mod io {#[macro_export]macro_rules! scan {($r:expr, [$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($r, $t)).collect::<Vec<_>>());($r:expr, ($($t:tt),*)) => (($(scan!($r, $t)),*));($r:expr, [u8]) => (io::scan($r));($r:expr, String) => (io::scan($r).into_iter().map(char::from).collect::<String>());($r:expr, $t:ty) => (scan!($r, String).parse::<$t>().unwrap());}pub fn scan<R: std::io::BufRead>(r: &mut R) -> Vec<u8> {let mut res = Vec::new();loop {let buf = match r.fill_buf() {Ok(buf) => buf,Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue,Err(e) => panic!(e),};let (done, used) = match buf.iter().position(u8::is_ascii_whitespace) {Some(i) => {res.extend_from_slice(&buf[..i]);(res.len() > 0, i + 1)}None => {res.extend_from_slice(buf);(buf.is_empty(), buf.len())}};r.consume(used);if done { return res; }}}}fn run<R: std::io::BufRead, W: std::io::Write>(reader: &mut R, writer: &mut W) {let (w, h, x) = scan!(reader, (usize, usize, usize));if h == 1 && w == 1 && x > 9 || (h == 1 || w == 1) && x > 18 || x > 36 {writer.write_all(b"-1\n").ok();return;};if x > 9 && (w % 3 != 2 && h % 3 != 2) {writer.write_all(b"-1\n").ok();return;}if x > 18 && (w % 3 != 2 || h % 3 != 2) {writer.write_all(b"-1\n").ok();return;}let mut ans = vec![vec![b'0'; w]; h];let si = if h % 3 == 0 { 1 } else { 0 };let sj = if w % 3 == 0 { 1 } else { 0 };for i in (si..h).step_by(3) {for j in (sj..w).step_by(3) {let mut x = x;for p in i..(h.min(i + if h % 3 == 2 { 2 } else { 1 })) {for q in j..(w.min(j + if w % 3 == 2 { 2 } else { 1 })) {let v = x.min(9);x -= v;ans[p][q] = b'0' + v as u8;}}}}for ans in ans {writer.write_all(&ans).ok();writer.write_all(b"\n").ok();}}fn main() {let (stdin, stdout) = (std::io::stdin(), std::io::stdout());let mut reader = std::io::BufReader::new(stdin.lock());let mut writer = std::io::BufWriter::new(stdout.lock());run(&mut reader, &mut writer);}