結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー outlineoutline
提出日時 2021-01-22 22:07:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 3,035 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 138,912 KB
実行使用メモリ 6,408 KB
最終ジャッジ日時 2023-08-27 19:21:30
合計ジャッジ時間 20,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 137 ms
4,516 KB
testcase_04 AC 136 ms
4,584 KB
testcase_05 AC 123 ms
4,512 KB
testcase_06 AC 123 ms
4,632 KB
testcase_07 AC 186 ms
5,448 KB
testcase_08 AC 187 ms
5,436 KB
testcase_09 AC 52 ms
4,376 KB
testcase_10 AC 52 ms
4,380 KB
testcase_11 AC 239 ms
5,956 KB
testcase_12 AC 239 ms
5,948 KB
testcase_13 AC 154 ms
4,784 KB
testcase_14 AC 154 ms
4,788 KB
testcase_15 AC 136 ms
4,824 KB
testcase_16 AC 136 ms
4,648 KB
testcase_17 AC 256 ms
5,916 KB
testcase_18 AC 256 ms
6,012 KB
testcase_19 AC 221 ms
5,636 KB
testcase_20 AC 222 ms
5,704 KB
testcase_21 AC 239 ms
5,668 KB
testcase_22 AC 240 ms
5,696 KB
testcase_23 AC 161 ms
4,848 KB
testcase_24 AC 161 ms
4,820 KB
testcase_25 AC 26 ms
4,376 KB
testcase_26 AC 26 ms
4,376 KB
testcase_27 AC 84 ms
4,380 KB
testcase_28 AC 85 ms
4,376 KB
testcase_29 AC 105 ms
4,564 KB
testcase_30 AC 104 ms
4,376 KB
testcase_31 AC 138 ms
4,584 KB
testcase_32 AC 138 ms
4,648 KB
testcase_33 AC 102 ms
4,380 KB
testcase_34 AC 102 ms
4,380 KB
testcase_35 AC 135 ms
4,632 KB
testcase_36 AC 136 ms
4,576 KB
testcase_37 AC 27 ms
4,380 KB
testcase_38 AC 28 ms
4,376 KB
testcase_39 AC 23 ms
4,376 KB
testcase_40 AC 23 ms
4,380 KB
testcase_41 AC 48 ms
4,376 KB
testcase_42 AC 48 ms
4,376 KB
testcase_43 AC 39 ms
4,380 KB
testcase_44 AC 253 ms
5,880 KB
testcase_45 AC 107 ms
4,400 KB
testcase_46 AC 36 ms
4,376 KB
testcase_47 AC 182 ms
5,196 KB
testcase_48 AC 169 ms
5,044 KB
testcase_49 AC 170 ms
5,144 KB
testcase_50 AC 131 ms
4,816 KB
testcase_51 AC 8 ms
4,380 KB
testcase_52 AC 226 ms
5,704 KB
testcase_53 AC 254 ms
6,176 KB
testcase_54 AC 269 ms
6,228 KB
testcase_55 AC 266 ms
6,244 KB
testcase_56 AC 268 ms
6,252 KB
testcase_57 AC 271 ms
6,264 KB
testcase_58 AC 269 ms
6,180 KB
testcase_59 AC 267 ms
6,380 KB
testcase_60 AC 261 ms
6,196 KB
testcase_61 AC 248 ms
6,096 KB
testcase_62 AC 267 ms
6,192 KB
testcase_63 AC 268 ms
6,220 KB
testcase_64 AC 270 ms
6,096 KB
testcase_65 AC 265 ms
6,164 KB
testcase_66 AC 266 ms
6,244 KB
testcase_67 AC 274 ms
6,088 KB
testcase_68 AC 262 ms
6,192 KB
testcase_69 AC 246 ms
6,248 KB
testcase_70 AC 248 ms
6,384 KB
testcase_71 AC 239 ms
6,408 KB
testcase_72 AC 271 ms
6,164 KB
testcase_73 AC 263 ms
6,104 KB
testcase_74 AC 260 ms
6,272 KB
testcase_75 AC 263 ms
6,248 KB
testcase_76 AC 258 ms
6,232 KB
testcase_77 AC 263 ms
6,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int mod = 2;
struct mint {
    int x;
    mint() : x(0) {}
    mint(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    mint& operator+=(const mint& p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    mint& operator-=(const mint& p){
        if((x -= p.x) < 0)  x += mod;
        return *this;
    }
    mint& operator*=(const mint& p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    mint& operator/=(const mint& p){
        *this *= p.inverse();
        return *this;
    }
    mint operator-() const { return mint(-x); }
    mint operator+(const mint& p) const { return mint(*this) += p; }
    mint operator-(const mint& p) const { return mint(*this) -= p; }
    mint operator*(const mint& p) const { return mint(*this) *= p; }
    mint operator/(const mint& p) const { return mint(*this) /= p; }
    bool operator==(const mint& p) const { return x == p.x; }
    bool operator!=(const mint& p) const { return x != p.x; }
    mint pow(int64_t n) const {
        mint res = 1, mul = x;
        while(n > 0){
            if(n & 1)   res *= mul;
            mul *= mul;
            n >>= 1;
        }
        return res;
    }
    mint inverse() const { return pow(mod - 2); }
    friend ostream& operator<<(ostream& os, const mint& p){
        return os << p.x;
    }
    friend istream& operator>>(istream& is, mint& p){
        int64_t val;
        is >> val;
        p = mint(val);
        return is;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K;
    cin >> N >> K >> mod;
    vector<int> P(N), E(N), A(N), H(N);
    for(int i = 0; i < N; ++i)  cin >> P[i];
    for(int i = 0; i < N; ++i)  cin >> E[i];
    for(int i = 0; i < N; ++i)  cin >> A[i];
    for(int i = 0; i < N; ++i)  cin >> H[i];
    sort(begin(P), end(P));
    sort(begin(E), end(E));
    sort(begin(A), end(A));
    sort(begin(H), end(H));
    
    mint ans = 0;
    for(int i = 0; i < N; ++i){
        int D = max({P[i], E[i], A[i], H[i]}) - min({P[i], E[i], A[i], H[i]});
        ans += mint(D).pow(K);
    }

    cout << ans << endl;

    return 0;
}
0