結果
| 問題 | No.2206 Popcount Sum 2 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-05-14 17:13:30 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,895 bytes |
| 記録 | |
| コンパイル時間 | 1,420 ms |
| コンパイル使用メモリ | 188,788 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-05-14 17:14:03 |
| 合計ジャッジ時間 | 8,741 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 TLE * 1 -- * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, k) for (register int i = j; i <= k; ++i)
#define per(i, j, k) for (register int i = j; i >= k; --i)
#define sz(x) (int)x.size()
const long long mod = 998244353;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using pii = pair<int, int>;
using pll = pair<i64, i64>;
const int N = 2e5 + 10;
int fac[N], ifac[N], sc[N];
int qpow(int a, int b, int res = 1) {
for (; b > 0; b >>= 1, a = (i64)a * a % mod) if (b & 1) res = (i64)res * a % mod;
return res;
}
void init(int n = 2e5) {
fac[0] = ifac[0] = sc[0] = 1;
rep (i, 1, n) {
fac[i] = (i64)fac[i - 1] * i % mod, sc[i] = ((i64)sc[i - 1] * 2 + 1) % mod;
}
ifac[n] = qpow(fac[n], mod - 2);
per (i, n - 1, 1) {
ifac[i] = (i64)ifac[i + 1] * (i + 1) % mod;
}
}
int comb(int n, int k) {
if (k > n || n < 0 || k < 0) return 0;
return (i64)fac[n] * ifac[k] % mod * ifac[n - k] % mod;
}
array<int, 3> s[N];
int ans[N];
int B;
bool cmp(array<int, 3> x, array<int, 3> y) {
if (x[0] / B != y[0] / B) return x[0] / B < y[0] / B;
return x[1] < y[1];
}
int norm(i64 p) {
p = (p % mod + mod) % mod;
return p;
}
signed main(int argc, char* argv[]) {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
init();
int q; scanf("%d", &q);
B = sqrt(q);
rep (i, 1, q) {
int x, y; scanf("%d %d", &x, &y);
s[i] = {y - 1, x - 1, i};
}
sort(s + 1, s + q + 1);
int inv = qpow(2, mod - 2);
for (int i = 1, l = 0, r = 1, res = 1; i <= q; ++i) {
int x = s[i][0], y = s[i][1];
// cout << x << ' ' << y << '\n';
while (l > x) res = norm((i64)res - comb(r, l)), l--;
while (l < x) l++, res = norm((i64)res + comb(r, l));
while (r > y) r--, res = (i64)(res + comb(r, l)) % mod * inv % mod;
while (r < y) res = norm((i64)res * 2 - comb(r, l)), r++;
ans[s[i][2]] = (i64)res * sc[y] % mod;
}
rep (i, 1, q) printf("%d\n", ans[i]);
}
vjudge1