結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー BSerBSer
提出日時 2021-01-22 21:39:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,259 ms / 2,000 ms
コード長 2,588 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 174,040 KB
実行使用メモリ 11,160 KB
最終ジャッジ日時 2023-09-17 23:59:20
合計ジャッジ時間 73,328 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 4 ms
4,356 KB
testcase_03 AC 622 ms
6,984 KB
testcase_04 AC 629 ms
6,996 KB
testcase_05 AC 594 ms
6,940 KB
testcase_06 AC 588 ms
6,948 KB
testcase_07 AC 852 ms
8,524 KB
testcase_08 AC 863 ms
8,572 KB
testcase_09 AC 245 ms
4,692 KB
testcase_10 AC 245 ms
4,620 KB
testcase_11 AC 1,078 ms
10,236 KB
testcase_12 AC 1,082 ms
10,240 KB
testcase_13 AC 695 ms
7,532 KB
testcase_14 AC 705 ms
7,576 KB
testcase_15 AC 625 ms
7,064 KB
testcase_16 AC 626 ms
6,988 KB
testcase_17 AC 1,175 ms
10,416 KB
testcase_18 AC 1,175 ms
10,544 KB
testcase_19 AC 1,006 ms
9,356 KB
testcase_20 AC 1,000 ms
9,504 KB
testcase_21 AC 1,100 ms
10,032 KB
testcase_22 AC 1,166 ms
10,100 KB
testcase_23 AC 725 ms
8,128 KB
testcase_24 AC 775 ms
8,068 KB
testcase_25 AC 118 ms
4,356 KB
testcase_26 AC 116 ms
4,380 KB
testcase_27 AC 390 ms
5,364 KB
testcase_28 AC 383 ms
5,364 KB
testcase_29 AC 465 ms
5,952 KB
testcase_30 AC 467 ms
6,216 KB
testcase_31 AC 618 ms
6,944 KB
testcase_32 AC 623 ms
7,328 KB
testcase_33 AC 462 ms
5,956 KB
testcase_34 AC 462 ms
5,928 KB
testcase_35 AC 621 ms
7,024 KB
testcase_36 AC 614 ms
6,988 KB
testcase_37 AC 124 ms
4,352 KB
testcase_38 AC 122 ms
4,352 KB
testcase_39 AC 100 ms
4,352 KB
testcase_40 AC 100 ms
4,352 KB
testcase_41 AC 216 ms
4,432 KB
testcase_42 AC 213 ms
4,428 KB
testcase_43 AC 174 ms
4,356 KB
testcase_44 AC 1,125 ms
10,500 KB
testcase_45 AC 489 ms
6,156 KB
testcase_46 AC 165 ms
4,356 KB
testcase_47 AC 825 ms
8,004 KB
testcase_48 AC 766 ms
8,176 KB
testcase_49 AC 761 ms
8,340 KB
testcase_50 AC 592 ms
7,068 KB
testcase_51 AC 31 ms
4,504 KB
testcase_52 AC 1,019 ms
9,644 KB
testcase_53 AC 1,156 ms
10,964 KB
testcase_54 AC 1,208 ms
11,048 KB
testcase_55 AC 1,195 ms
10,976 KB
testcase_56 AC 1,209 ms
10,944 KB
testcase_57 AC 1,222 ms
10,964 KB
testcase_58 AC 1,217 ms
10,948 KB
testcase_59 AC 1,190 ms
10,972 KB
testcase_60 AC 1,176 ms
10,904 KB
testcase_61 AC 1,149 ms
10,908 KB
testcase_62 AC 1,213 ms
10,960 KB
testcase_63 AC 1,213 ms
10,944 KB
testcase_64 AC 1,212 ms
11,032 KB
testcase_65 AC 1,219 ms
10,900 KB
testcase_66 AC 1,179 ms
10,940 KB
testcase_67 AC 1,234 ms
10,948 KB
testcase_68 AC 1,182 ms
10,908 KB
testcase_69 AC 1,112 ms
10,960 KB
testcase_70 AC 1,125 ms
11,028 KB
testcase_71 AC 1,122 ms
10,908 KB
testcase_72 AC 1,259 ms
10,976 KB
testcase_73 AC 1,194 ms
10,900 KB
testcase_74 AC 1,203 ms
10,956 KB
testcase_75 AC 1,193 ms
11,160 KB
testcase_76 AC 1,188 ms
10,948 KB
testcase_77 AC 1,184 ms
11,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Edge
{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), v.end()
ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e10;
const int MAX = 510000;
bool graph[nmax][nmax];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    ll N, K;
    cin >> N >> K >> MOD;

    vector<ll> a(N), b(N), c(N), d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < N; i++)
    {
        cin >> c[i];
    }

    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    SORT(a);
    SORT(b);
    SORT(c);
    SORT(d);

    vector<ll> num(N);
    for (int i = 0; i < N; i++)
    {
        num[i] = max({a[i], b[i], c[i], d[i]}) - min({a[i], b[i], c[i], d[i]});
    }

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        cerr << num[i] << " ";
        ans += powMod(num[i], K);
        ans %= MOD;
    }
    cerr << endl;
    cout << ans << endl;

    return 0;
}
0