QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#394826 | #6523. Escape Plan | Andy_Lin | WA | 583ms | 38540kb | C++14 | 1.3kb | 2024-04-20 20:10:01 | 2024-04-20 20:10:01 |
Judging History
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);
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 6992kb
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: 583ms
memory: 38540kb
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:
5109 1021 3293 5074 3796 3394 2083 6772 3512 2829 3296 2871 2914 4249 2241 3792 2135 2544 3343 1775 12654 5349 2111 2150 8409 15810 3899 2322 1987 1980 3067 2020 1702 -1 2879 6265 2664 2810 2738 3001 402 3769 18118 6874 7879 3823 -1 510 2636 10564 -1 3166 4763 7526 5898 1978 3302 270 5345 1998 3350 ...
result:
wrong answer 4th numbers differ - expected: '4646', found: '5074'