結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー leaf_1415leaf_1415
提出日時 2021-01-22 21:31:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 502 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 83,356 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2023-08-27 17:39:37
合計ジャッジ時間 29,867 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,436 KB
testcase_01 AC 2 ms
7,500 KB
testcase_02 AC 2 ms
7,444 KB
testcase_03 AC 243 ms
8,708 KB
testcase_04 AC 243 ms
8,800 KB
testcase_05 AC 213 ms
8,704 KB
testcase_06 AC 214 ms
8,720 KB
testcase_07 AC 316 ms
9,096 KB
testcase_08 AC 315 ms
9,044 KB
testcase_09 AC 96 ms
8,252 KB
testcase_10 AC 95 ms
8,104 KB
testcase_11 AC 409 ms
9,460 KB
testcase_12 AC 409 ms
9,308 KB
testcase_13 AC 262 ms
8,824 KB
testcase_14 AC 264 ms
8,860 KB
testcase_15 AC 251 ms
8,776 KB
testcase_16 AC 250 ms
8,768 KB
testcase_17 AC 471 ms
9,428 KB
testcase_18 AC 472 ms
9,604 KB
testcase_19 AC 401 ms
9,192 KB
testcase_20 AC 398 ms
9,192 KB
testcase_21 AC 434 ms
9,280 KB
testcase_22 AC 435 ms
9,292 KB
testcase_23 AC 268 ms
8,880 KB
testcase_24 AC 268 ms
8,884 KB
testcase_25 AC 43 ms
7,744 KB
testcase_26 AC 43 ms
7,772 KB
testcase_27 AC 149 ms
8,528 KB
testcase_28 AC 148 ms
8,412 KB
testcase_29 AC 180 ms
8,520 KB
testcase_30 AC 179 ms
8,528 KB
testcase_31 AC 238 ms
8,724 KB
testcase_32 AC 239 ms
8,796 KB
testcase_33 AC 177 ms
8,524 KB
testcase_34 AC 178 ms
8,512 KB
testcase_35 AC 234 ms
8,720 KB
testcase_36 AC 235 ms
8,804 KB
testcase_37 AC 47 ms
7,732 KB
testcase_38 AC 47 ms
7,784 KB
testcase_39 AC 41 ms
8,012 KB
testcase_40 AC 41 ms
7,756 KB
testcase_41 AC 79 ms
8,032 KB
testcase_42 AC 80 ms
8,012 KB
testcase_43 AC 65 ms
7,888 KB
testcase_44 AC 423 ms
9,428 KB
testcase_45 AC 192 ms
8,540 KB
testcase_46 AC 67 ms
7,864 KB
testcase_47 AC 337 ms
8,956 KB
testcase_48 AC 274 ms
8,964 KB
testcase_49 AC 277 ms
9,220 KB
testcase_50 AC 228 ms
8,732 KB
testcase_51 AC 12 ms
7,508 KB
testcase_52 AC 388 ms
9,452 KB
testcase_53 AC 425 ms
9,740 KB
testcase_54 AC 471 ms
9,588 KB
testcase_55 AC 465 ms
9,628 KB
testcase_56 AC 467 ms
9,564 KB
testcase_57 AC 481 ms
9,616 KB
testcase_58 AC 471 ms
9,788 KB
testcase_59 AC 459 ms
9,632 KB
testcase_60 AC 437 ms
9,564 KB
testcase_61 AC 409 ms
9,620 KB
testcase_62 AC 456 ms
9,612 KB
testcase_63 AC 455 ms
9,592 KB
testcase_64 AC 470 ms
9,624 KB
testcase_65 AC 465 ms
9,584 KB
testcase_66 AC 445 ms
9,596 KB
testcase_67 AC 502 ms
9,792 KB
testcase_68 AC 454 ms
9,676 KB
testcase_69 AC 382 ms
9,680 KB
testcase_70 AC 394 ms
9,632 KB
testcase_71 AC 384 ms
9,592 KB
testcase_72 AC 480 ms
9,584 KB
testcase_73 AC 458 ms
9,648 KB
testcase_74 AC 451 ms
9,904 KB
testcase_75 AC 458 ms
9,572 KB
testcase_76 AC 443 ms
9,620 KB
testcase_77 AC 440 ms
9,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;

ll n, k, mod;
ll a[4][200005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k >> mod;
	rep(i, 0, 3){
		rep(j, 1, n){
			cin >> a[i][j];
		}
		sort(a[i]+1, a[i]+n+1);
	}
	
	ll ans = 0;
	rep(i, 1, n){
		ll mn = inf, mx = -inf;
		rep(j, 0, 3) chmax(mx, a[j][i]), chmin(mn, a[j][i]);
		ans += modpow(mx-mn, k), ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}
0