結果
| 問題 | No.3507 RangeSum RangeUpdate RangeSqrt |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-18 14:01:29 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,240 bytes |
| 記録 | |
| コンパイル時間 | 4,416 ms |
| コンパイル使用メモリ | 384,540 KB |
| 実行使用メモリ | 34,796 KB |
| 最終ジャッジ日時 | 2026-04-18 14:01:51 |
| 合計ジャッジ時間 | 18,679 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 WA * 17 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define all(x) begin(x), end(x)
template <class T> bool chmin(T& x, T y) {
return x > y ? (x = y, true) : false;
}
template <class T> bool chmax(T& x, T y) {
return x < y ? (x = y, true) : false;
}
using mint = atcoder::modint998244353;
ll ipow(ll x, int a) {
ll res = 1;
while (a) {
if (a & 1) res *= x;
x *= x;
a >>= 1;
}
return res;
}
ll isqrt(ll n) {
if (n <= 0) return 0;
ll x = sqrt(n);
if (x * x > n) x--;
return x;
}
// template atcoder lazy segtree
struct S {
ll sm, sz;
array<ll, 6> d;
};
S op(S a, S b) {
a.sm += b.sm;
a.sz += a.sz;
rep(i, 0, 6) a.d[i] += b.d[i];
return a;
}
S e() {
return {0, 0, {}};
}
struct F {
ll a, c;
array<ll, 6> d;
};
S mapping(F f, S x) {
if (f.c > 0) {
int ln = min(6ll, f.c);
rep(i, 0, ln) {
x.sm -= x.d[i];
x.d[i] = 0;
}
rep(i, ln, 6) {
x.d[i - ln] = x.d[i];
x.d[i] = 0;
}
return x;
}
if (f.a >= 0) {
x.sm = x.sz * f.a;
rep(i, 0, 6) x.d[i] = f.d[i] * x.sz;
}
return x;
}
F comp(F f, F g) {
if (f.a >= 0) return f;
if (f.c > 0) {
g.c += f.c;
}
if (g.a >= 0 && g.c > 0) {
int ln = min(6ll, g.c);
rep(i, 0, ln) {
g.a -= g.d[i];
g.d[i] = 0;
}
rep(i, ln, 6) {
g.d[i - ln] = g.d[i];
g.d[i] = 0;
}
g.c = 0;
}
return g;
}
F id() {
return {-1, 0, {}};
}
using segtree = atcoder::lazy_segtree<S, op, e, F, mapping, comp, id>;
array<ll, 6> build_deq(ll x) {
array<ll, 6> res;
rep(i, 0, 6) {
ll y = isqrt(x);
if (x == y) break;
res[i] = x - y;
x = y;
}
return res;
}
void solve() {
int n, q;
cin >> n >> q;
vector<int> a(n);
rep(i, 0, n) cin >> a[i];
segtree seg;
{
vector<S> tmp(n);
rep(i, 0, n) tmp[i] = S{a[i], 1, build_deq(a[i])};
seg = segtree{tmp};
}
while (q--) {
int t, l, r;
cin >> t >> l >> r;
if (t == 0) cout << seg.prod(l, r).sm << '\n';
if (t == 1) {
int x;
cin >> x;
seg.apply(l, r, F{x, 0, build_deq(x)});
}
if (t == 2) seg.apply(l, r, F{-1, 1, {}});
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int t = 1;
// cin >> t;
while (t--) solve();
}