QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#142802 | #6523. Escape Plan | MaxBlazeResFire | WA | 411ms | 243436kb | C++23 | 1.5kb | 2023-08-19 22:24:20 | 2023-08-19 22:24:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define MAXN 3000005
int n,m,k,cnt,ise[MAXN],d[MAXN],dist[MAXN],del[MAXN],vis[MAXN],Vis[MAXN];
struct node{ int v,w,id; };
vector<node> E[MAXN];
priority_queue<int> Q[MAXN];
inline void upd( int t , int x ){
if( (int)( Q[t].size() ) <= d[t] ) Q[t].push( x );
else if( x < Q[t].top() ) Q[t].pop(),Q[t].push( x );
}
int dfs( int x ){
if( ise[x] ) return 0;
if( (int)( Q[x].size() ) > d[x] ) return dist[x];
vis[x] = 1;
for( node p : E[x] ){
int v = p.v,w = p.w,id = p.id;
if( vis[v] || Vis[id] ) continue;
int tmp = dfs( v ); Vis[id] = 1;
if( tmp == -1 ) continue;
//cerr << "upd" << x << "with" << v << "\n";
upd( x , tmp + w );
}
vis[x] = 0;
if( (int)( Q[x].size() ) > d[x] ) return dist[x] = Q[x].top();
return -1;
}
inline void solve(){
scanf("%d%d%d",&n,&m,&k);
for( int i = 1 ; i <= n ; i ++ ){
dist[i] = -1,ise[i] = del[i] = vis[i] = 0;
E[i].clear();
while( !Q[i].empty() ) Q[i].pop();
}
for( int i = 1 ; i <= k ; i ++ ){
int x; scanf("%d",&x);
ise[x] = 1;
}
for( int i = 1 ; i <= n ; i ++ ) scanf("%d",&d[i]);
for( int i = 1 ; i <= m ; i ++ ){
int u,v,w; scanf("%d%d%d",&u,&v,&w);
E[u].emplace_back( node{ v , w , ++cnt } );
E[v].emplace_back( node{ u , w , ++cnt } );
}
for( int i = 1 ; i <= cnt ; i ++ ) Vis[i] = 0;
printf("%d\n",dfs(1));
//for( int i = 1 ; i <= n ; i ++ ) cerr << dist[i] << "\n";
}
signed main(){
int testcase; scanf("%d",&testcase);
while( testcase -- ) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 20ms
memory: 178296kb
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: 411ms
memory: 243436kb
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:
5402 1021 4088 6471 4743 5168 2624 7921 3872 3014 5094 3112 1487 8315 2635 8626 3583 2738 4837 2626 12302 7009 2572 2150 8412 16882 5497 2322 1318 5217 3692 1735 1779 -1 4606 6265 2065 4352 2923 4611 402 3769 19209 8572 8382 5317 -1 510 2636 15128 -1 3166 4107 9746 7991 2356 4208 270 5066 2166 4558 ...
result:
wrong answer 1st numbers differ - expected: '5109', found: '5402'