Submission #241683

#TimeUsernameProblemLanguageResultExecution timeMemory
241683godwindRoller Coaster Railroad (IOI16_railroad)C++14
Compilation error
0 ms0 KiB
#include "railroad.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <functional>

using namespace std;

template<typename T> void uin(T &a, T b) {
	if (b < a) a = b;
}

const long long INF = 1e18 + 228;

long long dp[(1 << 17) + 17][16];

long long plan_roller_coaster(vector<int> s, vector<int> t) {
    int n = (int)s.size();
	if (n <= 16) {
		for (int i = 0; i < (1 << n); ++i) {
			for (int j = 0; j < n; ++j) {
				dp[i][j] = INF;
			}
		}
		for (int fir = 0; fir < n; ++fir) {
			dp[1 << fir][fir] = 0;
		}
		for (int mask = 0; mask < (1 << n); ++mask) {
			for (int last = 0; last < n; ++last) {
				if (dp[mask][last] != INF) {
					for (int new_last = 0; new_last < n; ++new_last) {
						if ((mask >> new_last) & 1) continue;
						long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
						uin(dp[mask | new_last][new_last], cur);
					}
				}
			}
		}
		long long answer = INF;
		for (int last = 0; last < n; ++last) {
			uin(answer, dp[(1 << n) - 1][last]);
		}
		return answer;
	}
    return 0;
}

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:41:70: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type)'
       long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
                                                                      ^
In file included from /usr/include/c++/7/vector:60:0,
                 from railroad.h:3,
                 from railroad.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
railroad.cpp:41:70: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}')
       long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
                                                                      ^
In file included from /usr/include/c++/7/vector:60:0,
                 from railroad.h:3,
                 from railroad.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
railroad.cpp:41:70: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}')
       long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
                                                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from railroad.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
railroad.cpp:41:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
                                                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from railroad.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
railroad.cpp:41:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       long long cur = dp[mask][last] + max(0LL, t[last] - s[new_last]);
                                                                      ^