Submission #1481441
Source Code Expand
#include <iostream> #include <vector> #include <queue> #include <utility> #include <functional> #include <algorithm> using namespace std; #define int long long #define rep(i,x) for(int i=0;i<x;++i) #define fst first #define scd second const int inf = 3e18; using pii = pair<int, int>; using vpii = vector<pii>; struct edge { int to, cost; }; vector<edge> G[2505]; int d[2505]; int N, M, R, T; int memR[2505]; void dijkstra(int s) { priority_queue<pii, vpii, greater<pii>> q; q.emplace(0, s); rep(i, N) d[i] = inf; d[s] = 0; while (q.size()) { pii p = q.top(); q.pop(); int v = p.scd; if (d[v] < p.fst) continue; for (edge &e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; q.emplace(d[e.to], e.to); } } } } signed main() { cin >> N >> M >> R >> T; rep(i, M) { int a, b, c; cin >> a >> b >> c; --a, --b; G[a].emplace_back(edge{b, c}); G[b].emplace_back(edge{a, c}); } long long ans = 0; rep(i, N) { dijkstra(i); vector<double> rabbits, turtles; rep(j, N) { if (i == j) continue; double r = (double)d[j] * T; double t = (double)d[j] * R; rabbits.emplace_back(r); turtles.emplace_back(t); memR[j] = r; } sort(begin(rabbits), end(rabbits)); rep(j, N - 1) { double t = turtles[j].fst; int idx = turtles[j].scd; int v = N - 1 - (upper_bound(begin(rabbits), end(rabbits), t) - begin(rabbits)); if (memR[idx] > t) v--; ans += v; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - ウサギとカメ |
User | Izryt |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1897 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:13: error: request for member ‘first’ in ‘turtles.std::vector<_Tp, _Alloc>::operator[]<double, std::allocator<double> >(((std::vector<double>::size_type)j))’, which is of non-class type ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’ #define fst first ^ ./Main.cpp:89:35: note: in expansion of macro ‘fst’ double t = turtles[j].fst; ^ ./Main.cpp:14:13: error: request for member ‘second’ in ‘turtles.std::vector<_Tp, _Alloc>::operator[]<double, std::allocator<double> >(((std::vector<double>::size_type)j))’, which is of non-class type ‘__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type {aka double}’ #define scd second ^ ./Main.cpp:90:34: note: in expansion of macro ‘scd’ int idx = turtles[j].scd; ^