結果
問題 | No.1359 [Zelkova 3rd Tune] 四人セゾン |
ユーザー | tokusakurai |
提出日時 | 2021-01-22 21:54:48 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 3,336 bytes |
コンパイル時間 | 2,388 ms |
コンパイル使用メモリ | 213,980 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-08 14:31:44 |
合計ジャッジ時間 | 20,630 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 138 ms
7,168 KB |
testcase_04 | AC | 141 ms
7,040 KB |
testcase_05 | AC | 121 ms
7,168 KB |
testcase_06 | AC | 121 ms
7,040 KB |
testcase_07 | AC | 178 ms
8,832 KB |
testcase_08 | AC | 179 ms
8,704 KB |
testcase_09 | AC | 52 ms
5,376 KB |
testcase_10 | AC | 50 ms
5,376 KB |
testcase_11 | AC | 228 ms
10,112 KB |
testcase_12 | AC | 232 ms
10,112 KB |
testcase_13 | AC | 146 ms
7,680 KB |
testcase_14 | AC | 150 ms
7,680 KB |
testcase_15 | AC | 131 ms
7,040 KB |
testcase_16 | AC | 131 ms
7,168 KB |
testcase_17 | AC | 246 ms
10,368 KB |
testcase_18 | AC | 249 ms
10,496 KB |
testcase_19 | AC | 223 ms
9,472 KB |
testcase_20 | AC | 215 ms
9,472 KB |
testcase_21 | AC | 278 ms
9,984 KB |
testcase_22 | AC | 232 ms
9,984 KB |
testcase_23 | AC | 158 ms
8,064 KB |
testcase_24 | AC | 157 ms
8,064 KB |
testcase_25 | AC | 25 ms
5,376 KB |
testcase_26 | AC | 24 ms
5,376 KB |
testcase_27 | AC | 79 ms
5,632 KB |
testcase_28 | AC | 81 ms
5,632 KB |
testcase_29 | AC | 99 ms
6,144 KB |
testcase_30 | AC | 104 ms
6,144 KB |
testcase_31 | AC | 137 ms
7,296 KB |
testcase_32 | AC | 132 ms
7,168 KB |
testcase_33 | AC | 101 ms
6,272 KB |
testcase_34 | AC | 101 ms
6,144 KB |
testcase_35 | AC | 129 ms
7,040 KB |
testcase_36 | AC | 135 ms
6,912 KB |
testcase_37 | AC | 27 ms
5,376 KB |
testcase_38 | AC | 28 ms
5,376 KB |
testcase_39 | AC | 24 ms
5,376 KB |
testcase_40 | AC | 23 ms
5,376 KB |
testcase_41 | AC | 48 ms
5,376 KB |
testcase_42 | AC | 49 ms
5,376 KB |
testcase_43 | AC | 39 ms
5,376 KB |
testcase_44 | AC | 251 ms
10,624 KB |
testcase_45 | AC | 107 ms
6,272 KB |
testcase_46 | AC | 36 ms
5,376 KB |
testcase_47 | AC | 171 ms
8,192 KB |
testcase_48 | AC | 162 ms
8,192 KB |
testcase_49 | AC | 167 ms
8,320 KB |
testcase_50 | AC | 127 ms
7,040 KB |
testcase_51 | AC | 8 ms
5,376 KB |
testcase_52 | AC | 217 ms
9,728 KB |
testcase_53 | AC | 245 ms
10,880 KB |
testcase_54 | AC | 258 ms
10,880 KB |
testcase_55 | AC | 247 ms
10,880 KB |
testcase_56 | AC | 253 ms
10,880 KB |
testcase_57 | AC | 257 ms
10,880 KB |
testcase_58 | AC | 259 ms
11,008 KB |
testcase_59 | AC | 262 ms
10,880 KB |
testcase_60 | AC | 249 ms
10,880 KB |
testcase_61 | AC | 241 ms
10,880 KB |
testcase_62 | AC | 261 ms
10,880 KB |
testcase_63 | AC | 254 ms
10,880 KB |
testcase_64 | AC | 267 ms
10,752 KB |
testcase_65 | AC | 256 ms
10,880 KB |
testcase_66 | AC | 251 ms
11,008 KB |
testcase_67 | AC | 267 ms
10,880 KB |
testcase_68 | AC | 245 ms
10,880 KB |
testcase_69 | AC | 234 ms
10,880 KB |
testcase_70 | AC | 235 ms
10,880 KB |
testcase_71 | AC | 229 ms
10,880 KB |
testcase_72 | AC | 259 ms
10,880 KB |
testcase_73 | AC | 309 ms
11,008 KB |
testcase_74 | AC | 260 ms
10,880 KB |
testcase_75 | AC | 256 ms
10,880 KB |
testcase_76 | AC | 258 ms
10,880 KB |
testcase_77 | AC | 257 ms
11,008 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define each(e, v) for(auto &e: v) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)x.size() using ll = long long; using pii = pair<int, int>; using pil = pair<int, ll>; using pli = pair<ll, int>; using pll = pair<ll, ll>; const int MOD = 1000000007; //const int MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; struct io_setup{ io_setup(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout << fixed << setprecision(15); } } io_setup; struct Random_Number_Generator{ mt19937_64 mt; Random_Number_Generator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {} int64_t operator () (int64_t l, int64_t r){ uniform_int_distribution<int64_t> dist(l, r-1); return dist(mt); } int64_t operator () (int64_t r){ return (*this)(0, r); } }; ll modpow(ll x, ll n, const int &m){ ll ret = 1; for(; n; n >>= 1, x *= x, x %= m){ if(n&1) ret *= x, ret %= m; } return ret; } template<typename T> T Euler_Totient(T m){ //オイラーのφ関数(xとmが互いに素ならば、x^φ(m)≡1(mod m)) T ret = m; for(T i = 2; i*i <= m; i++){ if(m%i == 0) ret /= i, ret *= i-1; while(m%i == 0) m /= i; } if(m > 1) ret /= m, ret *= m-1; return ret; } int modlog(const int &x, ll y, const int &m){ //x^k=y(mod m)となる最小の非負整数k(xとmは互いに素) unordered_map<int, int> mp; int n = 0; ll now = 1; for(; n*n < m; n++){ if(!mp.count(now)) mp[now] = n; now *= x, now %= m; } now = modpow(now, Euler_Totient(m)-1, m); rep(i, n){ if(mp.count(y)) return n*i+mp[y]; y *= now, y %= m; } return -1; } template<typename T> T order(T x, const T &m){ //x^k=1(mod m)となる最小の正整数k(xとmは互いに素) T n = Euler_Totient(m); vector<T> ds; for(T i = 1; i*i <= n; i++){ if(n%i == 0) ds.pb(i), ds.pb(n/i); } sort(all(ds)); for(auto &e: ds){ if(modpow(x, e, m) == 1) return e; } return -1; } template<typename T> T primitive_root(const T &m){ //素数mの原始根 vector<T> ds; for(T i = 1; i*i <= m-1; i++){ if((m-1)%i == 0) ds.pb(i), ds.pb((m-1)/i); } sort(all(ds)); Random_Number_Generator rnd; while(true){ T r = rnd(1, m); for(auto &e: ds){ if(e == m-1) return r; if(modpow(r, e, m) == 1) break; } } } int main(){ int N; ll K, M; cin >> N >> K >> M; vector<vector<ll>> A(4, vector<ll>(N)); rep(i, 4){ rep(j, N) cin >> A[i][j]; } rep(i, 4) sort(all(A[i])); ll ans = 0; rep(i, N){ ll p = -INF, m = INF; rep(j, 4) chmax(p, A[j][i]), chmin(m, A[j][i]); ans += modpow(p-m, K, M); ans %= M; } cout << ans << '\n'; }