結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー norikamenorikame
提出日時 2021-01-22 22:28:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 533 ms / 2,000 ms
コード長 2,469 bytes
コンパイル時間 3,206 ms
コンパイル使用メモリ 206,688 KB
実行使用メモリ 7,124 KB
最終ジャッジ日時 2023-08-27 20:16:58
合計ジャッジ時間 33,964 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 266 ms
5,208 KB
testcase_04 AC 264 ms
5,220 KB
testcase_05 AC 248 ms
4,876 KB
testcase_06 AC 249 ms
5,140 KB
testcase_07 AC 364 ms
5,912 KB
testcase_08 AC 364 ms
5,932 KB
testcase_09 AC 102 ms
4,380 KB
testcase_10 AC 102 ms
4,376 KB
testcase_11 AC 461 ms
6,448 KB
testcase_12 AC 458 ms
6,540 KB
testcase_13 AC 296 ms
5,404 KB
testcase_14 AC 295 ms
5,476 KB
testcase_15 AC 265 ms
4,808 KB
testcase_16 AC 264 ms
4,900 KB
testcase_17 AC 500 ms
6,856 KB
testcase_18 AC 499 ms
6,852 KB
testcase_19 AC 428 ms
6,276 KB
testcase_20 AC 429 ms
6,332 KB
testcase_21 AC 468 ms
6,552 KB
testcase_22 AC 465 ms
6,456 KB
testcase_23 AC 312 ms
5,412 KB
testcase_24 AC 313 ms
5,388 KB
testcase_25 AC 49 ms
4,376 KB
testcase_26 AC 48 ms
4,380 KB
testcase_27 AC 164 ms
4,380 KB
testcase_28 AC 164 ms
4,380 KB
testcase_29 AC 200 ms
4,704 KB
testcase_30 AC 201 ms
4,688 KB
testcase_31 AC 268 ms
5,136 KB
testcase_32 AC 268 ms
5,224 KB
testcase_33 AC 198 ms
4,716 KB
testcase_34 AC 197 ms
4,552 KB
testcase_35 AC 262 ms
4,856 KB
testcase_36 AC 261 ms
5,208 KB
testcase_37 AC 52 ms
4,376 KB
testcase_38 AC 53 ms
4,376 KB
testcase_39 AC 44 ms
4,384 KB
testcase_40 AC 44 ms
4,376 KB
testcase_41 AC 91 ms
4,376 KB
testcase_42 AC 92 ms
4,380 KB
testcase_43 AC 74 ms
4,380 KB
testcase_44 AC 483 ms
6,860 KB
testcase_45 AC 207 ms
4,556 KB
testcase_46 AC 70 ms
4,376 KB
testcase_47 AC 354 ms
5,652 KB
testcase_48 AC 323 ms
5,644 KB
testcase_49 AC 327 ms
5,668 KB
testcase_50 AC 256 ms
4,892 KB
testcase_51 AC 13 ms
4,376 KB
testcase_52 AC 436 ms
6,720 KB
testcase_53 AC 495 ms
7,080 KB
testcase_54 AC 520 ms
6,936 KB
testcase_55 AC 516 ms
6,976 KB
testcase_56 AC 517 ms
7,004 KB
testcase_57 AC 523 ms
7,072 KB
testcase_58 AC 520 ms
6,936 KB
testcase_59 AC 514 ms
6,932 KB
testcase_60 AC 504 ms
6,968 KB
testcase_61 AC 489 ms
6,920 KB
testcase_62 AC 513 ms
6,976 KB
testcase_63 AC 514 ms
6,964 KB
testcase_64 AC 518 ms
6,992 KB
testcase_65 AC 514 ms
7,068 KB
testcase_66 AC 506 ms
7,064 KB
testcase_67 AC 533 ms
6,932 KB
testcase_68 AC 508 ms
7,080 KB
testcase_69 AC 477 ms
7,124 KB
testcase_70 AC 483 ms
6,908 KB
testcase_71 AC 476 ms
7,004 KB
testcase_72 AC 523 ms
6,916 KB
testcase_73 AC 509 ms
6,984 KB
testcase_74 AC 508 ms
6,968 KB
testcase_75 AC 509 ms
6,940 KB
testcase_76 AC 506 ms
6,980 KB
testcase_77 AC 505 ms
6,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
#define v(t) vector<t>
//#define p(t) pair<t, t>
//#define p2(t, s) pair<t, s>
#define vp(t) v(p(t))

#define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i)
#define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i)
#define repr(i, n) for (int i=((int)(n)-1); i>=0; --i)
#define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i)

#define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr)
#define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define eb emplace_back

#define INF (1e9)
#define LINF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)
#define DEPS (1e-10)

ll mod = (1e9+7);

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n, k, m;
    cin >> n >> k >> m;
    mod = m;
    v(v(int)) p(4, v(int)(n));
    rep(i1, 4) rep(i, n) cin >> p[i1][i];
    rep(i, 4) { VSORT(p[i]); }
    mint sum(0);
    rep(i, n) {
        int mnval = (1e9+5), mxval = 0;
        rep(i1, 4) {
            mnval = min(mnval, p[i1][i]);
            mxval = max(mxval, p[i1][i]);
        }
        sum += mint(mxval-mnval).pow(k);
    }
    cout << sum << endl;
    return 0;
}
0