제출 #130558

#제출 시각아이디문제언어결과실행 시간메모리
130558KieranHorganAliens (IOI16_aliens)C++17
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast") #include "aliens.h" #include <bits/stdc++.h> using namespace std; // #define int long long vector<pair<int, int>> intervals; int cost(int i, int l) { int overlap = max(0ll, intervals[l].second-intervals[l+1].first+1); return (intervals[i].second-intervals[l+1].first+1)*(intervals[i].second-intervals[l+1].first+1) - overlap*overlap; } signed n; vector<vector<int>> dp, opt; int j; void recurse(int l, int r) { if(l==r) return; int i = (l+r)/2; for(int cur = opt[j][l-1]; cur < (r==n+1?i:opt[j][r]+1); cur++) { if(dp[j-1][cur] + cost(i, cur) < dp[j][i]) { opt[j][i] = cur; dp[j][i] = dp[j-1][cur] + cost(i, cur); } } if(l+1 != r) { recurse(l, i); recurse(i+1, r); } } long long take_photos(signed N, signed m, signed k, vector<signed> r, vector<signed> c) { n=N; for(int i = 0; i < n; i++) { if(c[i] >= r[i]) intervals.push_back({r[i], -c[i]}); else intervals.push_back({c[i], -r[i]}); } sort(intervals.begin(), intervals.end()); auto interStore = intervals; intervals.clear(); intervals.push_back({-1, -1}); int ma = -1; for(auto p: interStore) { if(-p.second > ma) { ma = -p.second; intervals.push_back({p.first, -p.second}); } } n = intervals.size()-1; k = min(k, n); dp.assign(k+1, vector<int>(n+1, 1<<30)); opt.assign(k+1, vector<int>(n+1, 0)); dp[0][0] = 0; // queue<pair<int, int>> ranges; for(j = 1; j <= k; j++) { recurse(1ll, (int)n+1); } return dp[k][n]; }

컴파일 시 표준 에러 (stderr) 메시지

aliens.cpp: In function 'int cost(int, int)':
aliens.cpp:10:68: error: no matching function for call to 'max(long long int, int)'
   int overlap = max(0ll, intervals[l].second-intervals[l+1].first+1);
                                                                    ^
In file included from /usr/include/c++/7/vector:60:0,
                 from aliens.h:3,
                 from aliens.cpp:2:
/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:10:68: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   int overlap = max(0ll, intervals[l].second-intervals[l+1].first+1);
                                                                    ^
In file included from /usr/include/c++/7/vector:60:0,
                 from aliens.h:3,
                 from aliens.cpp:2:
/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:10:68: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   int overlap = max(0ll, intervals[l].second-intervals[l+1].first+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:3:
/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:10:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   int overlap = max(0ll, intervals[l].second-intervals[l+1].first+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:3:
/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:10:68: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   int overlap = max(0ll, intervals[l].second-intervals[l+1].first+1);
                                                                    ^