QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#394834 | #6523. Escape Plan | Andy_Lin | WA | 0ms | 8916kb | C++14 | 1.3kb | 2024-04-20 20:18:29 | 2024-04-20 20:18:29 |
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);
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'