# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
498516 |
2021-12-25T11:18:33 Z |
gratus907 |
None (KOI16_gas) |
C++17 |
|
0 ms |
0 KB |
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <unordered_map>
#pragma GCC optimize("Ofast")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;
const ll INF = 987654321987654321;
const int MX = 2625;
struct Edge {
int src, dst, w;
bool operator<(const Edge &p) const {
return w > p.w;
}
};
int fuel[MX];
unordered_map<int, ll> cost[MX];
vector <Edge> G[MX];
void dijkstra(int start, vector<Edge> graph[])
{
cost[start][fuel[start]] = 0;
priority_queue<Edge> pq;
pq.push({0, start,0});
while(!pq.empty()) {
Edge x = pq.top();
pq.pop();
for (auto ed : graph[x.dst]) {
bool flag = false;
for (pii p : cost[ed.src]) {
int j = p.first;
int fcost = min(fuel[ed.dst], j);
int v = ed.dst;
int w = ed.w * j;
if (!cost[v].contains(fcost) or (cost[v][fcost] > p.second + w)) {
flag = true;
cost[v][fcost] = p.second + w;
}
}
if (flag) pq.push(ed);
}
}
}
int32_t main() {
usecppio
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> fuel[i];
for (int i = 0; i < m; i++) {
int u, v, w; cin >> u >> v >> w;
G[u].push_back({u, v, w});
G[v].push_back({v, u, w});
}
dijkstra(1, G);
ll ans = INF;
for (auto p : cost[n]) ans = min(ans, p.second);
cout << ans << '\n';
}
Compilation message
gas.cpp: In function 'void dijkstra(int, std::vector<Edge>*)':
gas.cpp:44:30: error: 'class std::unordered_map<int, long long int>' has no member named 'contains'
44 | if (!cost[v].contains(fcost) or (cost[v][fcost] > p.second + w)) {
| ^~~~~~~~