結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー Example0911Example0911
提出日時 2021-01-22 21:29:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 1,852 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 206,404 KB
実行使用メモリ 9,564 KB
最終ジャッジ日時 2023-08-27 17:31:45
合計ジャッジ時間 23,765 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 165 ms
6,164 KB
testcase_04 AC 165 ms
6,240 KB
testcase_05 AC 150 ms
6,196 KB
testcase_06 AC 149 ms
6,216 KB
testcase_07 AC 220 ms
7,556 KB
testcase_08 AC 221 ms
7,484 KB
testcase_09 AC 64 ms
4,380 KB
testcase_10 AC 64 ms
4,380 KB
testcase_11 AC 283 ms
8,592 KB
testcase_12 AC 284 ms
8,588 KB
testcase_13 AC 182 ms
6,748 KB
testcase_14 AC 183 ms
6,668 KB
testcase_15 AC 167 ms
6,164 KB
testcase_16 AC 166 ms
6,144 KB
testcase_17 AC 315 ms
8,780 KB
testcase_18 AC 316 ms
8,880 KB
testcase_19 AC 268 ms
8,096 KB
testcase_20 AC 268 ms
8,064 KB
testcase_21 AC 293 ms
8,520 KB
testcase_22 AC 292 ms
8,580 KB
testcase_23 AC 189 ms
7,012 KB
testcase_24 AC 189 ms
7,008 KB
testcase_25 AC 30 ms
4,376 KB
testcase_26 AC 30 ms
4,380 KB
testcase_27 AC 102 ms
5,160 KB
testcase_28 AC 102 ms
5,148 KB
testcase_29 AC 123 ms
5,428 KB
testcase_30 AC 123 ms
5,356 KB
testcase_31 AC 165 ms
6,144 KB
testcase_32 AC 164 ms
6,200 KB
testcase_33 AC 123 ms
5,368 KB
testcase_34 AC 122 ms
5,484 KB
testcase_35 AC 161 ms
6,232 KB
testcase_36 AC 162 ms
6,268 KB
testcase_37 AC 33 ms
4,380 KB
testcase_38 AC 33 ms
4,380 KB
testcase_39 AC 27 ms
4,380 KB
testcase_40 AC 27 ms
4,380 KB
testcase_41 AC 56 ms
4,380 KB
testcase_42 AC 56 ms
4,380 KB
testcase_43 AC 46 ms
4,380 KB
testcase_44 AC 296 ms
9,040 KB
testcase_45 AC 130 ms
5,348 KB
testcase_46 AC 45 ms
4,376 KB
testcase_47 AC 223 ms
7,304 KB
testcase_48 AC 195 ms
6,956 KB
testcase_49 AC 197 ms
7,252 KB
testcase_50 AC 157 ms
6,272 KB
testcase_51 AC 9 ms
4,380 KB
testcase_52 AC 267 ms
8,256 KB
testcase_53 AC 302 ms
9,316 KB
testcase_54 AC 323 ms
9,316 KB
testcase_55 AC 319 ms
9,376 KB
testcase_56 AC 322 ms
9,312 KB
testcase_57 AC 326 ms
9,372 KB
testcase_58 AC 323 ms
9,308 KB
testcase_59 AC 317 ms
9,420 KB
testcase_60 AC 306 ms
9,564 KB
testcase_61 AC 294 ms
9,436 KB
testcase_62 AC 316 ms
9,316 KB
testcase_63 AC 315 ms
9,400 KB
testcase_64 AC 322 ms
9,328 KB
testcase_65 AC 319 ms
9,324 KB
testcase_66 AC 312 ms
9,328 KB
testcase_67 AC 336 ms
9,368 KB
testcase_68 AC 313 ms
9,392 KB
testcase_69 AC 280 ms
9,336 KB
testcase_70 AC 288 ms
9,328 KB
testcase_71 AC 279 ms
9,376 KB
testcase_72 AC 327 ms
9,480 KB
testcase_73 AC 314 ms
9,560 KB
testcase_74 AC 311 ms
9,384 KB
testcase_75 AC 314 ms
9,312 KB
testcase_76 AC 307 ms
9,324 KB
testcase_77 AC 307 ms
9,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, K, M; cin >> N >> K >> M;
	mod = M;
	vector<ll>P(N), E(N), A(N), H(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> E[i];
	}for (int i = 0; i < N; i++) {
		cin >> A[i];
	}for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	sort(P.begin(), P.end());
	sort(E.begin(), E.end());
	sort(A.begin(), A.end());
	sort(H.begin(), H.end());
	mint ans = 0;
	for (int i = 0; i < N; i++) {
		ll now = max({ P[i],E[i],A[i],H[i] }) - min({ P[i],E[i],A[i],H[i] });
		ans += mint(now).pow(K);
	}
	cout << ans << endl;
	return 0;
}
0