結果
問題 | No.1368 サイクルの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2021-01-29 22:55:09 |
言語 | Rust (1.83.0 + proconio) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,647 bytes |
コンパイル時間 | 12,160 ms |
コンパイル使用メモリ | 384,444 KB |
最終ジャッジ日時 | 2024-11-15 05:06:08 |
合計ジャッジ時間 | 13,396 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: format argument must be a string literal --> src/main.rs:25:42 | 25 | Err(e) => panic!(e), | ^ | help: you might be missing a string literal to format with | 25 | Err(e) => panic!("{}", e), | +++++ error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
mod my {#[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, $t:ty) => ({std::str::from_utf8(&scan($r)).unwrap().parse::<$t>().unwrap()});}pub mod io {use std::io::{BufRead, ErrorKind};pub fn scan<R: BufRead>(r: &mut R) -> Vec<u8> {let mut buf = Vec::new();loop {let (done, used) = {let available = match r.fill_buf() {Ok(n) => n,Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,Err(e) => panic!(e),};match available.iter().position(u8::is_ascii_whitespace) {Some(i) => {buf.extend_from_slice(&available[..i]);(buf.len() > 0, i + 1)}None => {buf.extend_from_slice(available);(false, available.len())}}};r.consume(used);if done || used == 0 {return buf;}}}}}use std::io::{BufRead, Write};use my::io::scan;fn run<R: BufRead, W: Write>(reader: &mut R, writer: &mut W) {for _ in 0..scan!(reader, usize) {let n = scan!(reader, usize);let mut a = scan!(reader, [usize; n]);a.extend_from_slice(&a[..3].to_vec());let mut ans = 0;let mut dp = vec![vec![0; 3]; n + 3];for (i, a) in a.windows(3).enumerate() {for j in 0..3 {dp[i + 1][j] = dp[i + 1][j].max(dp[i][j]);}if a[0] == a[2] { continue; }if a[0] > a[1] && a[1] < a[2] || a[0] < a[1] && a[1] > a[2] {for j in 0..3 {if i < j || n + j <= i + 2 { continue; }let next = dp[i][j] + a[0];dp[i + 3][j] = dp[i + 3][j].max(next);ans = ans.max(next);}}}writeln!(writer, "{}", ans).ok();}}fn main() {let (stdin, stdout) = (std::io::stdin(), std::io::stdout());let reader = &mut std::io::BufReader::new(stdin.lock());let writer = &mut std::io::BufWriter::new(stdout.lock());run(reader, writer);}