結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー yuto1115yuto1115
提出日時 2021-01-22 22:03:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 4,781 bytes
コンパイル時間 4,039 ms
コンパイル使用メモリ 204,696 KB
実行使用メモリ 6,424 KB
最終ジャッジ日時 2023-08-27 19:15:56
合計ジャッジ時間 22,481 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,504 KB
testcase_03 AC 145 ms
4,868 KB
testcase_04 AC 143 ms
4,544 KB
testcase_05 AC 130 ms
4,556 KB
testcase_06 AC 130 ms
4,672 KB
testcase_07 AC 196 ms
5,336 KB
testcase_08 AC 197 ms
5,456 KB
testcase_09 AC 56 ms
4,380 KB
testcase_10 AC 56 ms
4,376 KB
testcase_11 AC 254 ms
5,916 KB
testcase_12 AC 254 ms
5,916 KB
testcase_13 AC 162 ms
4,824 KB
testcase_14 AC 162 ms
4,804 KB
testcase_15 AC 143 ms
4,868 KB
testcase_16 AC 143 ms
4,656 KB
testcase_17 AC 271 ms
5,952 KB
testcase_18 AC 270 ms
5,904 KB
testcase_19 AC 231 ms
5,656 KB
testcase_20 AC 232 ms
5,668 KB
testcase_21 AC 251 ms
5,724 KB
testcase_22 AC 250 ms
5,744 KB
testcase_23 AC 171 ms
4,888 KB
testcase_24 AC 172 ms
5,136 KB
testcase_25 AC 28 ms
4,384 KB
testcase_26 AC 28 ms
4,380 KB
testcase_27 AC 89 ms
4,376 KB
testcase_28 AC 90 ms
4,384 KB
testcase_29 AC 109 ms
4,380 KB
testcase_30 AC 109 ms
4,504 KB
testcase_31 AC 146 ms
4,608 KB
testcase_32 AC 146 ms
4,776 KB
testcase_33 AC 108 ms
4,604 KB
testcase_34 AC 108 ms
4,580 KB
testcase_35 AC 142 ms
4,692 KB
testcase_36 AC 142 ms
4,684 KB
testcase_37 AC 30 ms
4,376 KB
testcase_38 AC 29 ms
4,384 KB
testcase_39 AC 25 ms
4,376 KB
testcase_40 AC 24 ms
4,380 KB
testcase_41 AC 52 ms
4,376 KB
testcase_42 AC 51 ms
4,376 KB
testcase_43 AC 41 ms
4,380 KB
testcase_44 AC 266 ms
6,016 KB
testcase_45 AC 112 ms
4,420 KB
testcase_46 AC 39 ms
4,380 KB
testcase_47 AC 189 ms
5,072 KB
testcase_48 AC 178 ms
5,108 KB
testcase_49 AC 179 ms
5,128 KB
testcase_50 AC 138 ms
4,544 KB
testcase_51 AC 8 ms
4,380 KB
testcase_52 AC 238 ms
5,616 KB
testcase_53 AC 269 ms
6,132 KB
testcase_54 AC 283 ms
6,144 KB
testcase_55 AC 279 ms
6,184 KB
testcase_56 AC 284 ms
6,140 KB
testcase_57 AC 286 ms
6,252 KB
testcase_58 AC 283 ms
6,220 KB
testcase_59 AC 282 ms
6,184 KB
testcase_60 AC 275 ms
6,260 KB
testcase_61 AC 260 ms
6,144 KB
testcase_62 AC 280 ms
6,220 KB
testcase_63 AC 282 ms
6,248 KB
testcase_64 AC 284 ms
6,272 KB
testcase_65 AC 278 ms
6,256 KB
testcase_66 AC 280 ms
6,424 KB
testcase_67 AC 290 ms
6,180 KB
testcase_68 AC 275 ms
6,180 KB
testcase_69 AC 259 ms
6,144 KB
testcase_70 AC 263 ms
6,176 KB
testcase_71 AC 252 ms
6,272 KB
testcase_72 AC 284 ms
6,224 KB
testcase_73 AC 278 ms
6,208 KB
testcase_74 AC 275 ms
6,264 KB
testcase_75 AC 275 ms
6,128 KB
testcase_76 AC 272 ms
6,144 KB
testcase_77 AC 276 ms
6,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//@formatter:off
#include<bits/stdc++.h>
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(i,n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i)
#define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d)
#define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep(i,n) for (ll i = ll(n)-1; i >= 0; i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#ifdef __LOCAL
#define debug(...) { cout << #__VA_ARGS__; cout << ": "; print(__VA_ARGS__); cout << flush; }
#else
#define debug(...) void(0)
#endif
#define INT(...) int __VA_ARGS__;scan(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;scan(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,int>;
using LP = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vs = vector<string>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vp = vector<P>;
using vvp = vector<vector<P>>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
void scan(){}
template <class Head, class... Tail> void scan(Head& head, Tail&... tail){ cin >> head; scan(tail...); }
template<class T> void print(const T& t){ cout << t << '\n'; }
template <class Head, class... Tail> void print(const Head& head, const Tail&... tail){ cout<<head<<' '; print(tail...); }
template<class T> void fin(T a) { print(a); exit(0); }
const string yes[] = {"no","yes"};
const string Yes[] = {"No","Yes"};
const string YES[] = {"NO","YES"};
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int mod = -1;

struct mint {
    ll x;
    
    mint(ll x = 0) : x((x % mod + mod) % mod) { assert(mod > 0); }
    
    mint operator-() const { return mint(-x); }
    
    mint &operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint &operator++() { return *this += mint(1); }
    
    mint &operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint &operator--() { return *this -= mint(1); }
    
    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 {
        mint res = mint(1), a(*this);
        while (t > 0) {
            if (t & 1) res *= a;
            t >>= 1;
            a *= a;
        }
        return res;
    }
    
    // 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;
    }
};

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

bool operator==(const mint &a, const mint &b) { return a.x == b.x; }

bool operator!=(const mint &a, const mint &b) { return a.x != b.x; }

bool operator==(const mint &a, const int &b) { return a.x == b; }

bool operator!=(const mint &a, const int &b) { return a.x != b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    INT(n, k);
    scan(mod);
    vi p(n), e(n), a(n), h(n);
    cin >> p >> e >> a >> h;
    sort(all(p));
    sort(all(e));
    sort(all(a));
    sort(all(h));
    mint ans = 0;
    rep(i, n) {
        vi v = {p[i], e[i], a[i], h[i]};
        sort(all(v));
        int d = v[3] - v[0];
        ans += mint(d).pow(k);
    }
    print(ans);
}
0