結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー soto800soto800
提出日時 2021-01-22 21:34:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 1,690 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 171,476 KB
実行使用メモリ 9,568 KB
最終ジャッジ日時 2023-08-27 17:46:09
合計ジャッジ時間 30,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 241 ms
6,240 KB
testcase_04 AC 240 ms
6,248 KB
testcase_05 AC 227 ms
6,260 KB
testcase_06 AC 227 ms
6,200 KB
testcase_07 AC 335 ms
7,752 KB
testcase_08 AC 335 ms
7,500 KB
testcase_09 AC 92 ms
4,552 KB
testcase_10 AC 92 ms
4,380 KB
testcase_11 AC 424 ms
8,604 KB
testcase_12 AC 427 ms
8,532 KB
testcase_13 AC 273 ms
6,680 KB
testcase_14 AC 273 ms
6,676 KB
testcase_15 AC 238 ms
6,320 KB
testcase_16 AC 239 ms
6,120 KB
testcase_17 AC 447 ms
8,840 KB
testcase_18 AC 450 ms
8,760 KB
testcase_19 AC 389 ms
8,044 KB
testcase_20 AC 390 ms
7,960 KB
testcase_21 AC 420 ms
8,808 KB
testcase_22 AC 418 ms
8,652 KB
testcase_23 AC 289 ms
7,052 KB
testcase_24 AC 288 ms
6,912 KB
testcase_25 AC 45 ms
4,376 KB
testcase_26 AC 46 ms
4,380 KB
testcase_27 AC 150 ms
4,788 KB
testcase_28 AC 149 ms
4,828 KB
testcase_29 AC 183 ms
5,320 KB
testcase_30 AC 184 ms
5,364 KB
testcase_31 AC 245 ms
6,148 KB
testcase_32 AC 246 ms
6,144 KB
testcase_33 AC 181 ms
5,356 KB
testcase_34 AC 180 ms
5,404 KB
testcase_35 AC 239 ms
6,256 KB
testcase_36 AC 239 ms
6,152 KB
testcase_37 AC 49 ms
4,376 KB
testcase_38 AC 48 ms
4,376 KB
testcase_39 AC 40 ms
4,380 KB
testcase_40 AC 39 ms
4,376 KB
testcase_41 AC 85 ms
4,380 KB
testcase_42 AC 85 ms
4,380 KB
testcase_43 AC 70 ms
4,376 KB
testcase_44 AC 449 ms
9,132 KB
testcase_45 AC 189 ms
5,356 KB
testcase_46 AC 64 ms
4,376 KB
testcase_47 AC 316 ms
7,304 KB
testcase_48 AC 302 ms
6,956 KB
testcase_49 AC 306 ms
7,252 KB
testcase_50 AC 234 ms
6,192 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 401 ms
8,268 KB
testcase_53 AC 459 ms
9,416 KB
testcase_54 AC 474 ms
9,280 KB
testcase_55 AC 471 ms
9,360 KB
testcase_56 AC 473 ms
9,320 KB
testcase_57 AC 476 ms
9,360 KB
testcase_58 AC 477 ms
9,316 KB
testcase_59 AC 472 ms
9,268 KB
testcase_60 AC 467 ms
9,424 KB
testcase_61 AC 454 ms
9,392 KB
testcase_62 AC 474 ms
9,320 KB
testcase_63 AC 474 ms
9,268 KB
testcase_64 AC 474 ms
9,276 KB
testcase_65 AC 472 ms
9,320 KB
testcase_66 AC 472 ms
9,324 KB
testcase_67 AC 479 ms
9,428 KB
testcase_68 AC 467 ms
9,424 KB
testcase_69 AC 451 ms
9,568 KB
testcase_70 AC 452 ms
9,316 KB
testcase_71 AC 444 ms
9,348 KB
testcase_72 AC 475 ms
9,428 KB
testcase_73 AC 468 ms
9,348 KB
testcase_74 AC 465 ms
9,316 KB
testcase_75 AC 467 ms
9,352 KB
testcase_76 AC 462 ms
9,328 KB
testcase_77 AC 465 ms
9,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<28)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define MOD (1000000007)
#define TO_STRING(VariableName) # VariableName
#define LOG(xx) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<endl;
#define LOG2(xx,yy) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<endl;
#define LOG3(xx,yy,z) if(DEBUG)cout<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,xx,yy,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(xx)<<"="<<xx<<" "<<TO_STRING(yy)<<"="<<yy<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// a^n mod を計算する
lli modpow(lli a, lli n, lli mod) {
    lli res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){

    lli n,k,m;
    cin>>n>>k>>m;

    vector<lli> p(n),e(n),a(n),h(n);

    REP(i,0,n)cin>>p[i];
    REP(i,0,n)cin>>e[i];
    REP(i,0,n)cin>>a[i];
    REP(i,0,n)cin>>h[i];

    SORT(p);
    SORT(e);
    SORT(a);
    SORT(h);

    lli ans = 0;

    REP(i,0,n){
        lli minN = min({p[i],e[i],a[i],h[i]});
        lli maxN = max({p[i],e[i],a[i],h[i]});
        lli diff = maxN-minN;
        lli modP = modpow(diff,k,m);
        ans += modP;
        ans %= m;
    }
    cout<<ans<<endl;


    return 0;
}
0