結果
問題 | No.1043 直列大学 |
ユーザー | koyopro |
提出日時 | 2020-06-02 00:58:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,127 bytes |
コンパイル時間 | 1,984 ms |
コンパイル使用メモリ | 163,736 KB |
実行使用メモリ | 6,912 KB |
最終ジャッジ日時 | 2024-11-22 17:33:38 |
合計ジャッジ時間 | 3,582 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,824 KB |
testcase_01 | AC | 11 ms
6,816 KB |
testcase_02 | AC | 11 ms
6,816 KB |
testcase_03 | AC | 11 ms
6,820 KB |
testcase_04 | AC | 11 ms
6,824 KB |
testcase_05 | AC | 11 ms
6,820 KB |
testcase_06 | AC | 11 ms
6,820 KB |
testcase_07 | AC | 12 ms
6,816 KB |
testcase_08 | AC | 11 ms
6,820 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 26 ms
6,820 KB |
testcase_15 | AC | 30 ms
6,816 KB |
testcase_16 | AC | 27 ms
6,912 KB |
testcase_17 | AC | 22 ms
6,912 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 17 ms
6,816 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
ソースコード
#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define REP1(i, n) for(int i=1; i<=(n); i++) #define RREP1(i, n) for(int i=(n); i>=1; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define out(...) printf(__VA_ARGS__) #if DEBUG #define debug(...) printf(__VA_ARGS__) #else #define debug(...) /* ... */ #endif void solve(); signed main() { #if DEBUG std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); #endif cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; } /*================================*/ #if DEBUG #define SIZE 10 int MAX=1e5+10; #else #define SIZE 123 int MAX=1e5+10; #endif int N,M,V[SIZE],R[SIZE],A,B; int MOD=1e9+7; vector<int> DPV(MAX,0),DPR(MAX,0); template<typename T> class ST { using F = function<T(T, T)>; int size; T init; F f; vector<T> seg; int depth = 0; public: ST(int size, T init, F f): size(size), init(init), f(f) { while (1<<depth < size) depth++; seg.assign(2<<depth, init); } void update(int k, T t) { k += 1 << depth; seg[k] = t; while(k>>=1) seg[k] = f(seg[2*k], seg[2*k+1]); } T query(int a, int b) { a += 1<<depth; b += 1<<depth; T l = init; T r = init; while(a < b) { if (a & 1) l = f(l, seg[a++]); if (b & 1) r = f(r, seg[--b]); a >>= 1; b >>= 1; } return f(l, r); } T operator[] (int k) { return seg[k + (1<<depth)]; } }; template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; }; template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } typedef ModInt<1000000007> mint; void solve() { cin>>N>>M; REP(i,N)cin>>V[i]; REP(i,M)cin>>R[i]; cin>>A>>B; DPV[0]=1; DPR[0]=1; REP(i,N)RREP(j,MAX) { int nv = j + V[i]; if (nv<MAX) DPV[nv] += DPV[j]; int nr = j + R[i]; if (nr<MAX) DPR[nr] += DPR[j]; } auto st = ST<int>(MAX,0,[](int a,int b){return a+b;}); REP(j,MAX) { st.update(j, DPV[j]); } mint ans = 0; REP(j, MAX-1) if (j&&DPR[j]) { int add = DPR[j] * st.query(min(A*j,MAX-5), min(B*j+1,MAX-5)); debug("j:%lld, DPR[j]:%lld, add:%lld\n", j, DPR[j],add); ans += add; } cout << ans << endl; }