結果
問題 | No.1460 Max of Min |
ユーザー | 沙耶花 |
提出日時 | 2021-03-31 22:55:22 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,071 bytes |
コンパイル時間 | 4,941 ms |
コンパイル使用メモリ | 266,896 KB |
実行使用メモリ | 17,352 KB |
最終ジャッジ日時 | 2024-12-15 21:26:47 |
合計ジャッジ時間 | 223,599 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
10,280 KB |
testcase_01 | AC | 2 ms
10,148 KB |
testcase_02 | AC | 2 ms
13,640 KB |
testcase_03 | TLE | - |
testcase_04 | TLE | - |
testcase_05 | AC | 2 ms
10,276 KB |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | AC | 3 ms
13,632 KB |
testcase_09 | AC | 3 ms
10,148 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | AC | 1,290 ms
10,152 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 1,923 ms
13,640 KB |
testcase_15 | AC | 909 ms
10,276 KB |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | AC | 78 ms
10,272 KB |
testcase_19 | TLE | - |
testcase_20 | AC | 125 ms
10,148 KB |
testcase_21 | AC | 360 ms
10,400 KB |
testcase_22 | TLE | - |
testcase_23 | AC | 68 ms
10,276 KB |
testcase_24 | TLE | - |
testcase_25 | AC | 52 ms
10,148 KB |
testcase_26 | TLE | - |
testcase_27 | AC | 915 ms
10,276 KB |
testcase_28 | AC | 250 ms
13,640 KB |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | AC | 1,808 ms
10,148 KB |
testcase_34 | TLE | - |
testcase_35 | AC | 855 ms
10,148 KB |
testcase_36 | AC | 306 ms
10,404 KB |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | AC | 1,797 ms
10,152 KB |
testcase_40 | AC | 1,267 ms
10,404 KB |
testcase_41 | AC | 921 ms
10,272 KB |
testcase_42 | AC | 529 ms
13,640 KB |
testcase_43 | TLE | - |
testcase_44 | TLE | - |
testcase_45 | AC | 153 ms
10,404 KB |
testcase_46 | TLE | - |
testcase_47 | TLE | - |
testcase_48 | TLE | - |
testcase_49 | TLE | - |
testcase_50 | AC | 217 ms
13,640 KB |
testcase_51 | TLE | - |
testcase_52 | AC | 727 ms
10,272 KB |
testcase_53 | TLE | - |
testcase_54 | TLE | - |
testcase_55 | TLE | - |
testcase_56 | TLE | - |
testcase_57 | TLE | - |
testcase_58 | TLE | - |
testcase_59 | TLE | - |
testcase_60 | TLE | - |
testcase_61 | TLE | - |
testcase_62 | TLE | - |
testcase_63 | TLE | - |
testcase_64 | TLE | - |
testcase_65 | TLE | - |
testcase_66 | TLE | - |
testcase_67 | TLE | - |
testcase_68 | TLE | - |
testcase_69 | TLE | - |
testcase_70 | TLE | - |
testcase_71 | TLE | - |
testcase_72 | TLE | - |
testcase_73 | TLE | - |
testcase_74 | TLE | - |
testcase_75 | TLE | - |
testcase_76 | TLE | - |
testcase_77 | TLE | - |
testcase_78 | TLE | - |
testcase_79 | TLE | - |
testcase_80 | TLE | - |
testcase_81 | TLE | - |
testcase_82 | TLE | - |
testcase_83 | TLE | - |
testcase_84 | TLE | - |
testcase_85 | TLE | - |
testcase_86 | TLE | - |
testcase_87 | TLE | - |
testcase_88 | TLE | - |
testcase_89 | TLE | - |
testcase_90 | TLE | - |
testcase_91 | TLE | - |
testcase_92 | TLE | - |
testcase_93 | TLE | - |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000001 template<typename T> struct Kitamasa{ const int k; const vector<T> a, c; Kitamasa(const vector<T> &a, const vector<T> &c): k(a.size()), a(a), c(c) {} T solve(long long n){ T res = 0; auto d = cal(n); for(int i = 0; i < k; i++) res += d[i] * a[i]; return res; } private: vector<T> p1(const vector<T> &x){ /* a_n = sum(x_i * a_i) のとき、 a_n+1 = sum(y_i * a_i) となるyを求める a_n+1 = sum(x_i * a_i+1) = sum(x_i * a_i+1) + x_k-1*a_k = sum(x_i * a_i+1) + x_k-1*sum(c_i * a_i) //*/ vector<T> res(k); res[0] = x[k-1] * c[0]; for(int i = 1; i < k; i++){ res[i] = x[i-1] + (x[k-1] * c[i]); } return res; } vector<T> sq(const vector<T> &x){ /* a_n = sum(x_i * a_i) のとき、 a_2n = sum(y_i * a_i) となるyを求める a_2n = sum(x_i * a_n+i) ここで、 f(n) = x, f(n+1) = p1(f(n)), ... , f(n+k-1) が列挙できたとすると a_n+i = sum(f(n+i)_j * a_j) となる よって、 a_2n = sum(x_i*sum(f(n+i)_j * a_j)) //*/ vector<T> res(k); auto d = x; for(int i = 0; i < k; i++){ for(int j = 0; j < k; j++){ res[j] += x[i] * d[j]; } d = p1(d); } return res; } vector<T> cal(long long n){ vector<T> res(k); res[0] = 1; for(int i = 62; i >= 0; i--){ res = sq(res); if(n & (1ll << i)) res = p1(res); } return res; } }; template< int mod > struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { x |= p.x; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x &= p.x; return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; } }; constexpr int MOD = 2; using mint = ModInt< MOD >; using VM = vector<mint>; using VVM = vector<VM>; int solve(long long nn,long long kk,vector<long long> aa,vector<long long> bb){ int k = kk; long long n= nn; VM a(k, 1), c(k, 1); rep(i,k){ a[i] = aa[i]; c[i] = bb[i]; } Kitamasa kita(a, c); return kita.solve(n).x; } int main(){ int K; long long N; cin>>K>>N; vector<long long> A(K),B(K); rep(i,K){ cin>>A[i]; } rep(i,K){ cin>>B[i]; } long long ok = -Inf,ng = Inf; while(ng-ok>1LL){ long long mid = (ok+ng)/2; vector<long long> a(K),b(K); rep(i,K){ if(A[i]<mid){ a[i] = 0; } else{ a[i] = 1; } if(B[i]<mid){ b[i] = 0; } else{ b[i] = 1; } } if(solve(N,K,a,b)==1)ok = mid; else ng = mid; } cout<<ok<<endl; return 0; }