QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#350717 | #6523. Escape Plan | Dream_56 | WA | 0ms | 3604kb | C++14 | 1.7kb | 2024-03-11 01:38:47 | 2024-03-11 01:38:47 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using li = long long;
using pli = pair<long long, int>;
struct Graph {
public:
int n, m;
vector<int> head, to, w, nxt;
Graph(int n, int m): head(n + 5), to((m << 1) + 5), w((m << 1) + 5), nxt((m << 1) +5) {}
void adde(int x, int y, int val) {
to[tot] = y, w[tot] = val, nxt[tot] = head[x], head[x] = tot, tot++;
swap(x, y);
to[tot] = y, w[tot] = val, nxt[tot] = head[x], head[x] = tot, tot++;
}
private:
int tot = 2;
};
void solve() {
int n, m, exit_cnt; cin >> n >> m >> exit_cnt;
Graph G(n, m);
vector<int> exits(exit_cnt + 5);
vector<int> D(n + 5);
for (int i = 1; i <= exit_cnt; ++i) {
cin >> exits[i];
}
for (int i = 1; i <= n; ++i) {
cin >> D[i];
}
for (int i = 1; i <= m; ++i) {
int x, y, val;
cin >> x >> y >> val;
G.adde(x, y, val);
}
priority_queue<pli, vector<pli>, greater<pli>> q;
vector<li> Dist(n + 5, -1);
for (int p: exits) {
q.push({0, p});
}
while (q.size()) {
auto [dis, node] = q.top();
q.pop();
if (Dist[node] != -1)
continue;
--D[node];
if (D[node] >= 0)
continue;
Dist[node] = dis;
for (int ei = G.head[node]; ei; ei = G.nxt[ei]) {
int v = G.to[ei], val = G.w[ei];
if (Dist[v] != -1)
continue;
q.push({Dist[node] + val, v});
}
}
cout << Dist[1] << '\n';
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int T; cin >> T;
while (T--) {
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
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:
-1 -1
result:
wrong answer 1st numbers differ - expected: '4', found: '-1'