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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| #include<iostream> #include<cstdio> #include<algorithm> #define ll __int128 using namespace std;
const ll N=5e5;
ll n,m,op,x,y;
ll a[N+5];
struct sgt{ ll l,r,hash1,hash2,hash3,ma,mi; #define l(x) tree[x].l #define r(x) tree[x].r #define hash1(x) tree[x].hash1 #define hash2(x) tree[x].hash2 #define ma(x) tree[x].ma #define mi(x) tree[x].mi }tree[N*4+5];
void build(ll p,ll l,ll r) { l(p)=l;r(p)=r; if(l==r) { ma(p)=a[l];mi(p)=a[l]; hash1(p)=a[l];hash2(p)=a[l]*a[l]; return; } ll mid=(l+r)>>1; build(p<<1,l,mid);build(p<<1|1,mid+1,r); ma(p)=max(ma(p<<1),ma(p<<1|1)); mi(p)=min(mi(p<<1),mi(p<<1|1)); hash1(p)=hash1(p<<1)+hash1(p<<1|1); hash2(p)=hash2(p<<1)+hash2(p<<1|1); }
void modify(ll p,ll x,ll y) { if(l(p)==r(p)) { ma(p)=y;mi(p)=y; hash1(p)=y;hash2(p)=y*y; return; } ll mid=(l(p)+r(p))>>1; if(x<=mid) modify(p<<1,x,y); if(x>mid) modify(p<<1|1,x,y); ma(p)=max(ma(p<<1),ma(p<<1|1)); mi(p)=min(mi(p<<1),mi(p<<1|1)); hash1(p)=hash1(p<<1)+hash1(p<<1|1); hash2(p)=hash2(p<<1)+hash2(p<<1|1); }
ll ask1(ll p,ll l,ll r) { if(l(p)>=l&&r(p)<=r) { return hash1(p); } ll mid=(l(p)+r(p))>>1; if(l>mid) return ask1(p<<1|1,l,r); if(r<=mid) return ask1(p<<1,l,r); return ask1(p<<1,l,r)+ask1(p<<1|1,l,r); }
ll ask2(ll p,ll l,ll r) { if(l(p)>=l&&r(p)<=r) { return hash2(p); } ll mid=(l(p)+r(p))>>1; if(l>mid) return ask2(p<<1|1,l,r); if(r<=mid) return ask2(p<<1,l,r); return ask2(p<<1,l,r)+ask2(p<<1|1,l,r); }
ll getmax(ll p,ll l,ll r) { if(l(p)>=l&&r(p)<=r) { return ma(p); } ll mid=(l(p)+r(p))>>1; if(l>mid) return getmax(p<<1|1,l,r); if(r<=mid) return getmax(p<<1,l,r); return max(getmax(p<<1,l,r),getmax(p<<1|1,l,r)); }
ll getmin(ll p,ll l,ll r) { if(l(p)>=l&&r(p)<=r) { return mi(p); } ll mid=(l(p)+r(p))>>1; if(l>mid) return getmin(p<<1|1,l,r); if(r<=mid) return getmin(p<<1,l,r); return min(getmin(p<<1,l,r),getmin(p<<1|1,l,r)); }
ll sum(ll l,ll r) { return (l+r)*(r-l+1)/2; }
ll sqsum(ll x) { return x*(x+1)*(2*x+1)/6; }
inline ll read() { ll ret=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9') {if(ch=='-') f=-f;ch=getchar();} while(ch>='0'&&ch<='9') {ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();} return ret*f; }
void write(ll x) { static char buf[22];static ll len=-1; if(x>=0) { do{buf[++len]=x%10+48;x/=10;}while(x); } else { do{buf[++len]=-(x%10)+48;x/=10;}while(x); } while(len>=0) putchar(buf[len--]); }
int main() {
n=read();m=read();
for(ll i=1;i<=n;i++) { a[i]=read(); }
build(1,1,n);
while(m--) { op=read();x=read();y=read(); if(op==1) { modify(1,x,y); } if(op==2) { ll maxx=getmax(1,x,y),minn=getmin(1,x,y); if(maxx-minn+1!=y-x+1) { printf("yuanxing\n"); } else { ll key1=ask1(1,x,y),key2=ask2(1,x,y); ll tmp1=sum(minn,maxx),tmp2=sqsum(maxx)-sqsum(minn-1); if(tmp1==key1&&tmp2==key2) { printf("damushen\n"); } else printf("yuanxing\n"); } } }
return 0; }
|