結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー karinohitokarinohito
提出日時 2021-09-05 22:28:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 559 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 173,316 KB
実行使用メモリ 11,220 KB
最終ジャッジ日時 2023-08-24 05:30:12
合計ジャッジ時間 41,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 282 ms
6,924 KB
testcase_04 AC 276 ms
6,968 KB
testcase_05 AC 257 ms
6,992 KB
testcase_06 AC 270 ms
7,108 KB
testcase_07 AC 376 ms
8,692 KB
testcase_08 AC 377 ms
8,688 KB
testcase_09 AC 107 ms
4,928 KB
testcase_10 AC 107 ms
4,556 KB
testcase_11 AC 483 ms
10,420 KB
testcase_12 AC 482 ms
10,156 KB
testcase_13 AC 309 ms
7,444 KB
testcase_14 AC 310 ms
7,592 KB
testcase_15 AC 278 ms
6,924 KB
testcase_16 AC 276 ms
6,972 KB
testcase_17 AC 524 ms
10,464 KB
testcase_18 AC 521 ms
10,464 KB
testcase_19 AC 449 ms
9,412 KB
testcase_20 AC 452 ms
9,496 KB
testcase_21 AC 500 ms
10,028 KB
testcase_22 AC 485 ms
9,828 KB
testcase_23 AC 333 ms
8,100 KB
testcase_24 AC 327 ms
8,120 KB
testcase_25 AC 51 ms
4,376 KB
testcase_26 AC 50 ms
4,380 KB
testcase_27 AC 171 ms
5,340 KB
testcase_28 AC 180 ms
5,380 KB
testcase_29 AC 218 ms
5,980 KB
testcase_30 AC 223 ms
5,940 KB
testcase_31 AC 283 ms
7,040 KB
testcase_32 AC 277 ms
7,100 KB
testcase_33 AC 206 ms
5,936 KB
testcase_34 AC 206 ms
5,980 KB
testcase_35 AC 275 ms
7,268 KB
testcase_36 AC 272 ms
6,968 KB
testcase_37 AC 56 ms
4,380 KB
testcase_38 AC 56 ms
4,380 KB
testcase_39 AC 46 ms
4,376 KB
testcase_40 AC 45 ms
4,380 KB
testcase_41 AC 99 ms
4,500 KB
testcase_42 AC 96 ms
4,380 KB
testcase_43 AC 80 ms
4,376 KB
testcase_44 AC 507 ms
10,356 KB
testcase_45 AC 221 ms
6,240 KB
testcase_46 AC 75 ms
4,376 KB
testcase_47 AC 374 ms
8,088 KB
testcase_48 AC 346 ms
8,024 KB
testcase_49 AC 345 ms
8,240 KB
testcase_50 AC 268 ms
6,972 KB
testcase_51 AC 14 ms
4,380 KB
testcase_52 AC 455 ms
9,572 KB
testcase_53 AC 519 ms
10,992 KB
testcase_54 AC 545 ms
11,048 KB
testcase_55 AC 542 ms
10,996 KB
testcase_56 AC 539 ms
11,220 KB
testcase_57 AC 547 ms
10,944 KB
testcase_58 AC 542 ms
11,052 KB
testcase_59 AC 536 ms
11,064 KB
testcase_60 AC 527 ms
10,996 KB
testcase_61 AC 508 ms
10,992 KB
testcase_62 AC 534 ms
11,052 KB
testcase_63 AC 534 ms
11,064 KB
testcase_64 AC 541 ms
10,892 KB
testcase_65 AC 537 ms
10,924 KB
testcase_66 AC 527 ms
10,884 KB
testcase_67 AC 559 ms
11,068 KB
testcase_68 AC 531 ms
10,996 KB
testcase_69 AC 499 ms
10,992 KB
testcase_70 AC 502 ms
11,088 KB
testcase_71 AC 509 ms
10,992 KB
testcase_72 AC 544 ms
10,880 KB
testcase_73 AC 530 ms
11,052 KB
testcase_74 AC 530 ms
11,064 KB
testcase_75 AC 531 ms
10,988 KB
testcase_76 AC 527 ms
10,892 KB
testcase_77 AC 524 ms
11,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
struct fenwick_tree {
	ll n;
	vll bit;
	fenwick_tree(ll num) :bit(num + 1, 0) { n = num; }

	void add(ll i, ll w) {
		for (ll x = i+1; x <= n; x += x & -x) {
			bit[x-1] += w;
		}
	}

	ll sum(ll i) {
		ll ret = 0;
		for (ll x = i+1; x > 0; x -= x & -x) {
			ret += bit[x-1];
		}
		return ret;
	}

	ll sum(ll L, ll R) {
		return sum(R) - sum(L);
	}


};
ll TE(vll A) {
	ll res = 0;
	ll N = A.size();
	fenwick_tree fw(N);
	rep(i, N) {
		res += i - fw.sum(A[i]-1);
		fw.add(A[i], 1);
	}
	return res;
}
ll modPow(long long a, long long n, long long p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main() {

    ll N,K,M;
    cin>>N>>K>>M;
    vector<vll> A(4,vll(N));
    rep(i,4)rep(n,N)cin>>A[i][n];
    rep(i,4)sort(all(A[i]));
    ll AN=0;
    rep(i,N){
        ll Ma=max({A[0][i],A[1][i],A[2][i],A[3][i]});
        ll m=min({A[0][i],A[1][i],A[2][i],A[3][i]});
        ll d=Ma-m;
        //cout<<d<<endl;
        AN+=modPow(d,K,M);
        //cout<<AN<<endl;
        AN%=M;
    }
    cout<<AN<<endl;

}
0