結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tokusakuraitokusakurai
提出日時 2021-01-22 21:54:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 3,336 bytes
コンパイル時間 3,078 ms
コンパイル使用メモリ 211,176 KB
実行使用メモリ 11,032 KB
最終ジャッジ日時 2023-08-27 18:46:58
合計ジャッジ時間 24,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 141 ms
7,016 KB
testcase_04 AC 141 ms
7,052 KB
testcase_05 AC 130 ms
6,952 KB
testcase_06 AC 129 ms
7,020 KB
testcase_07 AC 196 ms
8,524 KB
testcase_08 AC 195 ms
8,648 KB
testcase_09 AC 55 ms
4,796 KB
testcase_10 AC 54 ms
4,692 KB
testcase_11 AC 249 ms
10,232 KB
testcase_12 AC 248 ms
10,092 KB
testcase_13 AC 158 ms
7,556 KB
testcase_14 AC 159 ms
7,660 KB
testcase_15 AC 143 ms
7,220 KB
testcase_16 AC 141 ms
6,928 KB
testcase_17 AC 264 ms
10,316 KB
testcase_18 AC 265 ms
10,504 KB
testcase_19 AC 228 ms
9,388 KB
testcase_20 AC 229 ms
9,260 KB
testcase_21 AC 249 ms
9,964 KB
testcase_22 AC 247 ms
9,848 KB
testcase_23 AC 166 ms
8,096 KB
testcase_24 AC 166 ms
8,120 KB
testcase_25 AC 27 ms
4,380 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 89 ms
5,484 KB
testcase_28 AC 87 ms
5,432 KB
testcase_29 AC 107 ms
6,216 KB
testcase_30 AC 107 ms
6,220 KB
testcase_31 AC 143 ms
7,320 KB
testcase_32 AC 143 ms
7,192 KB
testcase_33 AC 106 ms
5,960 KB
testcase_34 AC 106 ms
5,872 KB
testcase_35 AC 140 ms
7,016 KB
testcase_36 AC 140 ms
7,056 KB
testcase_37 AC 29 ms
4,376 KB
testcase_38 AC 28 ms
4,376 KB
testcase_39 AC 23 ms
4,384 KB
testcase_40 AC 23 ms
4,376 KB
testcase_41 AC 50 ms
4,668 KB
testcase_42 AC 50 ms
4,680 KB
testcase_43 AC 40 ms
4,380 KB
testcase_44 AC 264 ms
10,376 KB
testcase_45 AC 110 ms
6,316 KB
testcase_46 AC 38 ms
4,380 KB
testcase_47 AC 186 ms
8,188 KB
testcase_48 AC 175 ms
8,000 KB
testcase_49 AC 176 ms
8,208 KB
testcase_50 AC 136 ms
6,884 KB
testcase_51 AC 8 ms
4,380 KB
testcase_52 AC 235 ms
9,504 KB
testcase_53 AC 266 ms
11,012 KB
testcase_54 AC 280 ms
10,896 KB
testcase_55 AC 275 ms
10,888 KB
testcase_56 AC 278 ms
10,892 KB
testcase_57 AC 281 ms
10,948 KB
testcase_58 AC 278 ms
10,976 KB
testcase_59 AC 277 ms
11,012 KB
testcase_60 AC 272 ms
10,832 KB
testcase_61 AC 260 ms
10,840 KB
testcase_62 AC 276 ms
10,844 KB
testcase_63 AC 277 ms
11,032 KB
testcase_64 AC 279 ms
10,984 KB
testcase_65 AC 275 ms
11,012 KB
testcase_66 AC 276 ms
10,904 KB
testcase_67 AC 284 ms
10,904 KB
testcase_68 AC 272 ms
11,008 KB
testcase_69 AC 256 ms
11,012 KB
testcase_70 AC 257 ms
10,884 KB
testcase_71 AC 248 ms
10,888 KB
testcase_72 AC 279 ms
10,956 KB
testcase_73 AC 273 ms
10,844 KB
testcase_74 AC 270 ms
11,008 KB
testcase_75 AC 271 ms
10,908 KB
testcase_76 AC 268 ms
10,912 KB
testcase_77 AC 271 ms
10,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

struct Random_Number_Generator{
    mt19937_64 mt;

    Random_Number_Generator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

    int64_t operator () (int64_t l, int64_t r){
        uniform_int_distribution<int64_t> dist(l, r-1);
        return dist(mt);
    }

    int64_t operator () (int64_t r){ 
        return (*this)(0, r);
    }
};

ll modpow(ll x, ll n, const int &m){
    ll ret = 1;
    for(; n; n >>= 1, x *= x, x %= m){
        if(n&1) ret *= x, ret %= m;
    }
    return ret;
}

template<typename T> T Euler_Totient(T m){ //オイラーのφ関数(xとmが互いに素ならば、x^φ(m)≡1(mod m))
    T ret = m;
    for(T i = 2; i*i <= m; i++){
        if(m%i == 0) ret /= i, ret *= i-1;
        while(m%i == 0) m /= i;
    }
    if(m > 1) ret /= m, ret *= m-1;
    return ret;
}

int modlog(const int &x, ll y, const int &m){ //x^k=y(mod m)となる最小の非負整数k(xとmは互いに素)
    unordered_map<int, int> mp;
    int n = 0; ll now = 1;
    for(; n*n < m; n++){
        if(!mp.count(now)) mp[now] = n;
        now *= x, now %= m;
    }
    now = modpow(now, Euler_Totient(m)-1, m);
    rep(i, n){
        if(mp.count(y)) return n*i+mp[y];
        y *= now, y %= m;
    }
    return -1;
}

template<typename T> T order(T x, const T &m){ //x^k=1(mod m)となる最小の正整数k(xとmは互いに素)
    T n = Euler_Totient(m);
    vector<T> ds;
    for(T i = 1; i*i <= n; i++){
        if(n%i == 0) ds.pb(i), ds.pb(n/i);
    }
    sort(all(ds));
    for(auto &e: ds){
        if(modpow(x, e, m) == 1) return e;
    }
    return -1;
}

template<typename T> T primitive_root(const T &m){ //素数mの原始根
    vector<T> ds;
    for(T i = 1; i*i <= m-1; i++){
        if((m-1)%i == 0) ds.pb(i), ds.pb((m-1)/i);
    }
    sort(all(ds));
    Random_Number_Generator rnd;
    while(true){
        T r = rnd(1, m);
        for(auto &e: ds){
            if(e == m-1) return r;
            if(modpow(r, e, m) == 1) break;
        }
    }
}

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

    vector<vector<ll>> A(4, vector<ll>(N));
    rep(i, 4){
        rep(j, N) cin >> A[i][j];
    }

    rep(i, 4) sort(all(A[i]));
    ll ans = 0;
    rep(i, N){
        ll p = -INF, m = INF;
        rep(j, 4) chmax(p, A[j][i]), chmin(m, A[j][i]);
        ans += modpow(p-m, K, M);
        ans %= M;
    }

    cout << ans << '\n';
}
0