제출 #414152

#제출 시각아이디문제언어결과실행 시간메모리
414152600MihneaCultivation (JOI17_cultivation)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll const int N = 300 + 7; const int INF = (int) 1e18 + 7; int dimx, dimy, n; struct point { int x; int y; }; point v[N]; vector<int> cover[N]; signed main() { ios::sync_with_stdio(0); cin.tie(0); ///freopen ("input", "r", stdin); cin >> dimx >> dimy >> n; for (int i = 1; i <= n; i++) { cin >> v[i].x >> v[i].y; } assert(dimx <= 40); int sol = INF; for (int a = 0; a <= dimx; a++) { for (int b = 0; a + b <= dimx; b++) { /// fix north, south for (int i = 1; i <= dimx; i++) { cover[i].clear(); } for (int i = 1; i <= n; i++) { int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b); for (int j = l; j <= r; j++) { cover[j].push_back(i); } } bool ok = 1; for (int i = 1; i <= dimx; i++) { if (cover[i].empty()) { ok = 0; break; } } if (!ok) { continue; } /// now it's a pretty easy task /// For each row I have some restrictions int r1 = 0, r2 = 0, rsum = 0; for (int i = 1; i <= dimx; i++) { vector<int> pts; for (auto &j : cover[i]) { pts.push_back(v[j].y); } sort(pts.begin(), pts.end()); r1 = max(r1, pts[0] - 1); r2 = max(r2, dimy - pts.back()); for (int j = 1; j < (int) pts.size(); j++) { rsum = max(rsum, pts[j] - pts[j - 1] - 1); } } rsum = max(rsum, r1 + r2); sol = min(sol, a + b + rsum); } } cout << sol << "\n"; return 0; }

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

cultivation.cpp: In function 'int main()':
cultivation.cpp:44:34: error: no matching function for call to 'max(int, ll)'
   44 |         int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b);
      |                                  ^
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 cultivation.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
cultivation.cpp:44:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   44 |         int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b);
      |                                  ^
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 cultivation.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
cultivation.cpp:44:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   44 |         int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
cultivation.cpp:44:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |         int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b);
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cultivation.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
cultivation.cpp:44:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |         int l = max(1, v[i].x - a), r = min(dimx, v[i].x + b);
      |                                  ^
cultivation.cpp:45:30: error: 'r' was not declared in this scope
   45 |         for (int j = l; j <= r; j++) {
      |                              ^