結果
| 問題 | No.3507 RangeSum RangeUpdate RangeSqrt |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2026-04-18 22:01:52 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,486 bytes |
| 記録 | |
| コンパイル時間 | 3,478 ms |
| コンパイル使用メモリ | 281,400 KB |
| 実行使用メモリ | 16,640 KB |
| 最終ジャッジ日時 | 2026-04-18 22:02:04 |
| 合計ジャッジ時間 | 8,182 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 28 |
ソースコード
/**
author: shobonvip
created: 2026.04.18 21:48:24
**/
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
#define all(v) v.begin(), v.end()
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
struct S {
ll sum, len, mx, mn;
};
S op(S a, S b) {
return S{a.sum + b.sum, a.len + b.len, max(a.mx, b.mx), min(a.mn, b.mn)};
}
S e() {
return S{0, 0, 0, ll(1e18)};
}
const ll INF = 1e17;
S mapping(ll f, S x) {
if (f == INF) {
return x;
}
return S{x.len * f, x.len, (x.len == 0LL ? 0LL : f), (x.len == 0LL ? ll(1e18) : f)};
}
ll composition(ll g, ll f) {
if (g == INF) return f;
return g;
}
ll id() {
return INF;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
cin >> n >> q;
vector<ll> a(n);
rep(i,0,n) {
cin >> a[i];
}
auto f = [&](S x) -> bool {
return x.mx <= 1;
};
ll gt;
auto g = [&](S x) -> bool {
return x.mn >= gt;
};
lazy_segtree<S,op,e,ll,mapping,composition,id> seg(
[&]() {
vector<S> init(n);
rep(i,0,n) {
init[i] = S {
a[i], 1LL, a[i], a[i]
};
}
return init;
}()
);
while (q--) {
int t; cin >> t;
int l, r; cin >> l >> r;
if (t == 0) {
cout << seg.prod(l, r).sum << '\n';
} else if (t == 1) {
ll x; cin >> x;
seg.apply(l, r, x);
} else {
while (l < r) {
int tar = seg.max_right(l, f);
chmin(tar, r);
l = tar;
if (l == r) break;
gt = seg.get(l).sum;
int nl = seg.max_right(l, g);
chmin(nl, r);
ll tb = ll(sqrtl(gt));
seg.apply(l, nl, tb);
l = nl;
continue;
}
}
}
}
shobonvip