QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#943197 | #3153. JOI Park | xiapali | 0 | 1ms | 3712kb | C++20 | 2.1kb | 2025-03-19 18:31:16 | 2025-03-19 18:31:16 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")
mt19937 rnd(238);
#define len(a) (int) a.size()
#define pb push_back
#define pbb pop_back
#define all(a) a.begin(), a.end()
#define rev reverse
#define fi first
#define se second
#define vec vector
#define str string
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define umap unordered_map
#define pri pair<int, int>
#define prl pair<ll, ll>
const int MOD = 1e9 + 7;
const int BLOCK_SZ = 1000;
const ll inf = 1e18;
const int INF = 1e9;
const int mod = 1e9 + 7;
vector<vector<pair<int, ll>>> g;
void dijkstra(int s, vec<ll> &d) {
d[s] = 0;
set<pair<ll, int>> q;
q.emplace(d[s], s);
while (!q.empty()) {
auto l = *q.begin();
int v = l.se;
q.erase(l);
for (auto [to, w]: g[v]) {
if (d[to] > d[v] + w) {
q.erase({d[to], to});
d[to] = d[v] + w;
q.insert({d[to], to});
}
}
}
}
void solve() {
int n, m;
ll c;
cin >> n >> m >> c;
g.resize(n);
ll sum = 0;
while (m--) {
int u, v;
ll w;
cin >> u >> v >> w;
g[u - 1].pb({v - 1, w});
g[v - 1].pb({u - 1, w});
sum += w;
}
vector<ll> d(n, inf);
dijkstra(0, d);
vector<pair<ll, int>> arr;
for (int i = 0; i < n; i++) {
arr.pb({d[i], i});
}
sort(all(arr));
set<ll> s;
ll ans = inf;
for (int i = 0; i < n; i++) {
for (auto [u, w]: g[arr[i].se]) {
if (s.find(u) != s.end()) {
sum -= w;
}
}
s.insert(arr[i].fi);
ans = min(ans, c * arr[i].fi + sum);
}
cout << ans;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int _ = 1;
while (_--) solve();
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 15
Accepted
time: 0ms
memory: 3584kb
input:
2 1 66 2 1 7
output:
7
result:
ok single line: '7'
Test #2:
score: 15
Accepted
time: 0ms
memory: 3712kb
input:
5 10 23 5 2 8 4 2 10 4 5 3 5 3 7 1 5 4 1 4 1 3 2 4 1 2 4 3 4 10 1 3 6
output:
57
result:
ok single line: '57'
Test #3:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
input:
25 114 18 22 3 3 25 6 1 3 7 2 1 12 2 25 5 2 13 7 5 2 18 3 13 25 3 4 17 2 4 6 1 25 7 1 10 19 1 24 8 2 16 8 1 5 19 4 12 15 3 19 17 1 21 13 2 22 13 4 23 14 4 5 15 2 23 24 4 6 2 4 4 7 4 2 22 5 18 16 5 5 2 3 22 25 5 23 19 2 19 20 4 20 17 5 3 23 4 20 7 5 24 10 1 18 13 5 18 9 2 7 24 5 6 9 2 19 7 5 23 21 5 ...
output:
325
result:
wrong answer 1st lines differ - expected: '108', found: '325'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%