結果
問題 | No.1043 直列大学 |
ユーザー | koyopro |
提出日時 | 2020-06-02 00:56:48 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,105 bytes |
コンパイル時間 | 1,441 ms |
コンパイル使用メモリ | 163,448 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-05-02 06:03:50 |
合計ジャッジ時間 | 5,595 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,656 KB |
testcase_01 | AC | 10 ms
6,784 KB |
testcase_02 | AC | 11 ms
6,784 KB |
testcase_03 | AC | 10 ms
6,912 KB |
testcase_04 | AC | 10 ms
6,656 KB |
testcase_05 | AC | 10 ms
6,784 KB |
testcase_06 | AC | 10 ms
6,656 KB |
testcase_07 | AC | 11 ms
6,656 KB |
testcase_08 | AC | 10 ms
6,912 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | WA | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | WA | - |
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(A*j, B*j+1); debug("j:%lld, DPR[j]:%lld, add:%lld\n", j, DPR[j],add); ans += add; } cout << ans << endl; }