結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー daut-dlangdaut-dlang
提出日時 2021-01-22 22:14:46
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 2,226 bytes
コンパイル時間 3,553 ms
コンパイル使用メモリ 111,588 KB
実行使用メモリ 23,908 KB
最終ジャッジ日時 2023-09-04 11:58:40
合計ジャッジ時間 43,393 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 248 ms
14,608 KB
testcase_04 AC 248 ms
14,580 KB
testcase_05 AC 229 ms
14,532 KB
testcase_06 AC 230 ms
14,460 KB
testcase_07 AC 333 ms
13,652 KB
testcase_08 AC 335 ms
13,640 KB
testcase_09 AC 95 ms
7,524 KB
testcase_10 AC 94 ms
7,532 KB
testcase_11 AC 433 ms
23,108 KB
testcase_12 AC 433 ms
23,032 KB
testcase_13 AC 278 ms
15,500 KB
testcase_14 AC 276 ms
15,492 KB
testcase_15 AC 251 ms
14,144 KB
testcase_16 AC 251 ms
14,168 KB
testcase_17 AC 473 ms
23,608 KB
testcase_18 AC 472 ms
23,596 KB
testcase_19 AC 411 ms
21,644 KB
testcase_20 AC 410 ms
21,660 KB
testcase_21 AC 441 ms
22,856 KB
testcase_22 AC 440 ms
22,800 KB
testcase_23 AC 288 ms
15,692 KB
testcase_24 AC 288 ms
15,712 KB
testcase_25 AC 45 ms
6,248 KB
testcase_26 AC 45 ms
6,216 KB
testcase_27 AC 153 ms
11,532 KB
testcase_28 AC 153 ms
11,476 KB
testcase_29 AC 186 ms
12,496 KB
testcase_30 AC 186 ms
12,496 KB
testcase_31 AC 251 ms
14,448 KB
testcase_32 AC 250 ms
14,440 KB
testcase_33 AC 184 ms
12,560 KB
testcase_34 AC 184 ms
12,492 KB
testcase_35 AC 243 ms
14,564 KB
testcase_36 AC 244 ms
14,608 KB
testcase_37 AC 49 ms
6,456 KB
testcase_38 AC 49 ms
6,496 KB
testcase_39 AC 41 ms
5,752 KB
testcase_40 AC 41 ms
5,668 KB
testcase_41 AC 86 ms
7,476 KB
testcase_42 AC 84 ms
7,536 KB
testcase_43 AC 69 ms
7,988 KB
testcase_44 AC 458 ms
23,172 KB
testcase_45 AC 195 ms
12,852 KB
testcase_46 AC 67 ms
7,288 KB
testcase_47 AC 331 ms
15,936 KB
testcase_48 AC 298 ms
15,844 KB
testcase_49 AC 363 ms
15,976 KB
testcase_50 AC 238 ms
14,452 KB
testcase_51 AC 12 ms
4,996 KB
testcase_52 AC 409 ms
22,132 KB
testcase_53 AC 464 ms
23,908 KB
testcase_54 AC 492 ms
23,768 KB
testcase_55 AC 485 ms
23,792 KB
testcase_56 AC 487 ms
23,624 KB
testcase_57 AC 493 ms
23,704 KB
testcase_58 AC 488 ms
23,840 KB
testcase_59 AC 485 ms
23,692 KB
testcase_60 AC 472 ms
23,820 KB
testcase_61 AC 454 ms
23,780 KB
testcase_62 AC 485 ms
23,836 KB
testcase_63 AC 484 ms
23,760 KB
testcase_64 AC 493 ms
23,712 KB
testcase_65 AC 487 ms
23,728 KB
testcase_66 AC 479 ms
23,816 KB
testcase_67 AC 505 ms
23,704 KB
testcase_68 AC 479 ms
23,860 KB
testcase_69 AC 444 ms
23,740 KB
testcase_70 AC 448 ms
23,816 KB
testcase_71 AC 439 ms
23,676 KB
testcase_72 AC 494 ms
23,856 KB
testcase_73 AC 479 ms
23,772 KB
testcase_74 AC 478 ms
23,720 KB
testcase_75 AC 482 ms
23,760 KB
testcase_76 AC 475 ms
23,892 KB
testcase_77 AC 471 ms
23,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto M = RD;
	auto P = RDA;
	auto E = RDA;
	auto A = RDA;
	auto H = RDA;
	mod = M;

	P.sort;
	E.sort;
	A.sort;
	H.sort;
	long ans;
	foreach (i; 0..N)
	{
		auto arr = [P[i], E[i], A[i], H[i]];
		arr.sort;
		auto d = arr[3] - arr[0];
		debug writeln("d:", d);
		d.modpow(K);
		ans.moda(d);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}
0