結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー MayimgMayimg
提出日時 2021-01-22 22:35:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 3,314 ms
コンパイル使用メモリ 205,944 KB
実行使用メモリ 7,244 KB
最終ジャッジ日時 2023-08-27 20:34:32
合計ジャッジ時間 23,115 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 151 ms
5,088 KB
testcase_04 AC 148 ms
5,152 KB
testcase_05 AC 134 ms
4,964 KB
testcase_06 AC 135 ms
4,964 KB
testcase_07 AC 202 ms
5,912 KB
testcase_08 AC 203 ms
5,920 KB
testcase_09 AC 57 ms
4,372 KB
testcase_10 AC 57 ms
4,376 KB
testcase_11 AC 260 ms
6,444 KB
testcase_12 AC 261 ms
6,572 KB
testcase_13 AC 167 ms
5,420 KB
testcase_14 AC 167 ms
5,388 KB
testcase_15 AC 147 ms
5,016 KB
testcase_16 AC 148 ms
5,020 KB
testcase_17 AC 278 ms
6,780 KB
testcase_18 AC 278 ms
6,976 KB
testcase_19 AC 240 ms
6,528 KB
testcase_20 AC 240 ms
6,204 KB
testcase_21 AC 259 ms
6,416 KB
testcase_22 AC 259 ms
6,420 KB
testcase_23 AC 175 ms
5,376 KB
testcase_24 AC 176 ms
5,412 KB
testcase_25 AC 28 ms
4,380 KB
testcase_26 AC 28 ms
4,376 KB
testcase_27 AC 91 ms
4,428 KB
testcase_28 AC 93 ms
4,372 KB
testcase_29 AC 113 ms
4,592 KB
testcase_30 AC 112 ms
4,908 KB
testcase_31 AC 151 ms
5,160 KB
testcase_32 AC 150 ms
5,144 KB
testcase_33 AC 112 ms
4,648 KB
testcase_34 AC 112 ms
4,580 KB
testcase_35 AC 147 ms
5,392 KB
testcase_36 AC 148 ms
5,096 KB
testcase_37 AC 31 ms
4,376 KB
testcase_38 AC 31 ms
4,376 KB
testcase_39 AC 25 ms
4,376 KB
testcase_40 AC 24 ms
4,376 KB
testcase_41 AC 52 ms
4,372 KB
testcase_42 AC 52 ms
4,372 KB
testcase_43 AC 43 ms
4,372 KB
testcase_44 AC 276 ms
6,772 KB
testcase_45 AC 116 ms
4,620 KB
testcase_46 AC 39 ms
4,376 KB
testcase_47 AC 196 ms
5,692 KB
testcase_48 AC 183 ms
5,724 KB
testcase_49 AC 185 ms
5,624 KB
testcase_50 AC 143 ms
4,952 KB
testcase_51 AC 8 ms
4,372 KB
testcase_52 AC 247 ms
6,444 KB
testcase_53 AC 278 ms
7,024 KB
testcase_54 AC 292 ms
6,936 KB
testcase_55 AC 289 ms
7,012 KB
testcase_56 AC 292 ms
6,948 KB
testcase_57 AC 295 ms
6,944 KB
testcase_58 AC 294 ms
7,004 KB
testcase_59 AC 291 ms
6,940 KB
testcase_60 AC 284 ms
7,036 KB
testcase_61 AC 271 ms
6,940 KB
testcase_62 AC 290 ms
7,012 KB
testcase_63 AC 291 ms
6,944 KB
testcase_64 AC 292 ms
6,996 KB
testcase_65 AC 289 ms
6,932 KB
testcase_66 AC 288 ms
7,008 KB
testcase_67 AC 297 ms
6,944 KB
testcase_68 AC 284 ms
7,244 KB
testcase_69 AC 268 ms
7,012 KB
testcase_70 AC 271 ms
6,988 KB
testcase_71 AC 262 ms
6,948 KB
testcase_72 AC 293 ms
6,988 KB
testcase_73 AC 286 ms
6,940 KB
testcase_74 AC 285 ms
7,036 KB
testcase_75 AC 283 ms
7,000 KB
testcase_76 AC 282 ms
7,084 KB
testcase_77 AC 284 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k, m;
  cin >> n >> k >> m;
  vector<vector<int>> a(4, vector<int>(n));
  for (int i = 0; i < 4; i++) {
    for (auto& x : a[i]) cin >> x;
    sort(a[i].begin(), a[i].end());
  }
  vector<int> vals(n);
  for (int j = 0; j < n; j++) {
    vector<int> v;
    for (int i = 0; i < 4; i++) v.emplace_back(a[i][j]);
    vals[j] = *max_element(v.begin(), v.end()) - *min_element(v.begin(), v.end());
  }
  long long ans = 0;
  auto calc = [&] (int x) -> long long {
    long long res = 1;
    long long c = x;
    int kk = k;
    while (kk > 0) {
      if (kk & 1) {
        res *= c;
        res %= m;
      }
      c *= c;
      c %= m;
      kk >>= 1;
    }
    return res % m;
  };
  for (auto x : vals) {
    (ans += calc(x)) %= m;
  }
  cout << ans << endl;
  return 0;
}
0