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
| #include <bits/stdc++.h> using namespace std; #define N 1000005 #define INF 0x3f3f3f3f int t[N<<2],lazy[N<<2],pl[N<<2],pr[N<<2]; void pushup(int k){ t[k]=t[k<<1]+t[k<<1|1];pl[k]=pl[k<<1];pr[k]=pr[k<<1|1]; } void build(int k,int l,int r){ if(l==r)t[k]=0,pl[k]=l,pr[k]=r; else{ int m=l+((r-l)>>1); build(k<<1,l,m); build(k<<1|1,m+1,r); pushup(k); } } void pushdown(int k){ if(lazy[k]){ lazy[k<<1]+=lazy[k]; lazy[k<<1|1]+=lazy[k]; t[k<<1]+=lazy[k]*(pr[k<<1]-pl[k<<1]+1); t[k<<1|1]+=lazy[k]*(pr[k<<1|1]-pl[k<<1|1]+1); lazy[k]=0; } } int query(int L,int R,int l,int r,int k){ if(L<=l&&r<=R)return t[k]; else{ pushdown(k); int res=0; int m=l+((r-l)>>1); if(L<=m)res+=query(L,R,l,m,k<<1); if(R>=m+1)res+=query(L,R,m+1,r,k<<1|1); return res; } } void updateqj(int L,int R,int v,int l,int r,int k){ if(L<=l&&r<=R){ lazy[k]+=v; t[k]+=v*(pr[k]-pl[k]+1); } else{ pushdown(k); int m=l+((r-l)>>1); if(L<=m)updateqj(L,R,v,l,m,k<<1); if(R>=m+1)updateqj(L,R,v,m+1,r,k<<1|1); pushup(k); } } void solve(void) { int n,q;cin>>n>>q; int a1,a2,a3,a4;cin>>a1>>a2>>a3>>a4; string ch;cin>>ch; build(1,1,n); for(int i=1;i<=q;i++){ int op,l,r;cin>>op>>l>>r; if(op==1){ updateqj(l,r,1,1,n,1); }else{ int x=query(r,r,1,n,1); if((x&1)){ if(ch[r-1]=='1'){ cout<<"HoloPsychon"<<"\n"; } else cout<<"Magical Splash Flare"<<"\n"; } else{ if(ch[r-1]=='1'){ cout<<"Magical Splash Flare"<<"\n"; }else cout<<"HoloPsychon"<<"\n"; } } } } int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); return 0; }
|