QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#207873#6400. Game: Celesteucup-team870WA 295ms22192kbC++203.2kb2023-10-08 21:54:292023-10-08 21:54:29

Judging History

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

  • [2023-10-08 21:54:29]
  • 评测
  • 测评结果:WA
  • 用时:295ms
  • 内存:22192kb
  • [2023-10-08 21:54:29]
  • 提交

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,mod=1e9+9;
int ls[N*M],rs[N*M],num[N*M],cnt,rt[N];
ll w[N*M],pw[N];
int a[N],q[N],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]*inf+x)%mod;
        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]]])%mod;
    // cout<<l<<' '<<r<<" "<<num[now]<<"#########################\n";
    return now;
}
bool qu(int rt1,int rt2,int l,int r){
    // cout<<l<<' '<<r<<'\n';
    if(l==r)return num[rt1]<=num[rt2]; //傻逼成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]%mod; //cout<<pw[i]<<' '; cout<<'\n';
    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)){
                // cout<<q[r]<<' '<<wzh<<"?????????\n";
                --r;
            }
            q[++r]=wzh;
        }
        // cout<<i<<" ## "<<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);
        // cout<<i<<": "; 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();
}
/*
57 8 11
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

1
10 2 4
1 2 3 4 5 6 7 8 9 10
9 10 9 4 7 4 7 9 6 10

1
5 2 3
1 2 3 4 5
5 2 3 1 4
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 20104kb

input:

2
5 2 3
1 2 3 4 5
5 2 3 1 4
3 1 2
1 4 7
3 3 3

output:

3
5 4 3 
-1

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 295ms
memory: 22192kb

input:

10000
57 8 11
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
11 16 7 7 10 13 9 14 10 1 12 4 8 13 3 20 16 7 16 19 20 8 19 7 16 6 17 13 7 19 17 11 12 17 6 3 7 8 14 2 4 15 5 18 16 7 20 9 1...

output:

7
20 20 19 14 12 11 3 
-1
6
6 5 3 2 1 1 
-1
185
20 20 20 20 20 20 20 20 19 19 19 19 19 19 19 19 19 19 19 19 18 18 18 18 18 17 17 17 17 17 17 17 17 16 16 16 16 16 16 16 16 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 14 14 14 14 14 14 14 13 13 13 13 13 13 13 13 13 12 12 12 12 12 12 12 ...

result:

wrong answer 80th lines differ - expected: '20 20 20 20 20 20 20 20 20 20 ...8 8 7 6 6 6 5 5 4 3 3 3 2 1 1 1', found: '20 20 20 20 20 20 20 20 20 20 ... 8 7 7 6 6 6 5 5 4 3 3 2 1 1 1 '