1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| #include <cstdio> #include <cctype> #include <climits> #include <algorithm> using namespace std; using LL = long long; const int Mn(500500); const LL MP(998244353); template<typename T> void qrd(T& x) { x = 0; int c = getchar(); while(!isdigit(c)) { c = getchar(); } while(isdigit(c)) { x = x*10 + c - '0'; c = getchar(); } } template<typename T, typename... Ts> void qrd(T& x,Ts&... xs) { qrd(x); qrd(xs...); }
int n,m; LL arr[Mn]; struct Td { LL mn, mx, ssm; } t[Mn<<2]; inline void mtn(int p) { t[p] = { min(t[p<<1].mn, t[p<<1|1].mn), max(t[p<<1].mx, t[p<<1|1].mx), (t[p<<1].ssm + t[p<<1|1].ssm)%MP }; } void bud(int p=1, int l=1, int r=n) { if(l==r) { t[p] = {arr[l],arr[l],arr[l]*arr[l]%MP}; return; } int mid((l+r)/2); bud(p<<1,l,mid); bud(p<<1|1,mid+1,r); mtn(p); } void mdf(int mp,LL mx,int p=1,int l=1,int r=n) { if(l==r) { t[p] = {mx,mx,mx*mx%MP}; return; } int mid((l+r)/2); if(mp<=mid) { mdf(mp,mx,p<<1,l,mid); } else { mdf(mp,mx,p<<1|1,mid+1,r); } mtn(p); } Td qry(int ql,int qr,int p=1,int l=1,int r=n) { if(l>=ql && r<=qr) { return t[p]; } Td lret = {INT_MAX,INT_MIN,0}, rret = {INT_MAX,INT_MIN,0}; int mid((l+r)/2); if(ql<=mid) { lret = qry(ql,qr,p<<1,l,mid); } if(qr>mid) { rret = qry(ql,qr,p<<1|1,mid+1,r); } return { min(lret.mn, rret.mn), max(lret.mx, rret.mx), (lret.ssm + rret.ssm) % MP }; } inline LL calc(LL x) { const static LL INV_6(166374059); return x*(x+1)%MP*(2ll*x+1)%MP*INV_6%MP; }
int main() { qrd(n,m); for(int i(1);i<=n;++i) { qrd(arr[i]); } bud(); while(m--) { int o, x, y; qrd(o,x,y); if(o==1) { mdf(x,y); } else { Td tdp = qry(x,y); LL sm = (calc(tdp.mx) - calc(tdp.mn-1) + MP) % MP; printf("%s\n",(tdp.ssm==sm && tdp.mx-tdp.mn==y-x)?"damushen":"yuanxing"); } } return 0; }
|