QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#394835#6523. Escape PlanAndy_LinWA 430ms38896kbC++141.3kb2024-04-20 20:18:582024-04-20 20:18:58

Judging History

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

  • [2024-04-20 20:18:58]
  • 评测
  • 测评结果:WA
  • 用时:430ms
  • 内存:38896kb
  • [2024-04-20 20:18:58]
  • 提交

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);
    if(T>10)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: 100
Accepted
time: 2ms
memory: 10628kb

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:

4
-1

result:

ok 2 number(s): "4 -1"

Test #2:

score: -100
Wrong Answer
time: 430ms
memory: 38896kb

input:

100
100 1808 2
94 47
3 3 0 2 4 3 3 4 0 0 2 2 2 3 2 4 0 2 3 4 4 2 0 3 4 3 1 0 2 1 2 2 0 3 4 4 4 1 2 2 3 1 0 0 3 1 4 2 1 3 3 4 3 0 4 1 0 3 2 1 4 4 1 3 2 3 3 3 3 1 0 3 0 4 3 1 0 4 0 4 4 1 2 0 0 4 1 3 3 3 0 2 2 1 1 2 3 4 1 2
72 29 1138
59 78 2398
95 5 1610
32 46 4176
36 99 8143
100 69 413
61 58 1595
9 9...

output:

100 1808 2
5109
100 3355 3
1021
100 2594 3
3293
100 1788 3
5074
100 1874 4
3796
100 2974 3
3394
100 4025 4
2083
100 1466 2
6772
100 3939 3
3512
100 3403 3
2829
100 2724 2
3296
100 4662 2
2871
100 4811 3
2914
100 3208 1
4249
100 3650 2
2241
100 1161 2
3792
100 4624 1
2135
100 4211 3
2544
100 3136 2
3...

result:

wrong answer 1st numbers differ - expected: '5109', found: '100'