Submission #1082701

# Submission time Handle Problem Language Result Execution time Memory
1082701 2024-09-01T09:15:11 Z Arp Train (APIO24_train) C++17
0 / 100
53 ms 10620 KB
#include<bits/stdc++.h>
using namespace std;

using i64 = long long;

struct Data{
	i64 cost;
	int cur,node;
	Data(i64 _c=0LL,int _cu=0,int _no=0){
		cost = _c;
		cur = _cu;
		node = _no;
	}
	bool operator < (Data D) const{
		if(D.cost == cost){
			return D.cur <= cur;
		}
		return D.cost < cost;
	}
};

i64 solve(int N,int M,int W,vector<int> T,
	vector<int> X,vector<int> Y,vector<int> A,vector<int> B,vector<int> C,
	vector<int> L,vector<int> R){

	vector<vector<int>> adj(N);
	for(int i = 0;i < M;i++){
		int u = X[i];
		adj[u].push_back(i);
	} 
	for(int i = 0;i < N;i++){
		sort(adj[i].begin(),adj[i].end(),[&](int i,int j){
			return A[i] > A[j];
		});
	}
	vector<int> cur(N);
	vector<i64> dist(M + 1,-1);
	priority_queue<Data,vector<Data>,less<Data>> pq;
	pq.push(Data(0LL,0,0));

	while(!pq.empty()){
		Data d = pq.top();
		pq.pop();
		int u = (d.node == 0 ? 0 : Y[d.node - 1]);
		i64 cost = d.cost;
		int time = d.cur;
		if(dist[d.node] != -1) continue;
		dist[d.node] = cost;
		while(cur[u] < (int) adj[u].size()){
			int ind = adj[u][cur[u]];
			int v = Y[ind];
			int w = C[ind];
			if(time <= A[ind]){
				pq.push(Data(cost + w,B[ind],ind + 1));
				++ cur[u];
			}else break;
		}
	}
	i64 ans = 1e18;
	for(int i = 1;i <= M;i++){
		if(Y[i - 1] == N - 1){
			ans = min(ans,dist[i]);
		}
	}
	return ans;
}

Compilation message

train.cpp: In function 'i64 solve(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:51:8: warning: unused variable 'v' [-Wunused-variable]
   51 |    int v = Y[ind];
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 10620 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 10620 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -