Submission #168955

#TimeUsernameProblemLanguageResultExecution timeMemory
168955touristEvacuation plan (IZhO18_plan)C++11
Compilation error
0 ms0 KiB
#include <iostream>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int N = 1e5;
const int mod = 1e9 + 7;										/// ANOTHER HASH MOD: 228228227
const int prime = 29;											/// ANOTHER HASH PRIME: 997
const int INF = 1e9 + 7;

int n, m, k, q;

vector < int > bad, dist(N + 9, INF);
vector < pii > g[N + 9], querry;

inline void purify() {
}

inline void precalc() {
}

void check(int a, int b) {
	for (pii i : g[a]) {
		if (i.first == b) {
			assert(false);
		}
	}
}

inline void read() {
	int a, b, c;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b >> c;
		g[a].push_back({b, c});
		g[b].push_back({a, c});
	}

	cin >> k;
	for (int i = 1; i <= k; i++) {
		cin >> a;
		bad.push_back(a);
	}
}

void dij() {
	priority_queue < pii > pq;
	for (int i : bad) {
		pq.push({0, i});
		dist[i] = 0;
	}

	while (pq.size()) {
		int cur = pq.top().second;
		int d = -pq.top().first;
		pq.pop();

		if (d > dist[cur]) {
			continue;
		}

		for (pii i : g[cur]) {
			int u = i.first;
			int len = i.second;
			if (dist[cur] + len < dist[u]) {
				dist[u] = dist[cur] + len;
				pq.push({-dist[u], u});
			}
		}
	}
}

inline void solve() {
	dij();
  
	cin >> q;
	querry.push_back({0, 0});
	for (int i = 1; i <= q; i++) {
		cin >> a >> b;
		check(a, b);
		querry.push_back({a, b});
		int ans = dist[b];
		if (dist[a] < dist[b]) {
			ans = dist[a];
		}
		cout << ans << endl;
	}
}

int main() {
	int t;
	//scanf("%d", &t);
	t = 1;

	//precalc();
	while (t--) {
		//purify();
		read();
		solve();
	}
}

Compilation message (stderr)

plan.cpp: In function 'void solve()':
plan.cpp:88:10: error: 'a' was not declared in this scope
   cin >> a >> b;
          ^
plan.cpp:88:15: error: 'b' was not declared in this scope
   cin >> a >> b;
               ^
plan.cpp:90:26: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   querry.push_back({a, b});
                          ^
In file included from /usr/include/c++/7/vector:64:0,
                 from plan.cpp:3:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'