답안 #1050332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1050332 2024-08-09T08:47:31 Z Arp 은하철도 (APIO24_train) C++17
0 / 100
1000 ms 60456 KB
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
const i64 inf = 1e18;

struct item{
	i64 cost;
	int cur,where,node;
	item(i64 _cost = 0,int _cur = 0,int _node = 0,int _where = 0){
		cost = _cost;
		cur = _cur;
		node = _node;
		where = _where;
	}
	bool operator > (const item & i) const{
		if(i.cost == cost){
			return i.cur < cur;
		}
		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){

		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;	

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

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

			int u = top.node;
			i64 cost = top.cost;
			int where = top.where;
			int time = top.cur;

			if(dist[where] == inf){
				dist[where] = cost;
			}else continue;

			int ind = 1;
			for(int v : adj[u]){
				if(A[v] >= time) pq.push(item(cost + C[v],B[v],Y[v],v + 1));
			}

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

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:56:8: warning: unused variable 'ind' [-Wunused-variable]
   56 |    int ind = 1;
      |        ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 13680 KB Correct.
2 Correct 56 ms 15188 KB Correct.
3 Correct 0 ms 344 KB Correct.
4 Correct 6 ms 3928 KB Correct.
5 Correct 0 ms 344 KB Correct.
6 Execution timed out 1093 ms 60456 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 13680 KB Correct.
2 Correct 56 ms 15188 KB Correct.
3 Correct 0 ms 344 KB Correct.
4 Correct 6 ms 3928 KB Correct.
5 Correct 0 ms 344 KB Correct.
6 Execution timed out 1093 ms 60456 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -