結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー lorent_kyoprolorent_kyopro
提出日時 2021-01-22 21:37:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 3,168 bytes
コンパイル時間 3,031 ms
コンパイル使用メモリ 207,924 KB
実行使用メモリ 11,244 KB
最終ジャッジ日時 2023-08-27 17:57:10
合計ジャッジ時間 21,007 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 131 ms
7,036 KB
testcase_04 AC 136 ms
7,140 KB
testcase_05 AC 124 ms
6,936 KB
testcase_06 AC 123 ms
7,008 KB
testcase_07 AC 183 ms
8,516 KB
testcase_08 AC 183 ms
8,600 KB
testcase_09 AC 50 ms
4,688 KB
testcase_10 AC 51 ms
4,724 KB
testcase_11 AC 237 ms
10,244 KB
testcase_12 AC 241 ms
10,312 KB
testcase_13 AC 150 ms
7,532 KB
testcase_14 AC 151 ms
7,592 KB
testcase_15 AC 135 ms
6,960 KB
testcase_16 AC 134 ms
7,012 KB
testcase_17 AC 253 ms
10,444 KB
testcase_18 AC 246 ms
10,576 KB
testcase_19 AC 214 ms
9,412 KB
testcase_20 AC 218 ms
9,396 KB
testcase_21 AC 237 ms
9,932 KB
testcase_22 AC 231 ms
9,984 KB
testcase_23 AC 155 ms
8,092 KB
testcase_24 AC 159 ms
8,016 KB
testcase_25 AC 26 ms
4,380 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 85 ms
5,348 KB
testcase_28 AC 85 ms
5,420 KB
testcase_29 AC 109 ms
6,188 KB
testcase_30 AC 102 ms
6,268 KB
testcase_31 AC 137 ms
7,500 KB
testcase_32 AC 138 ms
7,244 KB
testcase_33 AC 104 ms
6,144 KB
testcase_34 AC 103 ms
6,016 KB
testcase_35 AC 134 ms
7,068 KB
testcase_36 AC 135 ms
7,020 KB
testcase_37 AC 29 ms
4,380 KB
testcase_38 AC 28 ms
4,376 KB
testcase_39 AC 23 ms
4,380 KB
testcase_40 AC 23 ms
4,376 KB
testcase_41 AC 48 ms
4,856 KB
testcase_42 AC 47 ms
4,732 KB
testcase_43 AC 37 ms
4,376 KB
testcase_44 AC 251 ms
10,512 KB
testcase_45 AC 109 ms
6,308 KB
testcase_46 AC 38 ms
4,380 KB
testcase_47 AC 182 ms
8,348 KB
testcase_48 AC 166 ms
8,116 KB
testcase_49 AC 169 ms
8,600 KB
testcase_50 AC 132 ms
7,016 KB
testcase_51 AC 7 ms
4,380 KB
testcase_52 AC 227 ms
9,576 KB
testcase_53 AC 256 ms
10,988 KB
testcase_54 AC 269 ms
10,960 KB
testcase_55 AC 265 ms
11,032 KB
testcase_56 AC 275 ms
11,040 KB
testcase_57 AC 276 ms
10,980 KB
testcase_58 AC 272 ms
11,064 KB
testcase_59 AC 273 ms
10,888 KB
testcase_60 AC 266 ms
10,964 KB
testcase_61 AC 249 ms
10,892 KB
testcase_62 AC 271 ms
11,136 KB
testcase_63 AC 267 ms
10,920 KB
testcase_64 AC 262 ms
10,968 KB
testcase_65 AC 262 ms
10,892 KB
testcase_66 AC 267 ms
11,040 KB
testcase_67 AC 275 ms
11,096 KB
testcase_68 AC 257 ms
10,968 KB
testcase_69 AC 248 ms
10,892 KB
testcase_70 AC 245 ms
10,936 KB
testcase_71 AC 238 ms
10,976 KB
testcase_72 AC 272 ms
11,036 KB
testcase_73 AC 262 ms
10,916 KB
testcase_74 AC 261 ms
10,968 KB
testcase_75 AC 253 ms
11,160 KB
testcase_76 AC 259 ms
10,984 KB
testcase_77 AC 261 ms
11,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
const array<string, 2> YESNO = {"NO", "YES"};
const array<string, 2> YesNo = {"No", "Yes"};
const array<string, 2> yesno = {"no", "yes"};
void YES(bool b = true) { cout << YESNO[b] << '\n'; }
void Yes(bool b = true) { cout << YesNo[b] << '\n'; }
void yes(bool b = true) { cout << yesno[b] << '\n'; }
template<typename T, typename U>
inline bool chmax(T& a, const U& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U>
inline bool chmin(T& a, const U& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
void UNIQUE(vector<T>& v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()));
}
template<typename T>
int lb(const vector<T> v, T x) {
    return distance(v.begin(), lower_bound(v.begin(), v.end(), x));
}
template<typename T>
int ub(const vector<T> v, T x) {
    return distance(v.begin(), upper_bound(v.begin(), v.end(), x));
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (auto it = v.begin(); it != v.end(); ++it) {
        if (it == v.begin()) os << *it;
        else os << ' ' << *it;
    }
    return os;
}
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;

long long pow_mod(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, k, m;
    cin >> n >> k >> m;
    auto a = make_vec<ll>({4, n});
    rep(i, 4) rep(j, n) cin >> a[i][j];
    rep(i, 4) sort(ALL(a[i]));

    ll ans = 0;
    rep(j, n) {
        ll d = max({a[0][j], a[1][j], a[2][j], a[3][j]}) - min({a[0][j], a[1][j], a[2][j], a[3][j]});
        ans += pow_mod(d, k, m);
        ans %= m;
    }
    cout << ans << '\n';
}
0