QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#109887 | #6523. Escape Plan | xuxubaobao | AC ✓ | 943ms | 90328kb | C++17 | 1.4kb | 2023-05-30 21:29:34 | 2023-05-30 21:29:35 |
Judging History
answer
// Super Idol的笑容
// 都没你的甜
// 八月正午的阳光
// 都没你耀眼
// 热爱105°C的你
// 滴滴清纯的蒸馏水
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int>;
using ll = long long;
constexpr int N = 1e6 + 10;
int n, m, k;
int du[N];
bool st[N], ban[N];
int d[N];
vector<array<int,3>> e[N];
void solve() {
vector<int> ns;
cin >> n >> m >> k;
for(int i = 1; i <= m; i ++) ban[i] = false;
for(int i = 1; i <= n; i ++) e[i].clear(), st[i] = false, du[i] = 0;
// for(int i = 1; i <= n; i ++) while(g[i].size()) g[i].pop();
ns.clear();
for(int i = 1; i <= k; i ++){
int x;
cin >> x;
ns.push_back(x);
}
for(int i = 1; i <= n; i ++){
cin >> du[i];
du[i] ++;
}
for(int i = 1; i <= m; i ++) {
int l, r, w;
cin >> l >> r >> w;
e[l].push_back({w, r, i});
e[r].push_back({w, l, i});
}
priority_queue<PII,vector<PII>,greater<PII>> q;
for(auto v : ns) {
du[v] = 0;
d[v] = 0;
q.push({0, v});
}
while(q.size()) {
auto [dis, x] = q.top();
q.pop();
du[x] --;
if(du[x] > 0) continue;
if(st[x]) continue;
d[x] = dis;
st[x] = 1;
for(auto [w, v, id] : e[x]) {
q.push({w + dis, v});
}
}
if(du[1] > 0) cout << "-1" << "\n";
else cout << d[1] << "\n";
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 7ms
memory: 31256kb
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: 943ms
memory: 90328kb
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