QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#680435#9431. The Quest for El DoradojimmyywangWA 160ms52440kbC++143.6kb2024-10-26 21:03:092024-10-26 21:03:11

Judging History

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

  • [2024-10-26 21:03:11]
  • 评测
  • 测评结果:WA
  • 用时:160ms
  • 内存:52440kb
  • [2024-10-26 21:03:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,b) for(int i=a;i<=b;i++)
ll rd(){
	ll x=0,f=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')f=-1;
		c=getchar();
	}while(isdigit(c)){
		x=x*10+c-'0';
		c=getchar();
	}return x*f;
}
#define d rd()
ll T,n,m,k;
struct edge{
    ll u,v,w,c,nx;
}e[1000010];
ll hd[500010],cnt;
void add(ll u,ll v,ll w,ll c){
    e[++cnt]={u,v,w,c,hd[u]};hd[u]=cnt;
}struct val{
    ll r,w;
};
bool operator < (val a,val b){
    if(a.r!=b.r)return a.r<b.r;
    return a.w<b.w;
}
struct node{ll u;val w;};
bool operator <(node a,node b){return b.w<a.w;}
priority_queue<node>q;
val dis[500010];
ll nx[500010];
ll pos[500010];
ll a[500010],b[500010];
ll rt[500010],cur;
ll t[500010*40];
ll ls[500010*40];
ll rs[500010*40];
const ll lim=1000000000;
void go(ll l,ll r,ll &p,ll rt0,ll num,ll id){
    if(!p)p=++cur;t[p]=id;
    if(l==r)return;
    ll mid=l+r>>1;
    // cout<<l<<" "<<r<<" "<<num<<" "<<id<<endl;
    if(mid>=num){
        rs[p]=rs[rt0];
        go(l,mid,ls[p],ls[rt0],num,id);
    }else{
        ls[p]=ls[rt0];
        go(mid+1,r,rs[p],rs[rt0],num,id);
    }
}
ll get(ll l,ll r,ll p,ll num){
    if(!p)return n+1;
    if(num<=l)return t[p];
    ll mid=l+r>>1,res=n+1;
    if(mid>=num)res=min(res,get(l,mid,ls[p],num));
    if(mid<lim)res=min(res,get(mid+1,r,rs[p],num));
    return res;
}
bool vis[500010];
set<ll>st[500010];
int main(){
    T=d;while(T--){
        n=d,m=d,k=d;
        cnt=0;f(i,1,n)hd[i]=nx[i]=0,vis[i]=0;
        f(i,1,m)pos[i]=0,st[i].clear();
        f(i,1,m){
            ll u=d,v=d,c=d,w=d;
            add(u,v,w,c),add(v,u,w,c);
        }f(i,1,k)a[i]=d,b[i]=d,st[a[i]].insert(i);
        for(int i=k;i>=1;i--){
            nx[i]=pos[a[i]];
            pos[a[i]]=i;
        }
        rt[n+1]=++cur;
        for(int i=k;i>=1;i--){
            if(!nx[i])go(1,lim,rt[i],rt[n+1],b[i],i);
            else go(1,lim,rt[i],rt[nx[i]],b[i],i);
        }
        while(!q.empty())q.pop();
        f(i,1,n)dis[i]={k+1,114514};
        dis[1]={0,0};q.push({1,dis[1]});
        while(!q.empty()){
            ll u=q.top().u;q.pop();
            if(vis[u])continue;vis[u]=1;
            for(int i=hd[u];i;i=e[i].nx){
                ll v=e[i].v,w=e[i].w,c=e[i].c;
                ll t=dis[u].r,id,nw;
                if(t==0){t=pos[c];if(!t)continue;}
                if(a[t]==c&&dis[u].w+w<=b[t]){id=t,nw=w+dis[u].w;}
                else{
                    auto qwq=st[c].upper_bound(t);
                    if(qwq==st[c].end())continue;t=*qwq;
                    // if(u==2&&v==3)cout<<"ooo   "<<t<<" "<<w<<endl;
                    id=get(1,lim,rt[t],w);if(id>n)continue;
                    nw=w;
                    // id=-1;
                    // f(j,t+1,k){
                    //     if(a[j]==c&&b[j]>=w){id=j,nw=w;break;}
                    // }if(id==-1)continue;
                }//cout<<id<<" "<<nw<<endl;
                if((val){id,nw}<dis[v]){
                    dis[v]={id,nw};
                    q.push({v,dis[v]});
                }
            }
        }
        // f(i,1,n)cout<<dis[i].r<<" "<<dis[i].w<<endl;
        f(i,1,n)cout<<vis[i];cout<<endl;
        f(i,1,cnt)e[i]={0,0,0,0,0};
        f(i,1,cur)t[i]=ls[i]=rs[i]=0;cur=0;
        f(i,1,n+1)rt[i]=0;
    }
	return 0;
}
/*
2
5 6 4
1 2 1 30
2 3 1 50
2 5 5 50
3 4 6 10
2 4 5 30
2 5 1 40
1 70
6 100
5 40
1 300
5 6 4
1 2 1 30
2 3 1 50
2 5 5 50
3 4 6 10
2 4 5 30
2 5 1 40
1 70
6 100
5 40
1 30


1        
5 3 2   
1 3 1 99
1 4 1 1000
3 4 1 9  
1 101
1 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 44780kb

input:

2
5 6 4
1 2 1 30
2 3 1 50
2 5 5 50
3 4 6 10
2 4 5 30
2 5 1 40
1 70
6 100
5 40
1 30
3 1 1
2 3 1 10
1 100

output:

11011
100

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 160ms
memory: 52440kb

input:

1110
46 80 30
44 23 5 46
10 28 1 64
32 34 3 40
9 36 1 26
15 14 5 95
38 19 2 34
2 17 4 183
10 38 2 81
5 15 2 83
31 38 3 100
40 30 1 53
41 10 1 193
29 20 5 18
14 41 3 78
8 16 5 74
46 13 3 78
44 28 3 45
1 40 3 133
5 32 1 108
22 26 2 83
10 38 1 77
11 40 1 11
17 21 2 66
41 46 3 98
9 36 2 25
40 18 1 19
27...

output:

1000110011110111110010100001010100100101000000
1100010010101011011011000000011000001100001000
1000000000000000000000000000000000000000000000
1011000000000000000100010011000100000000000010
1000000000000000000000000000000000000000000000
1001100010110000100001100000000011001110110
101010000000000000010...

result:

wrong answer 2nd lines differ - expected: '1100010010111011011011000000011000001100001000', found: '1100010010101011011011000000011000001100001000'