結果
| 問題 | No.2206 Popcount Sum 2 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-05-14 17:01:43 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,082 bytes |
| 記録 | |
| コンパイル時間 | 1,183 ms |
| コンパイル使用メモリ | 189,404 KB |
| 実行使用メモリ | 17,328 KB |
| 最終ジャッジ日時 | 2026-05-14 17:02:25 |
| 合計ジャッジ時間 | 8,913 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 TLE * 1 -- * 13 |
コンパイルメッセージ
main.cpp:49:8: warning: first argument of 'int main(i64, char**)' should be 'int' [-Wmain]
49 | signed main(int argc, char* argv[]) {
| ^~~~
ソースコード
#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>;
#define int i64
mt19937_64 rng((u64)random_device {}() << 32 ^ random_device {}() ^ chrono::high_resolution_clock::now().time_since_epoch().count());
template<class T = i64,class T2>T rnd(T l,T2 r) {
return uniform_int_distribution<T>(l,r)(rng);
}
const int N = 4e5 + 10;
i64 fac[N], ifac[N], sc[N];
i64 qpow(i64 a, int b, i64 res = 1) {
for (; b > 0; b >>= 1, a = a * a % mod) if (b & 1) res = res * a % mod;
return res;
}
void init(int n = 4e5) {
fac[0] = ifac[0] = sc[0] = 1;
rep (i, 1, n) fac[i] = fac[i - 1] * i % mod, ifac[i] = qpow(fac[i], mod - 2), sc[i] = sc[i - 1] + qpow(2, i), sc[i] %= mod;
}
i64 comb(int n, int k) {
if (k > n || n < 0 || k < 0) return 0;
return fac[n] * ifac[k] % mod * ifac[n - k] % mod;
}
array<int, 3> s[N];
int ans[N], col[N];
int n, 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(int p) {
p = (p % mod + mod) % mod;
return p;
}
signed main(int argc, char* argv[]) {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
init();
int q;
cin >> q;
B = sqrt(q);
rep (i, 1, q) {
int x, y;
cin >> 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(res - comb(r, l)), l--;
while (l < x) l++, res = norm(res + comb(r, l));
while (r > y) r--, res = (res + comb(r, l)) % mod * inv % mod;
while (r < y) res = norm(res * 2 - comb(r, l)), r++;
ans[s[i][2]] = res * sc[y] % mod;
}
rep (i, 1, q) cout << ans[i] << '\n';
}
vjudge1