効果の件名:
ソリューション:
カードのポイント:
C ++コード:
#include <cstdioを> する#include <アルゴリズム> の#include <CStringの> する#include <設定> の#include <iostreamの> INT N、Q、ANS。 名前空間ODT { 構造体ノード{ int型のL、R。 変更可能なint型のV; インラインブール演算子<(constのノード&RHS)のconst { 戻りL <rhs.l。 } }。 std ::セット<ノード> S; typedefでのstd ::セット<ノード> ::イテレータSIT; {分割(int型POS)をSIT ;それはs.lower_bound((ノード){POS、0、0})= SIT もし(!それ= s.end()&&それ- > L == POS)それを返します。 - それ; const int型L =それ- > L、R =それ- > R、V =それ- > V。 s.erase(IT)、s.insert((ノード){1、POS - 1、V})。 戻りs.insert((ノード){POS、R、V})最初。 } ボイド割り当て(int型のL、R INT、INT V){ SIT R =スプリット(R + 1)、L =スプリット(L)。 (!;それ= R、それはLが= SIT ++それが)のために - =それ- > V×(これ- > R -と- > L + 1)ANS。 s.erase(L、R)、s.insert((ノード){L、R、V})。 ANS + = V×(R - L + 1)。 } } int型のmain(){ のstd :: IOS :: sync_with_stdio(偽)のstd :: cin.tie(0)、STD :: cout.tie(0)。 std :: cinを>> N >> Q; ANS = N。 ODT :: s.insert((ODT ::ノード){1、nは、1})。 (Q - > 0)しながら{ 静的int型のL、R、X。 std :: CIN >> L >> R >> X。 - バツ; ODT ::(L、R、X)を割り当てます。 std :: coutの<< ANS << '\ nの'; } 0を返します。