Submission #882452

#TimeUsernameProblemLanguageResultExecution timeMemory
882452vjudge1Jakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,sse4.2")
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
const int MAXM = 3e5+5;

int n, p[MAXM], B[MAXM], m;
struct quad {
	int first, second, third, fourth;
	quad() : first(0), second(0), third(0), fourth(0) {}
	quad(int a, int b, int c, int d) :first(a), second(b), third(c), fourth(d) {}
	inline bool operator< (quad other) const {
		if(other.first != this->first) return this->first < other.first;
		if(other.second != this->second) return this->second < other.second;
		if(other.third != this->third) return this->third < other.third;
		return this->fourth < other.fourth;
	}
	inline bool operator> (quad other) const {
		if(other.first != this->first) return this->first > other.first;
		if(other.second != this->second) return this->second > other.second;
		if(other.third != this->third) return this->third > other.third;
		return this->fourth > other.fourth;
	}
};

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> B[i] >> p[i];
	vector<int> a(n, INT_MAX);
	vector<vector<int>> b(n);
	priority_queue<quad, vector<quad>, greater<quad>> pq;
	pq.push({0, B[0], p[0], 3});
	for(auto x:b[B[0]]) if(x!=0) pq.push({0, B[0], p[x], 3});
	a[B[0]] = min(a[B[0]], 0ll);
	for(int i = 0; i < m; i++) b[B[i]].push_back(i);
	while(!pq.empty()) {
		auto cur = pq.top(); pq.pop();
		if(a[cur.second] == INT_MAX) {
			for(auto x:b[cur.second]) pq.push({cur.first, cur.second, p[x], 3});
		}
		a[cur.second] = min(a[cur.second], cur.first);
		if(cur.second >= cur.third && cur.fourth != 2)
			pq.push({cur.first + 1, cur.second - cur.third, cur.third, 1});
		if(cur.second < n - cur.third && cur.fourth != 1)
			pq.push({cur.first + 1, cur.second + cur.third, cur.third, 2});
	}
	cout << (a[B[1]] == INT_MAX ? -1 : a[B[1]]) << '\n';
}

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:37:28: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, long long int)'
   37 |  a[B[0]] = min(a[B[0]], 0ll);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:37:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   37 |  a[B[0]] = min(a[B[0]], 0ll);
      |                            ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:37:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   37 |  a[B[0]] = min(a[B[0]], 0ll);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:37:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   37 |  a[B[0]] = min(a[B[0]], 0ll);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:37:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   37 |  a[B[0]] = min(a[B[0]], 0ll);
      |                            ^