Submission #1050407

#TimeUsernameProblemLanguageResultExecution timeMemory
1050407ArpTrain (APIO24_train)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 inf = 1e18; vector<int> b; struct item{ i64 cost; int wh; item(i64 _cost = 0,int _wh = 0){ cost = _cost; wh = _wh; } bool operator > (const item & i) const{ if(i.cost == cost){ return (i.wh == 0 ? 0 : b[i.wh - 1]) < (wh == 0 ? 0 : b[wh - 1]); } return i.cost < cost; } }; i64 solve(int N, int M, int W, std::vector<int> T, vector<int> X, vector<int> Y, vector<int> A, vector<int> B, vector<int> C, vector<int> L, vector<int> R){ b = B; assert(W == 0); vector<vector<int>> adj(N); for(int i = 0;i < M;i++){ adj[X[i]].push_back(i); } vector<i64> dist(M + 1,inf); vector<bool> vis(M + 1,false); priority_queue<item,vector<item>,greater<item>> pq; dist[0] = 0; pq.push(item(0,0)); // pq.push(item(1,0,0,0)); i64 ans = inf; while(!pq.empty()){ auto top = pq.top(); pq.pop(); i64 cost = top.cost; int wh = top.wh; int u = (wh == 0 ? 0 : Y[wh - 1]); int time = B[wh - 1]; if(vis[wh]) continue; vis[wh] = true; if(Y[wh - 1] == N - 1) ans = min(ans,cost); for(int v : adj[u]){ if(A[v] >= time && dist[v + 1] > cost + C[v]){ pq.push(item(cost + C[v],v + 1)); dist[v + 1] = C[v] + cost; } } } if(ans == inf) return -1; else return ans; } int main(){ cout << solve(3, 3, 0, {20, 30, 40}, {0, 1, 0}, {1, 2, 2}, {1, 20, 18}, {15, 30, 40}, {10, 5, 40}, {}, {}) << '\n'; cout << solve(3, 5, 0, {30, 38, 33}, {0, 1, 0, 0, 1}, {2, 0, 1, 2, 2}, {12, 48, 26, 6, 49}, {16, 50, 28, 7, 54}, {38, 6, 23, 94, 50}, {32, 14, 42, 37, 2, 4}, {36, 14, 45, 40, 5, 5}) << '\n'; return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccuvRwJn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrLz3um.o:train.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status