結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー tanimani364tanimani364
提出日時 2021-03-24 20:26:49
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 2,026 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 134,136 KB
実行使用メモリ 11,044 KB
最終ジャッジ日時 2023-08-17 22:34:05
合計ジャッジ時間 27,722 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 151 ms
7,008 KB
testcase_04 AC 146 ms
7,012 KB
testcase_05 AC 133 ms
6,976 KB
testcase_06 AC 138 ms
6,936 KB
testcase_07 AC 199 ms
8,888 KB
testcase_08 AC 199 ms
8,872 KB
testcase_09 AC 56 ms
4,640 KB
testcase_10 AC 57 ms
4,592 KB
testcase_11 AC 261 ms
10,184 KB
testcase_12 AC 257 ms
10,184 KB
testcase_13 AC 164 ms
7,496 KB
testcase_14 AC 164 ms
7,508 KB
testcase_15 AC 146 ms
7,016 KB
testcase_16 AC 145 ms
6,976 KB
testcase_17 AC 274 ms
10,416 KB
testcase_18 AC 274 ms
10,464 KB
testcase_19 AC 237 ms
9,412 KB
testcase_20 AC 237 ms
9,368 KB
testcase_21 AC 260 ms
9,980 KB
testcase_22 AC 256 ms
9,892 KB
testcase_23 AC 172 ms
8,084 KB
testcase_24 AC 174 ms
8,088 KB
testcase_25 AC 29 ms
4,376 KB
testcase_26 AC 28 ms
4,380 KB
testcase_27 AC 90 ms
5,408 KB
testcase_28 AC 93 ms
5,424 KB
testcase_29 AC 111 ms
6,184 KB
testcase_30 AC 114 ms
6,232 KB
testcase_31 AC 150 ms
7,260 KB
testcase_32 AC 147 ms
7,244 KB
testcase_33 AC 112 ms
5,912 KB
testcase_34 AC 108 ms
5,968 KB
testcase_35 AC 147 ms
6,972 KB
testcase_36 AC 144 ms
7,044 KB
testcase_37 AC 30 ms
4,380 KB
testcase_38 AC 29 ms
4,384 KB
testcase_39 AC 25 ms
4,380 KB
testcase_40 AC 24 ms
4,380 KB
testcase_41 AC 54 ms
4,608 KB
testcase_42 AC 51 ms
4,664 KB
testcase_43 AC 42 ms
4,376 KB
testcase_44 AC 274 ms
10,464 KB
testcase_45 AC 115 ms
6,140 KB
testcase_46 AC 40 ms
4,380 KB
testcase_47 AC 196 ms
8,292 KB
testcase_48 AC 181 ms
8,036 KB
testcase_49 AC 186 ms
8,336 KB
testcase_50 AC 140 ms
6,964 KB
testcase_51 AC 8 ms
4,376 KB
testcase_52 AC 241 ms
9,604 KB
testcase_53 AC 274 ms
10,936 KB
testcase_54 AC 289 ms
10,924 KB
testcase_55 AC 285 ms
10,936 KB
testcase_56 AC 287 ms
10,940 KB
testcase_57 AC 291 ms
10,928 KB
testcase_58 AC 288 ms
10,940 KB
testcase_59 AC 284 ms
10,924 KB
testcase_60 AC 279 ms
10,948 KB
testcase_61 AC 266 ms
10,936 KB
testcase_62 AC 284 ms
11,000 KB
testcase_63 AC 285 ms
10,936 KB
testcase_64 AC 287 ms
10,964 KB
testcase_65 AC 283 ms
11,044 KB
testcase_66 AC 284 ms
10,924 KB
testcase_67 AC 292 ms
10,960 KB
testcase_68 AC 280 ms
10,916 KB
testcase_69 AC 264 ms
10,976 KB
testcase_70 AC 263 ms
10,948 KB
testcase_71 AC 257 ms
10,948 KB
testcase_72 AC 290 ms
10,948 KB
testcase_73 AC 235 ms
10,944 KB
testcase_74 AC 232 ms
10,988 KB
testcase_75 AC 232 ms
10,956 KB
testcase_76 AC 231 ms
10,964 KB
testcase_77 AC 234 ms
11,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x %= p;
	}
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{
	int n,k,m;
	cin>>n>>k>>m;
	vector<vector<ll>>a(4,vector<ll>(n));
	rep(i,4){
		rep(j,n){
			cin>>a[i][j];
		}
		sort(all(a[i]));
	}
	ll ans=0;
	rep(i,n){
		ll x=max({a[0][i],a[1][i],a[2][i],a[3][i]});
		ll y=min({a[0][i],a[1][i],a[2][i],a[3][i]});
		ans+=mypow<ll>(x-y,k,m);
		ans%=m;
	}
	cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0