QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617426#9427. Collect the Coinszzpcd#WA 3ms13920kbC++202.9kb2024-10-06 15:30:392024-10-06 15:30:40

Judging History

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

  • [2024-11-06 15:56:27]
  • hack成功,自动添加数据
  • (/hack/1139)
  • [2024-10-06 15:30:40]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:13920kb
  • [2024-10-06 15:30:39]
  • 提交

answer

#include<bits/stdc++.h>
#define N 500010
using namespace std;
int n,vis[N],m,K;
struct edge
{
    int v,pre,c,l;
}e[N<<1];
int fir[N],tot=1;
void adde(int u,int v,int c,int l)
{
    e[++tot]={v,fir[u],c,l};fir[u]=tot;
    e[++tot]={u,fir[v],c,l};fir[v]=tot;
    return ;
}
struct node
{
    int now;
    long long dis;
    int id;
    friend bool operator <(const node &i,const node &j)
    {
        if(i.now==j.now)
        {
            return i.dis>j.dis;
        }
        else 
        {
            return i.now>j.now;
        }
    }
}dat[N];
priority_queue<node> q;
struct opt
{
    int a,b;
}op[N];
vector<pair<int,int>> vec[N];
int getpos(int c,int ll,int val)
{
    int l=0,r=vec[c].size()-1;
    while(l<r)
    {
        int mid=l+r>>1;
        auto [p,siz] = vec[c][mid];
        if(p>ll&&siz>=val) r=mid;
        else l=mid+1;
    }
    if(vec[c][r].first>ll&&vec[c][r].second>=val) return vec[c][r].first;
    else return K+1;
}
void dij()
{

    while(!q.empty()) q.pop();
    q.push({1,0ll,1});
    fill(vis,vis+n+5,0);
    while(!q.empty())
    {
        auto [now,dis,u] = q.top();
        q.pop();
        if(vis[u]) continue;
        vis[u]=true;
        for(int i=fir[u];i;i=e[i].pre)
        {
            int v=e[i].v;
            if(e[i].c==op[now].a)
            {
                if(dis+e[i].l<=op[now].b)
                {
                    node tmp={now,dis+e[i].l,v};
                    if(dat[v]<tmp)
                    {
                        dat[v]=tmp;
                        q.push(dat[v]);
                    }
                }
                else 
                {
                    int p=getpos(e[i].c,now,e[i].l);
                    if(p==K+1) continue;
                    node tmp={p,e[i].v,v};
                    if(dat[v]<tmp)
                    {
                        dat[v]=tmp;
                        q.push(dat[v]);
                    }
                }
            }
            else 
            {
                int p=getpos(e[i].c,now,e[i].l);
                if(p==K+1) continue;
                node tmp={p,e[i].l,v};
                if(dat[v]<tmp)
                {
                    dat[v]=tmp;
                    q.push(dat[v]);
                }
            }
        }
    }
    return ;
}
void _()
{
    cin>>n>>m>>K;
    tot=1;
    for(int i=1;i<=n;++i) fir[i]=0,dat[i]={(int)2e9,(long long)2e18,i};
    for(int i=1;i<=m;++i)
    {
        int u,v,c,l;
        cin>>u>>v>>c>>l;
        adde(u,v,c,l);
        vec[i].clear();
    }
    for(int i=1;i<=K;++i)
    {
        cin>>op[i].a>>op[i].b;
        vec[op[i].a].push_back({i,op[i].b});
    }
    dij();
    for(int i=1;i<=n;++i) cout<<vis[i];
    cout<<'\n';
    return ;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T;
    cin>>T;
    while(T--) _();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 13920kb

input:

3
5
1 1
3 7
3 4
4 3
5 10
1
10 100
3
10 100
10 1000
10 10000

output:

10000
10000
10000

result:

wrong answer 1st lines differ - expected: '2', found: '10000'