結果
問題 | No.2581 [Cherry Anniversary 3] 28輪の桜のブーケ |
ユーザー | Kude |
提出日時 | 2023-12-09 00:14:03 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 349 ms / 3,000 ms |
コード長 | 1,707 bytes |
コンパイル時間 | 3,728 ms |
コンパイル使用メモリ | 282,740 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2023-12-09 00:14:22 |
合計ジャッジ時間 | 8,760 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,676 KB |
testcase_01 | AC | 5 ms
6,676 KB |
testcase_02 | AC | 16 ms
6,676 KB |
testcase_03 | AC | 122 ms
6,676 KB |
testcase_04 | AC | 69 ms
6,676 KB |
testcase_05 | AC | 10 ms
6,676 KB |
testcase_06 | AC | 104 ms
6,676 KB |
testcase_07 | AC | 98 ms
6,676 KB |
testcase_08 | AC | 24 ms
6,676 KB |
testcase_09 | AC | 62 ms
6,676 KB |
testcase_10 | AC | 98 ms
6,676 KB |
testcase_11 | AC | 18 ms
6,676 KB |
testcase_12 | AC | 128 ms
6,676 KB |
testcase_13 | AC | 147 ms
6,676 KB |
testcase_14 | AC | 125 ms
6,676 KB |
testcase_15 | AC | 122 ms
6,676 KB |
testcase_16 | AC | 122 ms
6,676 KB |
testcase_17 | AC | 122 ms
6,676 KB |
testcase_18 | AC | 139 ms
6,676 KB |
testcase_19 | AC | 155 ms
6,676 KB |
testcase_20 | AC | 154 ms
6,676 KB |
testcase_21 | AC | 148 ms
6,676 KB |
testcase_22 | AC | 347 ms
6,676 KB |
testcase_23 | AC | 349 ms
6,676 KB |
testcase_24 | AC | 338 ms
6,676 KB |
testcase_25 | AC | 344 ms
6,676 KB |
testcase_26 | AC | 330 ms
6,676 KB |
testcase_27 | AC | 10 ms
6,676 KB |
testcase_28 | AC | 10 ms
6,676 KB |
testcase_29 | AC | 296 ms
6,676 KB |
testcase_30 | AC | 62 ms
6,676 KB |
testcase_31 | AC | 134 ms
6,676 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using mint = modint; } int main() { ios::sync_with_stdio(false); cin.tie(0); int mod; cin >> mod; mint::set_mod(mod); mint g[28][2]; rep(i, 28) { int x; cin >> x; g[i][1] = x; } rep(i, 28) { int x; cin >> x; g[i][0] = x; } vector<int> d[15]; rep(s, 1 << 14) { mint v; rep(i, 14) v += g[i + 14][s >> i & 1]; d[__builtin_popcount(s)].emplace_back(v.val()); } rep(i, 15) ranges::sort(d[i]); int q; cin >> q; rep(_, q) { int k, x; cin >> k >> x; int ans = 0; rep(s, 1 << 14) { mint v; int rest = k - __builtin_popcount(s); if (rest < 0 || rest >= 15) continue; rep(i, 14) v += g[i][s >> i & 1]; // x <= a+b < m or x+m <= a+b < 2m for (auto [l, r] : {P(x - (int)v.val(), mod - (int)v.val()), P(x + mod - v.val(), 2 * mod - v.val())}) { ans += lower_bound(all(d[rest]), r) - lower_bound(all(d[rest]), l); } } cout << ans << '\n'; } }