結果

問題 No.1043 直列大学
ユーザー kilalakilala
提出日時 2020-05-01 22:56:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,782 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 178,012 KB
実行使用メモリ 21,248 KB
最終ジャッジ日時 2023-08-26 15:38:07
合計ジャッジ時間 5,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 121 ms
4,376 KB
testcase_10 AC 169 ms
4,376 KB
testcase_11 AC 63 ms
4,376 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  
#include <bits/stdc++.h>

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int v[105] = {0}, r[105] = {0};
unordered_map<long long, ll> vp, rp;
unordered_map<long long, ll> vpa, rpa;
vector<ll> vl, rl;
int main() {
    int n, m, a, b;
    long long ans = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int i = 0; i < m; ++i) cin >> r[i];
    cin >> a >> b;

    for (int i = 0; i < n; ++i) {
        vpa = vp;
        int vll = vl.size();
        long long vn = v[i];
        if (!vp.count(vn)) vl.push_back(vn);
        vpa[vn]++;
        vpa[vn] %= MOD;
        for (int j = 0; j < vll; ++j) {
            if (!vp.count(vn + vl[j])) {
                vl.push_back(vn + vl[j]);
            }
            vpa[vn+vl[j]] += vp[vl[j]];
            vpa[vn+vl[j]] %= MOD;
        }
        vp = vpa;
    }
    for (int i = 0; i < m; ++i) {
        rpa = rp;
        int rll = rl.size();
        ll rn = r[i];
        if (!rp.count(rn)) rl.push_back(rn);
        rpa[rn]++;
        rpa[rn] %= MOD;
        for (int j = 0; j < rll; ++j) {
            if (!rp.count(rn + rl[j])) {
                rl.push_back(rn + rl[j]);
            }
            rpa[rn+rl[j]]+=rp[rl[j]];
            rpa[rn+rl[j]] %= MOD;
        }
        rp = rpa;
    }

    for (int i = 0; i < vl.size(); ++i) {
        for (int j = 0; j < rl.size(); ++j) {
            double ii = (double)vl[i] / (double)rl[j];
            if (ii <= b && ii >= a) {
                ans += (vp[vl[i]] % MOD) * (rp[rl[j]]% MOD) % MOD;
                // cout << vl[i] << ' ' << vp[vl[i]] << endl;
                // cout << rl[j] << ' ' << rp[rl[j]] << endl;
                // cout << ans << endl;
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0