QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#110124 | #6523. Escape Plan | zzzyzzz | WA | 409ms | 36712kb | C++17 | 1.7kb | 2023-05-31 17:10:39 | 2023-05-31 17:10:42 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=1e5+7,M=3e6+7;
typedef long long ll;
typedef pair<int,int> PII;
inline ll read() {
ll c=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9') {
if(ch=='-') f=-f;
ch=getchar();
}
while(ch>='0'&&ch<='9') {
c=c*10+ch-'0';
ch=getchar();
}
return c*f;
}
int n,m,k;
int h[N],e[M],ne[M],w[M],idx;
int cost[N];
bool st[N];
bool temp[N];
int cnt[N];
ll dist[N];
void add(int a,int b,int c) {
e[idx]=b,ne[idx]=h[a],w[idx]=c,h[a]=idx++;
}
void bfs(vector<int> &vis) {
queue<int> q;
for(auto &it:vis) q.push(it);
while(q.size()) {
auto it=q.front();
q.pop();
if(st[it]) continue;
st[it]=true;
priority_queue<PII,vector<PII>,greater<PII> > s;
for(int i=h[it];i!=-1;i=ne[i]) {
int j=e[i];
s.push({w[i],j});
}
while(s.size()) {
auto itt=s.top();
s.pop();
int tp=itt.fi;
int j=itt.se;
if(temp[it]) {
cnt[j]++;
if(cost[j]<cnt[j]) {
temp[j]=true;
dist[j]=min(dist[j],dist[it]+tp);
q.push(j);
}
}
}
}
}
void solve() {
n=read(),m=read(),k=read();
memset(dist,0x3f3f,sizeof(ll)*(n+4));
vector<int> vis;
for(int i=1;i<=k;i++) {
int c=read();
vis.push_back(c);
}
for(int i=1;i<=n;i++) cost[i]=read(),cnt[i]=0,temp[i]=false,st[i]=false;
for(auto &it:vis) temp[it]=true,dist[it]=0;
memset(h,-1,sizeof(int)*(n+4));
idx=0;
while(m--) {
int a=read(),b=read(),c=read();
add(a,b,c),add(b,a,c);
}
bfs(vis);
if(dist[1]==0x3f3f3f3f3f3f3f3f) printf("-1\n");
else printf("%lld\n",dist[1]);
}
int main() {
int T;
T=read();
while(T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 11792kb
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: 409ms
memory: 36712kb
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:
4032 858 871 1391 1628 1707 331 3705 1286 1140 1083 1200 566 1998 741 2893 1175 1138 1353 723 5471 2508 425 1694 3763 6946 930 2322 616 889 1035 490 651 -1 888 6265 813 1583 641 1056 402 3769 12402 4642 4482 2589 -1 510 1095 2654 -1 913 1156 1397 2358 1480 2446 270 1549 1019 1678 954 2012 1997 1087 ...
result:
wrong answer 1st numbers differ - expected: '5109', found: '4032'