QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#555737 | #6523. Escape Plan | chimera | AC ✓ | 930ms | 93560kb | C++11 | 1.7kb | 2024-09-10 08:50:58 | 2024-09-10 08:50:58 |
Judging History
answer
#include <bits/stdc++.h>
#define greedy int
#define mindset main()
using namespace std;
#define FOR(a,b,c) for(ll a = b; a < (c); a++)
#define FORR(a,b,c) for(ll a = b; a > (c); a--)
#define READ(x) ll x;cin>>x;
#define READAR(x,n) vll x(n); FOR(readar,0,n) cin >> x[readar];
#define READS(x) string x; cin>>x;
#define SEP(n,mx) (((n) == (mx)-1) ? '\n' : ' ')
#define speedfirst ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef tuple<ll,ll,ll> tll;
void solve() {
READ(N); READ(M); READ(K);
READAR(E, K);
READAR(D, N);
vector<vpll> adj(N);
FOR(m,0,M) {
READ(U); READ(V); READ(W); U--; V--; adj[U].push_back({V,W}); adj[V].push_back({U,W});
}
vector<ll> ct(N,0);
vector<ll> mx(N,0);
vector<bool> consumed(N, false);
priority_queue<pll, vector<pll>, greater<pll> > hitq;
for(auto e: E) {
e--;
consumed[e]=true;
for(auto a: adj[e]) {
hitq.push({a.second, a.first});
}
}
while(hitq.size()) {
auto b = hitq.top(); hitq.pop();
ll d = b.first; ll v = b.second;
if(consumed[v]) continue;
ct[v]++;
mx[v] = max(mx[v], d);
if(ct[v] > D[v]) {
consumed[v] = true;
for(auto a: adj[v]) {
hitq.push({a.second + mx[v], a.first});
}
}
}
if(!consumed[0]) cout << "-1\n";
else cout << mx[0] << "\n";
}
greedy mindset {
speedfirst;
READ(T); FOR(t,0,T) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 0
Accepted
time: 930ms
memory: 93560kb
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 4646 3796 3394 1884 6772 2329 2067 3296 2809 865 4249 2241 3792 2135 2544 3343 1775 10602 4677 1700 2150 7071 14055 3368 2322 1113 1980 3067 1617 1702 -1 2879 6265 2065 2810 2289 3001 402 3769 18118 6874 7879 3823 -1 510 2636 10564 -1 3166 3615 7526 5549 1261 3302 270 4440 1998 3350 3...
result:
ok 100 numbers