結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー kyo1kyo1
提出日時 2021-01-25 15:06:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 4,261 ms
コンパイル使用メモリ 202,708 KB
実行使用メモリ 6,404 KB
最終ジャッジ日時 2023-09-04 06:08:14
合計ジャッジ時間 30,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 136 ms
4,672 KB
testcase_04 AC 136 ms
4,628 KB
testcase_05 AC 122 ms
4,868 KB
testcase_06 AC 122 ms
4,688 KB
testcase_07 AC 185 ms
5,364 KB
testcase_08 AC 184 ms
5,368 KB
testcase_09 AC 52 ms
4,380 KB
testcase_10 AC 52 ms
4,376 KB
testcase_11 AC 238 ms
5,900 KB
testcase_12 AC 237 ms
5,888 KB
testcase_13 AC 152 ms
4,888 KB
testcase_14 AC 152 ms
4,960 KB
testcase_15 AC 134 ms
4,612 KB
testcase_16 AC 135 ms
4,568 KB
testcase_17 AC 253 ms
5,936 KB
testcase_18 AC 253 ms
5,992 KB
testcase_19 AC 218 ms
5,672 KB
testcase_20 AC 220 ms
5,692 KB
testcase_21 AC 237 ms
5,640 KB
testcase_22 AC 236 ms
5,672 KB
testcase_23 AC 159 ms
5,216 KB
testcase_24 AC 160 ms
5,396 KB
testcase_25 AC 26 ms
4,376 KB
testcase_26 AC 26 ms
4,376 KB
testcase_27 AC 84 ms
4,376 KB
testcase_28 AC 84 ms
4,380 KB
testcase_29 AC 102 ms
4,376 KB
testcase_30 AC 103 ms
4,424 KB
testcase_31 AC 137 ms
4,568 KB
testcase_32 AC 137 ms
4,580 KB
testcase_33 AC 101 ms
4,380 KB
testcase_34 AC 101 ms
4,560 KB
testcase_35 AC 134 ms
4,644 KB
testcase_36 AC 134 ms
4,620 KB
testcase_37 AC 28 ms
4,376 KB
testcase_38 AC 27 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,380 KB
testcase_43 AC 38 ms
4,380 KB
testcase_44 AC 250 ms
6,008 KB
testcase_45 AC 106 ms
4,376 KB
testcase_46 AC 36 ms
4,376 KB
testcase_47 AC 179 ms
5,104 KB
testcase_48 AC 167 ms
5,104 KB
testcase_49 AC 168 ms
5,148 KB
testcase_50 AC 130 ms
4,692 KB
testcase_51 AC 8 ms
4,376 KB
testcase_52 AC 224 ms
5,692 KB
testcase_53 AC 252 ms
6,224 KB
testcase_54 AC 266 ms
6,276 KB
testcase_55 AC 263 ms
6,168 KB
testcase_56 AC 266 ms
6,208 KB
testcase_57 AC 270 ms
6,148 KB
testcase_58 AC 267 ms
6,196 KB
testcase_59 AC 266 ms
6,196 KB
testcase_60 AC 260 ms
6,276 KB
testcase_61 AC 246 ms
6,148 KB
testcase_62 AC 264 ms
6,204 KB
testcase_63 AC 266 ms
6,156 KB
testcase_64 AC 267 ms
6,208 KB
testcase_65 AC 262 ms
6,404 KB
testcase_66 AC 263 ms
6,280 KB
testcase_67 AC 271 ms
6,172 KB
testcase_68 AC 259 ms
6,160 KB
testcase_69 AC 243 ms
6,212 KB
testcase_70 AC 245 ms
6,288 KB
testcase_71 AC 236 ms
6,276 KB
testcase_72 AC 267 ms
6,156 KB
testcase_73 AC 262 ms
6,224 KB
testcase_74 AC 259 ms
6,224 KB
testcase_75 AC 260 ms
6,228 KB
testcase_76 AC 256 ms
6,156 KB
testcase_77 AC 259 ms
6,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template <typename T>
int pow(int x, T n, int mod = std::numeric_limits<int>::max()) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<int64_t>(res) * static_cast<int64_t>(x) % mod;
    x = static_cast<int64_t>(x) * static_cast<int64_t>(x) % mod;
    n >>= 1;
  }
  return res;
}

template <typename T>
int64_t pow(int64_t x, T n, int64_t mod = std::numeric_limits<int64_t>::max()) {
  int64_t res = 1;
  while (n > 0) {
    if (n & 1) res = static_cast<__int128>(res) * static_cast<__int128>(x) % mod;
    x = static_cast<__int128>(x) * static_cast<__int128>(x) % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K, M;
  cin >> N >> K >> M;
  vector<int> A(N), B(N), C(N), D(N);
  for (auto &&e : A) {
    cin >> e;
  }
  for (auto &&e : B) {
    cin >> e;
  }
  for (auto &&e : C) {
    cin >> e;
  }
  for (auto &&e : D) {
    cin >> e;
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  sort(D.begin(), D.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    res += pow(max({A[i], B[i], C[i], D[i]}) - min({A[i], B[i], C[i], D[i]}), K, M);
    res %= M;
  }
  cout << res << '\n';
  return 0;
}
0