結果
問題 | No.2941 Sigma Music Game Score Problem |
ユーザー | strangerxxx |
提出日時 | 2024-10-25 17:07:50 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,689 bytes |
コンパイル時間 | 13,428 ms |
コンパイル使用メモリ | 405,292 KB |
実行使用メモリ | 17,548 KB |
最終ジャッジ日時 | 2024-10-25 17:08:09 |
合計ジャッジ時間 | 18,752 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,820 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 1 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,820 KB |
testcase_10 | AC | 1 ms
6,820 KB |
testcase_11 | AC | 1 ms
6,816 KB |
testcase_12 | AC | 2 ms
6,816 KB |
testcase_13 | AC | 2 ms
6,816 KB |
testcase_14 | AC | 3 ms
6,816 KB |
testcase_15 | AC | 1 ms
6,820 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 247 ms
16,844 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 251 ms
17,244 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 1 ms
6,816 KB |
testcase_29 | AC | 86 ms
8,312 KB |
testcase_30 | AC | 131 ms
11,696 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
// -*- coding:utf-8-unix -*- #![allow(dead_code, unused_imports, unused_macros)] fn main() { input! { m: usize, n: usize, x: [usize; n], } let mut a = vec![0]; a.extend(x); a.push(m + 1); let mut ans = 0; for i in a.windows(2) { let diff = &i[1] - &i[0] - 1; ans += diff * (diff + 1) % UMOD * (2 * diff + 1) % UMOD * mod_pow(6, UMOD - 2, UMOD) % UMOD; ans %= UMOD; } p!(ans % UMOD); } // use ::num; // use itertools::Itertools; // use ac_library::*; // use proconio::input; use cmp::Ordering::*; // use itertools::Itertools; // use itertools_num::ItertoolsNum; // use maplit; // use ordered_float::OrderedFloat; use std::cmp::*; use std::collections::*; use std::fmt::*; use std::hash::*; use std::io::{stdin, stdout, Write}; use std::iter::FromIterator; use std::str::FromStr; use std::*; // use superslice::*; // use rand::Rng; // use rand::rngs::SmallRng; // use rand::seq::SliceRandom; const MOD1000000007: i64 = 1000000007; const MOD998244353: i64 = 998244353; const MOD: i64 = 998244353; const UMOD: usize = MOD as usize; const PI: f64 = f64::consts::PI; const DIRS: [char; 4] = ['U', 'D', 'L', 'R']; const DIJ: [(usize, usize); 4] = [(!0, 0), (1, 0), (0, !0), (0, 1)]; #[macro_export] macro_rules! p { ($($arg:expr),*) => { { print!("{}\n", vec![$(format!("{}", $arg)),*].join(" ")); } }; } #[macro_export] macro_rules! vp { ($x:expr) => { print!( "{}\n", $x.iter() .map(|x| x.to_string()) .collect::<Vec<_>>() .join(" ") ); }; } #[macro_export] macro_rules! dprint { ($($arg:expr),*) => { #[allow(unused_assignments)] { let mut first = true; $( if !first { eprint!(" "); } eprint!("{:?}", $arg); first = false; )* eprint!("\n"); } }; } #[macro_export] macro_rules! yesno { ($val:expr) => { if $val { print!("Yes\n"); } else { print!("No\n"); } }; } fn read<T: FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn read_mat<T: FromStr>(n: usize) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } fn readii() -> (i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1]) } fn readiii() -> (i64, i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1], vec[2]) } fn readuu() -> (usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1]) } fn readff() -> (f64, f64) { let vec: Vec<f64> = read_vec(); (vec[0], vec[1]) } fn readcc() -> (char, char) { let vec: Vec<char> = read_vec(); (vec[0], vec[1]) } fn readuuu() -> (usize, usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1], vec[2]) } fn readiiii() -> (i64, i64, i64, i64) { let vec: Vec<i64> = read_vec(); (vec[0], vec[1], vec[2], vec[3]) } fn readuuuu() -> (usize, usize, usize, usize) { let vec: Vec<usize> = read_vec(); (vec[0], vec[1], vec[2], vec[3]) } #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[macro_export] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } pub trait BinarySearch<T> { fn bisect_left(&self, key: T) -> usize; fn bisect_right(&self, key: T) -> usize; } impl<T> BinarySearch<T> for [T] where T: Ord, { fn bisect_left(&self, key: T) -> usize { let mut ng = -1 as isize; let mut ok = self.len() as isize; while ok - ng > 1 { let mid = (ok + ng) / 2; if key <= self[mid as usize] { ok = mid; } else { ng = mid; } } ok as usize } fn bisect_right(&self, key: T) -> usize { let mut ng = -1 as isize; let mut ok = self.len() as isize; while ok - ng > 1 { let mid = (ok + ng) / 2; if key < self[mid as usize] { ok = mid; } else { ng = mid; } } ok as usize } } pub fn next_permutation<T: Ord>(a: &mut [T]) -> bool { let Some(i) = a.windows(2).rposition(|w| w[0] < w[1]) else { return false; }; let j = a.iter().rposition(|x| x > &a[i]).unwrap(); a.swap(i, j); a[i + 1..].reverse(); true } fn mod_pow<T>(x: T, a: T, md: T) -> T where T: Copy + From<u8> + std::ops::Mul<Output = T> + std::ops::Rem<Output = T> + std::ops::Shr<u64, Output = T> + std::ops::Add<Output = T> + std::ops::BitAnd<Output = T> + PartialOrd + Default + std::ops::ShrAssign<i32>, { let mut res = T::from(1); let mut base = x; let mut ai = a; while ai > T::from(0) { if ai & T::from(1) == T::from(1) { res = res * base % md; } ai >>= 1; base = (base * base) % md; } res }