結果
| 問題 | No.3671 Reusable Lazy Segment Tree |
| コンテスト | |
| ユーザー |
harurun
|
| 提出日時 | 2026-08-05 03:42:46 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 2,121 bytes |
| 記録 | |
| コンパイル時間 | 2,374 ms |
| コンパイル使用メモリ | 355,524 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-09-04 22:02:36 |
| 合計ジャッジ時間 | 11,081 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// Correct but intentionally too slow.
// It copies the whole array for every independent subproblem and processes
// every range element one by one: O(QN + sum(q_i)N) in the worst case.
static int clamp_index(uint32_t value, int n) {
if (value < 1) return 1;
if (value > static_cast<uint32_t>(n)) return n;
return static_cast<int>(value);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
constexpr uint32_t MASK = (uint32_t(1) << 30) - 1;
int N, M;
cin >> N >> M;
vector<uint32_t> initial(N + 1);
for (int i = 1; i <= N; ++i) cin >> initial[i];
vector<uint32_t> l(M + 1), r(M + 1), x(M + 1), L(M + 1), R(M + 1);
for (int i = 1; i <= M; ++i) cin >> l[i];
for (int i = 1; i <= M; ++i) cin >> r[i];
for (int i = 1; i <= M; ++i) cin >> x[i];
for (int i = 1; i <= M; ++i) cin >> L[i];
for (int i = 1; i <= M; ++i) cin >> R[i];
int Q;
cin >> Q;
for (int i = 1; i <= Q; ++i) {
int s, q;
cin >> s >> q;
// This O(N) copy alone makes the maximum tests infeasible.
vector<uint32_t> a = initial;
uint32_t y = static_cast<uint32_t>(i);
for (int j = 1; j <= q; ++j) {
const int z = ((s + j) % M) + 1;
const int u = clamp_index(l[z] ^ y, N);
const int v = clamp_index(r[z] ^ y, N);
const int ql = min(u, v);
const int qr = max(u, v);
const int U = clamp_index(L[z] ^ y, N);
const int V = clamp_index(R[z] ^ y, N);
const int sum_l = min(U, V);
const int sum_r = max(U, V);
const uint32_t update_mask = x[z] ^ y;
if ((z & 1) == 0) {
for (int k = ql; k <= qr; ++k) a[k] |= update_mask;
} else {
for (int k = ql; k <= qr; ++k) a[k] &= update_mask;
}
uint64_t sum = 0;
for (int k = sum_l; k <= sum_r; ++k) sum += a[k];
y = static_cast<uint32_t>(sum) & MASK;
}
cout << y << '\n';
}
return 0;
}
harurun