結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー どららどらら
提出日時 2021-01-22 21:39:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 171,508 KB
実行使用メモリ 9,656 KB
最終ジャッジ日時 2023-08-27 18:02:08
合計ジャッジ時間 30,771 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 245 ms
6,168 KB
testcase_04 AC 246 ms
6,264 KB
testcase_05 AC 232 ms
6,168 KB
testcase_06 AC 231 ms
6,200 KB
testcase_07 AC 339 ms
7,520 KB
testcase_08 AC 342 ms
7,544 KB
testcase_09 AC 93 ms
4,412 KB
testcase_10 AC 94 ms
4,376 KB
testcase_11 AC 431 ms
8,656 KB
testcase_12 AC 433 ms
8,868 KB
testcase_13 AC 279 ms
7,032 KB
testcase_14 AC 283 ms
6,784 KB
testcase_15 AC 243 ms
6,260 KB
testcase_16 AC 243 ms
6,176 KB
testcase_17 AC 456 ms
8,864 KB
testcase_18 AC 461 ms
8,864 KB
testcase_19 AC 395 ms
8,008 KB
testcase_20 AC 396 ms
8,140 KB
testcase_21 AC 431 ms
8,668 KB
testcase_22 AC 426 ms
8,532 KB
testcase_23 AC 295 ms
7,020 KB
testcase_24 AC 294 ms
7,012 KB
testcase_25 AC 47 ms
4,376 KB
testcase_26 AC 46 ms
4,380 KB
testcase_27 AC 152 ms
4,900 KB
testcase_28 AC 153 ms
4,880 KB
testcase_29 AC 187 ms
5,424 KB
testcase_30 AC 186 ms
5,524 KB
testcase_31 AC 251 ms
6,284 KB
testcase_32 AC 250 ms
6,492 KB
testcase_33 AC 184 ms
5,520 KB
testcase_34 AC 185 ms
5,380 KB
testcase_35 AC 245 ms
6,196 KB
testcase_36 AC 244 ms
6,176 KB
testcase_37 AC 50 ms
4,376 KB
testcase_38 AC 50 ms
4,376 KB
testcase_39 AC 39 ms
4,380 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 87 ms
4,380 KB
testcase_42 AC 87 ms
4,376 KB
testcase_43 AC 70 ms
4,424 KB
testcase_44 AC 457 ms
9,056 KB
testcase_45 AC 191 ms
5,356 KB
testcase_46 AC 65 ms
4,380 KB
testcase_47 AC 323 ms
7,304 KB
testcase_48 AC 307 ms
6,996 KB
testcase_49 AC 312 ms
7,280 KB
testcase_50 AC 239 ms
6,152 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 407 ms
8,268 KB
testcase_53 AC 470 ms
9,372 KB
testcase_54 AC 485 ms
9,348 KB
testcase_55 AC 482 ms
9,336 KB
testcase_56 AC 484 ms
9,456 KB
testcase_57 AC 486 ms
9,316 KB
testcase_58 AC 487 ms
9,608 KB
testcase_59 AC 507 ms
9,344 KB
testcase_60 AC 494 ms
9,428 KB
testcase_61 AC 462 ms
9,484 KB
testcase_62 AC 482 ms
9,424 KB
testcase_63 AC 481 ms
9,656 KB
testcase_64 AC 484 ms
9,368 KB
testcase_65 AC 479 ms
9,336 KB
testcase_66 AC 480 ms
9,412 KB
testcase_67 AC 489 ms
9,344 KB
testcase_68 AC 475 ms
9,520 KB
testcase_69 AC 459 ms
9,484 KB
testcase_70 AC 463 ms
9,484 KB
testcase_71 AC 454 ms
9,476 KB
testcase_72 AC 495 ms
9,388 KB
testcase_73 AC 478 ms
9,364 KB
testcase_74 AC 474 ms
9,344 KB
testcase_75 AC 476 ms
9,320 KB
testcase_76 AC 473 ms
9,388 KB
testcase_77 AC 475 ms
9,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll mod_pow(ll x, ll n, ll mod){
  ll res = 1;
  while(n>0){
    if(n&1) res = res*x%mod;
    x = x*x%mod;
    n >>= 1;
  }
  return res;
}

int main(){
  ll N, K, M;
  cin >> N >> K >> M;
  vector<ll> v1(N),v2(N),v3(N),v4(N);
  rep(i,N) cin >> v1[i];
  rep(i,N) cin >> v2[i];
  rep(i,N) cin >> v3[i];
  rep(i,N) cin >> v4[i];
  sort(ALLOF(v1));
  sort(ALLOF(v2));
  sort(ALLOF(v3));
  sort(ALLOF(v4));

  ll ret = 0;
  rep(i,N){
    vector<ll> w = {v1[i],v2[i],v3[i],v4[i]};
    sort(ALLOF(w));
    ll d = w[3] - w[0];
    ll dK = mod_pow(d, K, M);
    ret += dK;
    ret %= M;
  }

  cout << ret << endl;
  
  return 0;
}


0