Submission #139189

#TimeUsernameProblemLanguageResultExecution timeMemory
139189nvmdavaAliens (IOI16_aliens)C++17
Compilation error
0 ms0 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define ll long long vector<pair<ll, ll> > tmp; vector<ll> L(1, -1), R(1, -1); int n; struct Line{ ll x, y, g; int id; Line(int _id, ll _x, ll _y, ll _g){ x = _x; id = _id; y = _y; g = _g; } ll query(ll xx){ return y - xx * g; } ll cross(ll _y, ll _g){ ll dy = _y - y; ll dg = _g - g; return dy / dg + 1; } }; vector<Line> line; int cnt[100005]; ll ans[100005]; void calc(ll c){ line.clear(); int it = 0, sz = 0; line.push_back(Line(0, 0, L[1] * L[1], 2 * L[1])); for(int i = 1; i <= n; i++){ while(it < sz && line[it + 1].x <= R[i]) it++; ans[i] = c + R[i] * R[i] + line[it].query(R[i]); cnt[i] = cnt[line[it].id] + 1; if(i == n) break; ll t = max(0, R[i] - L[i + 1]); ll yy = ans[i] - t * t + L[i + 1] * L[i + 1]; ll gg = 2 * L[i + 1]; while(sz >= 0 && line[sz].cross(yy, gg) <= line[sz].x){ sz--; line.pop_back(); } line.push_back(Line(i, sz == -1 ? 0 : line[sz].cross(yy, gg), yy, gg)); sz++; it = min(it, sz); } } ll take_photos(int n, int qq, int k, std::vector<int> rr, std::vector<int> cc) { for(int i = 0; i < n; i++){ tmp.push_back({min(rr[i], cc[i]), - 1 - max(rr[i], cc[i])}); } sort(tmp.begin(), tmp.end()); int mxm = -1; for(auto& x : tmp){ if(-x.second > mxm){ mxm = -x.second; L.push_back(x.first); R.push_back(mxm); } } ::n = n = L.size() - 1; ll l = 0, r = qq * 1LL * qq; while(l < r){ ll m = (l + r) >> 1; calc(m); if(cnt[n] <= k) r = m; else l = m + 1; } calc(r); return ans[n] - k * r; }

Compilation message (stderr)

aliens.cpp: In function 'void calc(long long int)':
aliens.cpp:45:32: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type)'
   ll t = max(0, R[i] - L[i + 1]);
                                ^
In file included from /usr/include/c++/7/vector:60:0,
                 from aliens.h:3,
                 from aliens.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:
aliens.cpp:45:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}')
   ll t = max(0, R[i] - L[i + 1]);
                                ^
In file included from /usr/include/c++/7/vector:60:0,
                 from aliens.h:3,
                 from aliens.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:
aliens.cpp:45:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type {aka long long int}')
   ll t = max(0, R[i] - L[i + 1]);
                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from aliens.cpp:2:
/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:
aliens.cpp:45:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   ll t = max(0, R[i] - L[i + 1]);
                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from aliens.cpp:2:
/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:
aliens.cpp:45:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   ll t = max(0, R[i] - L[i + 1]);
                                ^