結果
| 問題 |
No.1234 典型RMQ
|
| コンテスト | |
| ユーザー |
chocopuu
|
| 提出日時 | 2020-09-19 09:49:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,809 bytes |
| コンパイル時間 | 2,318 ms |
| コンパイル使用メモリ | 204,464 KB |
| 最終ジャッジ日時 | 2025-01-14 18:39:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 22 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/lazysegtree"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;
// モノイドの型S
struct S {
int a, size;
};
// S × S -> S を計算する関数
S op(S l, S r) {
return S{min(l.a, r.a), l.size + r.size};
}
// e を返す関数
S e() {
return S{INF, 0};
}
// 写像の型
struct F{
int a;
};
// f(x) を返す関数
S mapping(F l, S r) {
return S{r.a + r.size * l.a, r.size};
}
// f ○ g を返す関数(f(g(x)))
F composition(F l, F r) {
return F{l.a + r.a};
}
// 恒等写像 id(x) = x
F id() {
return F{0};
}
// lazy_segtree<S, op, e, F, mapping, composition, id> seg();
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
signed main(){
IOS();
int N;
cin >> N;
vector<int>a(N);
cin >> a;
int Q;
cin >> Q;
lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
REP(i, N) {
seg.set(i, S{a[i], 1});
}
REP(_, Q) {
int k, l, r, c;
cin >> k >> l >> r >> c;
--l;
if(k == 1) {
seg.apply(l, r, F{c});
} else {
out(seg.prod(l, r).a);
}
}
}
chocopuu