結果

問題 No.1234 典型RMQ
ユーザー chocopuuchocopuu
提出日時 2020-09-19 09:49:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,809 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 208,872 KB
実行使用メモリ 10,800 KB
最終ジャッジ日時 2023-09-27 06:52:44
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 78 ms
10,608 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
		}
	}
}
0