結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2021-01-22 21:58:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 2,997 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 171,000 KB
実行使用メモリ 6,472 KB
最終ジャッジ日時 2023-08-27 19:02:57
合計ジャッジ時間 30,164 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 238 ms
4,752 KB
testcase_04 AC 238 ms
4,672 KB
testcase_05 AC 222 ms
4,856 KB
testcase_06 AC 222 ms
4,524 KB
testcase_07 AC 328 ms
5,360 KB
testcase_08 AC 327 ms
5,472 KB
testcase_09 AC 91 ms
4,376 KB
testcase_10 AC 90 ms
4,380 KB
testcase_11 AC 416 ms
5,992 KB
testcase_12 AC 416 ms
6,008 KB
testcase_13 AC 268 ms
4,900 KB
testcase_14 AC 268 ms
4,796 KB
testcase_15 AC 234 ms
4,580 KB
testcase_16 AC 234 ms
4,692 KB
testcase_17 AC 440 ms
5,996 KB
testcase_18 AC 439 ms
5,952 KB
testcase_19 AC 384 ms
5,692 KB
testcase_20 AC 383 ms
5,580 KB
testcase_21 AC 412 ms
5,908 KB
testcase_22 AC 412 ms
5,916 KB
testcase_23 AC 282 ms
4,792 KB
testcase_24 AC 284 ms
4,856 KB
testcase_25 AC 45 ms
4,376 KB
testcase_26 AC 44 ms
4,380 KB
testcase_27 AC 147 ms
4,380 KB
testcase_28 AC 147 ms
4,380 KB
testcase_29 AC 179 ms
4,468 KB
testcase_30 AC 179 ms
4,428 KB
testcase_31 AC 240 ms
4,716 KB
testcase_32 AC 240 ms
4,676 KB
testcase_33 AC 178 ms
4,624 KB
testcase_34 AC 177 ms
4,504 KB
testcase_35 AC 237 ms
4,584 KB
testcase_36 AC 235 ms
4,568 KB
testcase_37 AC 48 ms
4,380 KB
testcase_38 AC 48 ms
4,380 KB
testcase_39 AC 39 ms
4,380 KB
testcase_40 AC 38 ms
4,376 KB
testcase_41 AC 84 ms
4,376 KB
testcase_42 AC 84 ms
4,376 KB
testcase_43 AC 68 ms
4,380 KB
testcase_44 AC 440 ms
6,048 KB
testcase_45 AC 186 ms
4,376 KB
testcase_46 AC 62 ms
4,376 KB
testcase_47 AC 310 ms
5,252 KB
testcase_48 AC 296 ms
5,048 KB
testcase_49 AC 301 ms
5,052 KB
testcase_50 AC 228 ms
4,524 KB
testcase_51 AC 12 ms
4,376 KB
testcase_52 AC 393 ms
5,692 KB
testcase_53 AC 451 ms
6,156 KB
testcase_54 AC 466 ms
6,164 KB
testcase_55 AC 463 ms
6,112 KB
testcase_56 AC 464 ms
6,300 KB
testcase_57 AC 468 ms
6,108 KB
testcase_58 AC 466 ms
6,260 KB
testcase_59 AC 465 ms
6,164 KB
testcase_60 AC 461 ms
6,216 KB
testcase_61 AC 445 ms
6,216 KB
testcase_62 AC 463 ms
6,216 KB
testcase_63 AC 465 ms
6,472 KB
testcase_64 AC 465 ms
6,172 KB
testcase_65 AC 462 ms
6,108 KB
testcase_66 AC 462 ms
6,216 KB
testcase_67 AC 471 ms
6,152 KB
testcase_68 AC 458 ms
6,252 KB
testcase_69 AC 443 ms
6,212 KB
testcase_70 AC 445 ms
6,296 KB
testcase_71 AC 435 ms
6,156 KB
testcase_72 AC 464 ms
6,316 KB
testcase_73 AC 460 ms
6,168 KB
testcase_74 AC 457 ms
6,168 KB
testcase_75 AC 456 ms
6,424 KB
testcase_76 AC 455 ms
6,168 KB
testcase_77 AC 458 ms
6,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.01.22 21:58:45
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

template< int MOD >
struct mint {
public:
    long long x;
    mint(long long x = 0) :x((x%MOD+MOD)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    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) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-() const {return mint() -= *this; }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    friend std::istream &operator>>(std::istream &is, mint &n) {
        long long x;
        is >> x;
        n = mint(x);
        return is;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
    bool operator!=(const mint &a) const {
        return this->x != a.x;
    }
    mint pow(long long k) const {
        mint ret = 1;
        mint p = this->x;
        while (k > 0) {
            if (k & 1) {
                ret *= p;
            }
            p *= p;
            k >>= 1;
        }
        return ret;
    }
};

ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}
int main() {
    int n,k,m;cin >> n >> k >> m;
    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(p.begin(), p.end());
    sort(e.begin(), e.end());
    sort(a.begin(), a.end());
    sort(h.begin(), h.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += powMod(max({p[i],e[i],a[i],h[i]}) - min({p[i],e[i],a[i],h[i]}),k,m);
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}
0