QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394834#6523. Escape PlanAndy_LinWA 0ms8916kbC++141.3kb2024-04-20 20:18:292024-04-20 20:18:29

Judging History

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

  • [2024-04-20 20:18:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:8916kb
  • [2024-04-20 20:18:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 100001
#define M 1000001
int T,n,m,k,last[N],tot,dis[N],val[N];
bool flag[N];
struct EDGE{
  int to,pre,w;
}e[M<<1];
void add(int x,int y,int z){
  e[++tot].to=y;e[tot].pre=last[x];last[x]=tot;e[tot].w=z;
}
priority_queue<pair<int,int> >q;
priority_queue<int>heap[N];
int main(){
  scanf("%d",&T);
  while(T--){
    scanf("%d%d%d",&n,&m,&k);
    printf("%d %d %d\n",n,m,k);
    for(int i=1;i<=n;++i)last[i]=0,flag[i]=0;tot=0;
    for(int i=1;i<=n;++i)while(!heap[i].empty())heap[i].pop();
    while(k--){
      int x;scanf("%d",&x);
      dis[x]=0;q.push({0,x});heap[x].push(0);
    }
    for(int i=1;i<=n;++i)scanf("%d",val+i),++val[i];
    while(m--){
      int x,y,z;scanf("%d%d%d",&x,&y,&z);
      add(x,y,z);add(y,x,z);
    }
    while(!q.empty()){
      int x=q.top().second;dis[x]=heap[x].top();q.pop();
      if(flag[x])continue;
      flag[x]=1;
      for(int i=last[x];i;i=e[i].pre){
        int y=e[i].to;if(flag[y])continue;
        heap[y].push(dis[x]+e[i].w);
        if(heap[y].size()>val[y])heap[y].pop();
        if(heap[y].size()==val[y]){
          q.push({-heap[y].top(),y});
        }
      }
    }
    if(heap[1].size()!=val[1]){
      puts("-1");
    }
    else printf("%d\n",dis[1]);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 8916kb

input:

2
3 4 1
3
1 1 1
1 2 1
1 2 2
2 3 1
2 3 2
3 2 2
2 3
2 0 0
1 2 1
1 3 1

output:

3 4 1
4
3 2 2
-1

result:

wrong answer 1st numbers differ - expected: '4', found: '3'