QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671803#8338. Quad Kingdoms Chesshuan_ypCompile Error//C++202.4kb2024-10-24 14:32:002024-10-24 14:32:00

Judging History

你现在查看的是最新测评结果

  • [2024-10-24 14:32:00]
  • 评测
  • [2024-10-24 14:32:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define re int
#define ll unsigned long long
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
    return x*ff;
}
const int mn1=1e9+7;
const int b1=233;
const int B=500;
inline int md1(int x){return x>=mn1?x-mn1:x;}
int g1[100005];
struct H{
    int s,vl1,tp;
};
void cl(const H &x,int y){
    x.s=1;x.vl1=1ll*y*b1%mn1;
    x.tp=y;
}
H add(const H &x,int y){
    H u;u.s=x.s+1;
    u.vl1=md1(1ll*x.vl1*b1%mn1+1ll*y*b1%mn1);
    u.tp=x.tp;return u;
}
H merge(const H &x,const H &y){
    H u;u.s=x.s+y.s;
    u.vl1=md1(1ll*x.vl1*g1[y.s]%mn1+y.vl1);
    u.tp=x.tp;return u;
}
void cle(vector<int> &qwq){
    vector<int> awa;swap(qwq,awa);
}
struct tt{
    int a[100005],n,m;
    H h[100005];
    vector<int>st[10000];
    void build(int i){
        int len=0;cle(st[i]);
        for(re j=(i-1)*B+1;j<=i*B&&j<=n;j++){
            while(len){
                if(a[st[i][len-1]]<a[j])st[i].pop_back(),len--;
                else break;
            }
            if(!len){
                st[i].emplace_back(j);
                len++;
                cl(h[j],a[j]);continue;
            }
            else {
                h[j]=add(h[st[i][len-1]],a[j]);
                len++;st[i].emplace_back(j);
            }
        }
    }
    void init(){
        n=read();
        m=(n-1)/B+1;
        for(re i=1;i<=n;i++)a[i]=read();
        for(re i=1;i<=m;i++)build(i);
    }
    void update(int x,int y){
        int u=(x-1)/B+1;a[x]=y;
        build(u);
    }
    H ask(){
        H qwq=h[n];
        for(re i=m-1;i>0;i--){
            int l=0,r=st[i].size()-1,mid;
            if(a[st[i][0]]<qwq.tp)continue;
            while(l<=r){
                mid=(l+r)>>1;
                if(qwq.tp>a[st[i][mid]])r=mid-1;
                else l=mid+1;
            }
            l--;
            if(l>=0)qwq=merge(h[st[i][l]],qwq);
        }
        return qwq;
    }
}T[2];
int main(){
    g1[0]=1;
    for(re i=1;i<=100000;i++){
        g1[i]=1ll*g1[i-1]*b1%mn1;
    }
    T[0].init();
    T[1].init();
    int m=read(),t,x,y;
    while(m--){
        t=read();x=read();y=read();
        T[t-1].update(x,y);
        H qwq=T[0].ask();H awa=T[1].ask();
        if(qwq.vl1==awa.vl1)puts("YES");
        else puts("NO");
    }
    return 0;
}

Details

answer.code: In function ‘void cl(const H&, int)’:
answer.code:20:8: error: assignment of member ‘H::s’ in read-only object
   20 |     x.s=1;x.vl1=1ll*y*b1%mn1;
      |     ~~~^~
answer.code:20:16: error: assignment of member ‘H::vl1’ in read-only object
   20 |     x.s=1;x.vl1=1ll*y*b1%mn1;
      |           ~~~~~^~~~~~~~~~~~~
answer.code:21:9: error: assignment of member ‘H::tp’ in read-only object
   21 |     x.tp=y;
      |     ~~~~^~