結果
問題 | No.1043 直列大学 |
ユーザー | kilala |
提出日時 | 2020-05-02 00:08:59 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,519 bytes |
コンパイル時間 | 1,893 ms |
コンパイル使用メモリ | 180,996 KB |
実行使用メモリ | 17,492 KB |
最終ジャッジ日時 | 2024-06-07 12:55:07 |
合計ジャッジ時間 | 7,404 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
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 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
ソースコード
#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; vector<ll> rls; 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 < rl.size(); ++i) cout << rp[rl[i]] << '_'; // cout << endl; rls.push_back(rp[rl[0]]); // cout << rls[0] << '_'; for (int i = 1; i < rl.size(); ++i) { ll s = (rls[i-1] + rp[rl[i]]) % MOD; rls.push_back(s); // cout << rls[i] << '_'; } // cout << endl; for (int i = 0; i < vl.size(); ++i) { double lb = vl[i] / (double)b, hb = vl[i] / (double)a; // cout << vl[i] <<' ' << lb << ' ' << hb<< endl; auto lbidx = lower_bound(rl.begin(), rl.end(), lb); auto hbidx = lower_bound(rl.begin(), rl.end(), hb); if (lbidx == rl.end()) continue; if (hbidx == rl.end()) hbidx--; if (vl[i] / (double)*hbidx < a) hbidx--; if (vl[i] / (double)*lbidx > b) lbidx++; // cout << *(lbidx) << ' ' << *(hbidx) << endl; int lbi = lbidx - rl.begin(); int hbi = hbidx - rl.begin(); // cout << lbi << '_' << hbi << endl; ans += (vp[vl[i]] % MOD) * (rls[hbi] - rls[lbi]) % MOD; // cout << ans << '-' << rp[rl[lbi]] << endl; ans = (ans + (vp[vl[i]] % MOD) * rp[rl[lbi]]) % MOD; // cout << ans << endl; } cout << ans << endl; return 0; }