Submission #417781

#TimeUsernameProblemLanguageResultExecution timeMemory
417781DEQKJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#define ll long long
using namespace std;
const int N = 3e4 + 10;
vector<vector<pair<int, int>>> g(N);
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	short n, m; cin >> n >> m;
	int f, s;
	for(short i = 0; i < m; i++) {
		short x, y; cin >> x >> y;
		if(i == 0) f = x;
		if(i == 1) s = x;
		if(y == 0) continue;
		for(short j = x + y; j < n; j += y) {
			g[x].push_back({j, (j - x) / y});
		}
		for(short j = x - y; j >= 0; j -= y) {
			g[x].push_back({j, (x - j) / y});
		}
	}
	priority_queue<pair<ll, short>, vector<pair<int, short>>, greater<pair<ll, short>>> c;
	vector<ll> d(n, 1e15);
	d[f] = 0;
	c.push({0, f});
	while(!c.empty()) {
		ll w; short u; 
		tie(w, u) = c.top();
		c.pop();
		if(d[u] != w) continue;
		for(pair<int, int> to : g[u]) {
			if(d[to.first] > d[u] + to.second) {
				d[to.first] = d[u] + to.second;
				c.push({d[to.first], to.first});
			}
		}
	}
	cout << (d[s] == 1e15 ? -1 : d[s]);
}

Compilation message (stderr)

In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from skyscraper.cpp:1:
/usr/include/c++/10/bits/stl_queue.h: In instantiation of 'class std::priority_queue<std::pair<long long int, short int>, std::vector<std::pair<int, short int> >, std::greater<std::pair<long long int, short int> > >':
skyscraper.cpp:23:86:   required from here
/usr/include/c++/10/bits/stl_queue.h:480:67: error: static assertion failed: value_type must be the same as the underlying container
  480 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~