Submission #1050393

# Submission time Handle Problem Language Result Execution time Memory
1050393 2024-08-09T09:03:21 Z Arp Train (APIO24_train) C++17
0 / 100
57 ms 10496 KB
#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 (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);

		priority_queue<item,vector<item>,greater<item>> pq;	
		dist[0] = 0;

		pq.push(item(0,0));
		// pq.push(item(1,0,0,0));

		while(!pq.empty()){
			auto top = pq.top();
			pq.pop();

			i64 cost = top.cost;
			int wh = top.wh;
			int u = X[wh];
			int time = B[wh - 1];

			if(dist[wh] != cost){
				continue;
			}

			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;
				}
			}

		}
		i64 ans = inf;
		for(int i = 1;i <= M;i++){
			if(Y[i - 1] == N - 1){
				ans = min(ans,dist[i]);
			}
		}
		if(ans == inf) return -1;
		else return ans;
}

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 7128 KB Correct.
2 Correct 57 ms 10496 KB Correct.
3 Runtime error 1 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 54 ms 7128 KB Correct.
2 Correct 57 ms 10496 KB Correct.
3 Runtime error 1 ms 348 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -