結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー kkktymkkktym
提出日時 2021-01-22 21:39:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 529 ms / 2,000 ms
コード長 2,454 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 108,184 KB
実行使用メモリ 11,260 KB
最終ジャッジ日時 2023-08-27 18:03:35
合計ジャッジ時間 32,216 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 265 ms
6,984 KB
testcase_04 AC 266 ms
7,140 KB
testcase_05 AC 248 ms
7,116 KB
testcase_06 AC 249 ms
7,016 KB
testcase_07 AC 362 ms
8,652 KB
testcase_08 AC 363 ms
8,524 KB
testcase_09 AC 103 ms
4,568 KB
testcase_10 AC 102 ms
4,608 KB
testcase_11 AC 457 ms
10,436 KB
testcase_12 AC 458 ms
10,176 KB
testcase_13 AC 294 ms
7,604 KB
testcase_14 AC 297 ms
7,504 KB
testcase_15 AC 265 ms
7,020 KB
testcase_16 AC 266 ms
7,068 KB
testcase_17 AC 500 ms
10,452 KB
testcase_18 AC 501 ms
10,432 KB
testcase_19 AC 428 ms
9,516 KB
testcase_20 AC 429 ms
9,452 KB
testcase_21 AC 465 ms
10,044 KB
testcase_22 AC 464 ms
10,168 KB
testcase_23 AC 312 ms
7,804 KB
testcase_24 AC 312 ms
7,756 KB
testcase_25 AC 48 ms
4,376 KB
testcase_26 AC 48 ms
4,376 KB
testcase_27 AC 163 ms
5,496 KB
testcase_28 AC 163 ms
5,356 KB
testcase_29 AC 199 ms
6,064 KB
testcase_30 AC 199 ms
5,916 KB
testcase_31 AC 266 ms
6,944 KB
testcase_32 AC 267 ms
7,008 KB
testcase_33 AC 196 ms
5,944 KB
testcase_34 AC 196 ms
5,908 KB
testcase_35 AC 261 ms
7,072 KB
testcase_36 AC 261 ms
6,940 KB
testcase_37 AC 53 ms
4,376 KB
testcase_38 AC 52 ms
4,376 KB
testcase_39 AC 43 ms
4,376 KB
testcase_40 AC 44 ms
4,376 KB
testcase_41 AC 91 ms
4,492 KB
testcase_42 AC 91 ms
4,428 KB
testcase_43 AC 74 ms
4,380 KB
testcase_44 AC 481 ms
10,408 KB
testcase_45 AC 207 ms
6,192 KB
testcase_46 AC 71 ms
4,376 KB
testcase_47 AC 352 ms
8,456 KB
testcase_48 AC 321 ms
8,016 KB
testcase_49 AC 327 ms
8,280 KB
testcase_50 AC 255 ms
7,064 KB
testcase_51 AC 13 ms
4,376 KB
testcase_52 AC 433 ms
9,780 KB
testcase_53 AC 494 ms
10,904 KB
testcase_54 AC 519 ms
10,964 KB
testcase_55 AC 516 ms
11,096 KB
testcase_56 AC 518 ms
10,960 KB
testcase_57 AC 524 ms
11,096 KB
testcase_58 AC 518 ms
11,032 KB
testcase_59 AC 511 ms
10,936 KB
testcase_60 AC 505 ms
10,968 KB
testcase_61 AC 490 ms
11,028 KB
testcase_62 AC 512 ms
11,080 KB
testcase_63 AC 510 ms
11,076 KB
testcase_64 AC 516 ms
11,080 KB
testcase_65 AC 512 ms
11,044 KB
testcase_66 AC 505 ms
11,076 KB
testcase_67 AC 529 ms
11,064 KB
testcase_68 AC 512 ms
10,960 KB
testcase_69 AC 478 ms
11,036 KB
testcase_70 AC 483 ms
11,076 KB
testcase_71 AC 478 ms
11,020 KB
testcase_72 AC 521 ms
11,024 KB
testcase_73 AC 507 ms
10,972 KB
testcase_74 AC 511 ms
10,948 KB
testcase_75 AC 507 ms
11,260 KB
testcase_76 AC 505 ms
11,224 KB
testcase_77 AC 501 ms
10,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
// 任意MODが使えるModint 
// 型宣言の前にmodint::set_mod(MOD) をしてね
struct modint{
  long long x;

  modint() : x(0) {}
  modint(long long x):x(x%mod()){}

  static int &mod() {
    static int mod = 0;
    return mod;
  }

  static void set_mod(int md) {
    mod() = md;
  }

  modint& operator+=(const modint a){
    if((x+=a.x)>=mod()) x-=mod();
    return *this;
  }
  modint& operator-=(const modint a){
    if((x += mod()-a.x)>=mod()) x-=mod();
    return *this;
  }
  modint& operator*=(const modint a){
    (x*=a.x)%=mod();
    return *this;
  }
  modint operator+(const modint a) const{
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint a) const{
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint a) const{
    modint res(*this);
    return res*=a;
  }
  modint pow(long long t) const{
    if(!t) return 1;
    modint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  modint inv() const{
    return pow(mod()-2);
  }
  modint& operator/=(const modint a){
    return (*this) *= a.inv();
  }
  modint operator/(const modint a) const{
    modint res(*this);
    return res/=a;
  }
};


int main()
{
  int n; cin >> n;
  ll k,m; cin >> k >> m;
  modint::set_mod(m);
  vvl a(4, vl(n));
  rep(i,4) {
    rep(j,n) cin >> a[i][j];
  }

  rep(i,4) {
    sort(a[i].begin(),a[i].end());
  }

  modint res;
  rep(i,n) {
    ll mx = -infll, mn = infll;
    rep(j,4) {
      chmax(mx, a[j][i]);
      chmin(mn, a[j][i]);
    }
    modint tmp(mx - mn);
    res += tmp.pow(k);
  }
  cout << res.x << "\n"; 


  return 0;
}
0