Submission #1082702

# Submission time Handle Problem Language Result Execution time Memory
1082702 2024-09-01T09:19:18 Z Arp Train (APIO24_train) C++17
5 / 100
73 ms 15440 KB
#include<bits/stdc++.h>
using namespace std;

using i64 = long long;
const i64 inf = 1e18;
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,inf);
	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] != inf) 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 == inf ? -1 : 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 Correct 56 ms 10704 KB Correct.
2 Correct 67 ms 15440 KB Correct.
3 Correct 0 ms 344 KB Correct.
4 Correct 10 ms 4468 KB Correct.
5 Correct 0 ms 348 KB Correct.
6 Correct 54 ms 10576 KB Correct.
7 Correct 1 ms 348 KB Correct.
8 Correct 62 ms 14644 KB Correct.
9 Correct 66 ms 15440 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 56 ms 10704 KB Correct.
2 Correct 67 ms 15440 KB Correct.
3 Correct 0 ms 344 KB Correct.
4 Correct 10 ms 4468 KB Correct.
5 Correct 0 ms 348 KB Correct.
6 Correct 54 ms 10576 KB Correct.
7 Correct 1 ms 348 KB Correct.
8 Correct 62 ms 14644 KB Correct.
9 Correct 66 ms 15440 KB Correct.
10 Incorrect 73 ms 14296 KB Wrong Answer.
11 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 -