Submission #1575446


Source Code Expand

#include <iostream>
#include <queue>
#include <functional>
#include <vector>
#includde <cassert>
using namespace std;

int n, m;
int s, t;
vector<int> edgeTo[1000];
vector<int> edgeCost[1000];

int minDistS[1000];
int minDistT[1000];

void dijkstra(int start, int minDist[]) {
	typedef pair<int, int> P;	//cost, pos
	priority_queue<P, vector<P>, greater<P>> que;	//cost昇順でほげほげ
	int i;
	
	for (i = 0; i < n; i++) minDist[i] = 1145141919;
	
	que.push(P(0, start));
	minDist[start] = 0;
	while (!que.empty()) {
		P now = que.top(); que.pop();
		int c = now.first;
		int v = now.second;
		
		for (i = 0; i < edgeTo[v].size(); i++) {
			int nextV = edgeTo[v][i];
			if (minDist[nextV] > c + edgeCost[v][i]) {
				minDist[nextV] = c + edgeCost[v][i];
				que.push(P(minDist[nextV], nextV));
			}
		}
	}
}

int main() {
	int i;

	cin >> n >> m;
	cin >> s >> t;
	s--; t--;
	
	if (s == t) { assert(0); }
	
	for (i = 0; i < m; i++) {
		int from, to, c;
		cin >> from >> to >> c;
		from--;
		to--;
		edgeTo[from].push_back(to);
		edgeTo[to].push_back(from);
		edgeCost[from].push_back(c);
		edgeCost[to].push_back(c);
	}
	
	dijkstra(s, minDistS);
	dijkstra(t, minDistT);
	
	for (int u = 0; u < n; u++) {
		if (minDistS[u] == minDistT[u]) {
			cout << u + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Submission Info

Submission Time
Task C - 身体バランス
User startcpp
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1392 Byte
Status CE

Compile Error

./Main.cpp:5:2: error: invalid preprocessing directive #includde
 #includde <cassert>
  ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:24: error: ‘assert’ was not declared in this scope
  if (s == t) { assert(0); }
                        ^