QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207857#6400. Game: Celesteucup-team870Compile Error//Python32.7kb2023-10-08 21:33:302023-10-08 21:33:30

Judging History

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

  • [2023-10-08 21:33:30]
  • 评测
  • [2023-10-08 21:33:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
#define P pair<int,int>
#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define mi int mid=(l+r)/2;
const int N=1e6+6,M=25,inf=1e9+7;
int ls[N*M],rs[N*M],num[N*M],cnt,rt[N];
ull w[N*M],pw[N];
int a[N],q[N*2],x[N];
int res[N],top;
void dfs(int rt,int l,int r){
    if(!rt)return;
    // cout<<l<<' '<<r<<' '<<num[rt]<<"-------------------\n";
    if(l==r){
        rep(_,1,num[rt])res[++top]=l; return;
    }
    mi
    dfs(rs[rt],mid+1,r); dfs(ls[rt],l,mid);
}
int crt(int rt,int l,int r,int x){
    int now=++cnt;
    // cout<<l<<' '<<r<<' '<<num[rt]<<"#########\n"
    if(l==r){
        // cout<<l<<' '<<r<<"######\n";
        num[now]=num[rt]+1; w[now]=w[rt]*pw[1]+x;
        return now;
    }
    mi
    if(mid>=x)ls[now]=crt(ls[rt],l,mid,x),rs[now]=rs[rt];
    else rs[now]=crt(rs[rt],mid+1,r,x),ls[now]=ls[rt];
    num[now]=num[ls[now]]+num[rs[now]];
    w[now]=w[ls[now]]+w[rs[now]]*pw[num[ls[now]]];
    // cout<<l<<' '<<r<<" "<<num[now]<<"#########################\n";
    return now;
}
bool qu(int rt1,int rt2,int l,int r){
    if(l==r)return num[l]<=num[r];
    mi
    if(w[rs[rt1]]!=w[rs[rt2]])return qu(rs[rt1],rs[rt2],mid+1,r);
    return qu(ls[rt1],ls[rt2],l,mid);
}
void slv(){
    rep(i,0,cnt){
        ls[i]=rs[i]=num[i]=w[i]=0;
    }
    cnt=0;
    int n,L,R; cin>>n>>L>>R;
    pw[0]=1;
    rep(i,1,n)pw[i]=inf*pw[i-1];
    rep(i,1,n)cin>>x[i];
    rep(i,1,n)cin>>a[i];
    int l=1,r=0;
    rt[1]=crt(0,1,n,a[1]);
    q[++r]=1; int wzh=1;
    auto cmp=[&](int i,int j){
        // cout<<i<<' '<<j<<"hhh\n";
        return qu(rt[i],rt[j],1,n);
    };
    rep(i,2,n){
        if(x[1]>x[i]-L){
            rt[i]=-1; continue;
        }
        while(l<=r && x[q[l]]<x[i]-R)++l;
        while(x[wzh+1]<=x[i]-L){
            ++wzh;
            if(rt[wzh]==-1)continue;
            while(r>=l && cmp(q[r],wzh))--r;
            q[++r]=wzh;
        }
        // cout<<l<<' '<<r<<":";
        // rep(i,l,r)cout<<q[i]<<" "; cout<<'\n';
        if(l>r)rt[i]=-1;
        else {
            // cout<<i<<' '<<q[l]<<"????????????\n";
            rt[i]=crt(rt[q[l]],1,n,a[i]);
        }
        // top=0; dfs(rt[i],1,n);
        // rep(i,1,top)cout<<res[i]<<' '; cout<<'\n';
    }
    if(rt[n]==-1){
        cout<<"-1\n";return;
    }
    top=0; dfs(rt[n],1,n);
    cout<<top<<'\n'; //忘了...
    rep(i,1,top)cout<<res[i]<<' '; cout<<'\n';
}
signed main(){
    IOS
    int T;cin>>T;
    while(T--)slv();
}
/*
1
5 2 3
1 2 3 4 5
5 2 3 1 4
*/

Details

  File "answer.code", line 2
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax