TempestJueMu @ 2022-07-22 14:51:14
rt,TLE on #5,6 可能是我写假了,也可能是被卡掉了
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//By CYJian
namespace io {
const int __SIZE = (1 << 21) + 1;
char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
inline void gc (char &x) { x = Gc(); }
inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';) __c = Gc();
for(; __c > 31 && __c < 127 && __c != ' ' && __c != '\n' && __c != '\r'; ++s, __c = Gc()) *s = __c; *s = 0; }
template <class I> inline bool gi (I &x) { _eof = 0;
for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
while (x) qu[++ qr] = x % 10 + '0', x /= 10; while (qr) pc (qu[qr --]); }
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;
struct node
{
int l,r;
mutable ll v;
node(int L=0,int R=0,ll V=0):l(L),r(R),v(V){}
bool operator <(const node& o)const{return l<o.l;}
};
set<node>s;
#define IT set<node>::iterator
IT split(int pos)
{
IT it=s.lower_bound(node(pos));
if(it!=s.end()&&it->l==pos)return it;
it--;
int L=it->l,R=it->r;ll V=it->v;
s.erase(it);
s.insert(node(L,pos-1,V));
return s.insert(node(pos,R,V)).first;
}
void assign(int l,int r,ll val)
{
IT itr=split(r+1),itl=split(l);
s.erase(itl,itr);
s.insert(node(l,r,val));
}
void add(int l,int r,ll val)
{
IT itr=split(r+1),itl=split(l);
for(;itl!=itr;++itl)itl->v+=val;
}
ll query(int l,int r)
{
IT itr=split(r+1),itl=split(l);
ll ret=-99999999999;
for(;itl!=itr;++itl)ret=max(ret,itl->v);
return ret;
}
#undef IT
int main()
{
int n,q;
gi(n);gi(q);
for(int i=1,a;i<=n;++i)
gi(a),s.insert(node(i,i,a));
for(int i=1,op,l,r,x;i<=q;++i)
{
gi(op);gi(l);gi(r);
if(op==1)gi(x),assign(l,r,x);
if(op==2)gi(x),add(l,r,x);
if(op==3)print(query(l,r)),pc('\n');
}
return 0;
}
by Register_int @ 2022-07-22 14:54:47
@Guolar_JueMu 如果我没记错的话,这题卡了珂朵莉
by TempestJueMu @ 2022-07-22 14:57:24
@Register_int 好吧qaq
by Zvelig1205 @ 2022-07-22 16:09:27
珂朵莉大多数情况下只能应用在随机数据,对于特殊构造过的数据,珂朵莉越长越快,暴力越短越快(指维护区间长度)。
而对这个题来说,60% 的数据