結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー akakimidoriakakimidori
提出日時 2021-01-22 22:07:22
言語 Rust
(1.77.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 2,116 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 147,452 KB
実行使用メモリ 17,080 KB
最終ジャッジ日時 2023-08-27 19:21:51
合計ジャッジ時間 15,966 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 99 ms
9,656 KB
testcase_04 AC 98 ms
9,668 KB
testcase_05 AC 89 ms
9,356 KB
testcase_06 AC 89 ms
9,404 KB
testcase_07 AC 133 ms
15,040 KB
testcase_08 AC 132 ms
15,112 KB
testcase_09 AC 38 ms
5,460 KB
testcase_10 AC 38 ms
5,424 KB
testcase_11 AC 173 ms
16,408 KB
testcase_12 AC 173 ms
16,368 KB
testcase_13 AC 111 ms
14,004 KB
testcase_14 AC 111 ms
14,052 KB
testcase_15 AC 99 ms
9,392 KB
testcase_16 AC 99 ms
9,392 KB
testcase_17 AC 188 ms
16,572 KB
testcase_18 AC 187 ms
16,612 KB
testcase_19 AC 160 ms
15,904 KB
testcase_20 AC 160 ms
15,900 KB
testcase_21 AC 176 ms
16,384 KB
testcase_22 AC 176 ms
16,384 KB
testcase_23 AC 115 ms
14,476 KB
testcase_24 AC 116 ms
14,440 KB
testcase_25 AC 19 ms
4,380 KB
testcase_26 AC 19 ms
4,380 KB
testcase_27 AC 62 ms
8,144 KB
testcase_28 AC 62 ms
8,084 KB
testcase_29 AC 75 ms
8,800 KB
testcase_30 AC 75 ms
8,904 KB
testcase_31 AC 100 ms
9,676 KB
testcase_32 AC 99 ms
9,668 KB
testcase_33 AC 73 ms
8,584 KB
testcase_34 AC 73 ms
8,608 KB
testcase_35 AC 97 ms
9,688 KB
testcase_36 AC 96 ms
9,644 KB
testcase_37 AC 19 ms
4,380 KB
testcase_38 AC 20 ms
4,376 KB
testcase_39 AC 16 ms
4,376 KB
testcase_40 AC 17 ms
4,380 KB
testcase_41 AC 35 ms
5,284 KB
testcase_42 AC 35 ms
5,252 KB
testcase_43 AC 28 ms
4,936 KB
testcase_44 AC 182 ms
16,740 KB
testcase_45 AC 78 ms
8,860 KB
testcase_46 AC 27 ms
4,900 KB
testcase_47 AC 134 ms
14,576 KB
testcase_48 AC 122 ms
14,512 KB
testcase_49 AC 122 ms
14,764 KB
testcase_50 AC 94 ms
9,312 KB
testcase_51 AC 5 ms
4,376 KB
testcase_52 AC 163 ms
16,096 KB
testcase_53 AC 182 ms
17,032 KB
testcase_54 AC 194 ms
17,044 KB
testcase_55 AC 191 ms
17,036 KB
testcase_56 AC 192 ms
17,036 KB
testcase_57 AC 195 ms
17,040 KB
testcase_58 AC 191 ms
17,032 KB
testcase_59 AC 192 ms
17,052 KB
testcase_60 AC 187 ms
17,044 KB
testcase_61 AC 176 ms
17,020 KB
testcase_62 AC 190 ms
17,044 KB
testcase_63 AC 190 ms
17,072 KB
testcase_64 AC 194 ms
17,060 KB
testcase_65 AC 194 ms
17,052 KB
testcase_66 AC 190 ms
17,024 KB
testcase_67 AC 200 ms
17,080 KB
testcase_68 AC 188 ms
17,008 KB
testcase_69 AC 173 ms
17,028 KB
testcase_70 AC 174 ms
17,076 KB
testcase_71 AC 169 ms
17,040 KB
testcase_72 AC 196 ms
17,052 KB
testcase_73 AC 167 ms
17,048 KB
testcase_74 AC 164 ms
16,976 KB
testcase_75 AC 165 ms
17,032 KB
testcase_76 AC 163 ms
17,076 KB
testcase_77 AC 167 ms
17,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// ---------- begin input macro ----------
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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_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_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 ----------

fn pow_mod(r: u64, mut n: u64, m: u64) -> u64 {
    let mut t = 1 % m;
    let mut s = r % m;
    while n > 0 {
        if n & 1 == 1 {
            t = t * s % m;
        }
        s = s * s % m;
        n >>= 1;
    }
    t
}

fn run() {
    input! {
        n: usize,
        k: u64,
        m: u64,
        p: [[u64; n]; 4],
    }
    let mut p = p;
    p.iter_mut().for_each(|p| p.sort());
    let mut ans = 0;
    for _ in 0..n {
        let mut a = [0u64; 4];
        for (a, p) in a.iter_mut().zip(p.iter_mut()) {
            *a = p.pop().unwrap();
        }
        a.sort();
        ans += pow_mod(a[3] - a[0], k, m);
    }
    ans %= m;
    println!("{}", ans);
}

fn main() {
    run();
}
0