제출 #583633

#제출 시각아이디문제언어결과실행 시간메모리
583633MilosMilutinovicDomino (COCI15_domino)C++14
컴파일 에러
0 ms0 KiB
/** * author: wxhtzdy * created: 24.06.2022 12:30:23 **/ #include <bits/stdc++.h> using namespace std; string to_string(string s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template <typename A> string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define int long long int f[1 << 23][9]; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<vector<int>> a(n, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } vector<array<int, 3>> b; auto Id = [&](int i, int j) { return i * n + j; }; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i + 1 < n) { b.push_back({a[i][j] + a[i + 1][j], Id(i, j), Id(i + 1, j)}); } if (j + 1 < n) { b.push_back({a[i][j] + a[i][j + 1], Id(i, j), Id(i, j + 1)}); } } } sort(b.rbegin(), b.rend()); while ((int) b.size() > 50) { b.pop_back(); } int sz = (int) b.size(); int R = min(22, sz / 2); int L = sz - R; for (int s = 0; s < (1 << R); s++) { for (int j = 0; j <= k; j++) { f[s][j] = 0; } } for (int s = 0; s < (1 << R); s++) { for (int i = 0; i < R; i++) { for (int j = 0; j <= k; j++) { if (s >> i & 1) { f[s][j] = max(f[s][j], f[s ^ (1 << i)][j]); } } } for (int p = 1; p <= k; p++) { f[s][p] = max(f[s][p], f[s][p - 1]); } if (__builtin_popcount(s) >= k) { continue; } for (int i = 0; i < R; i++) { for (int p = 0; p < k; p++) { if (s >> i & 1) { continue; } bool ok = true; for (int j = 0; j < R; j++) { if (!(s >> j & 1)) { continue; } if (b[L + i][1] == b[L + j][1]) { ok = false; } if (b[L + i][1] == b[L + j][2]) { ok = false; } if (b[L + i][2] == b[L + j][1]) { ok = false; } if (b[L + i][2] == b[L + j][2]) { ok = false; } } if (ok) { f[s | (1 << i)][p + 1] = max(f[s | (1 << i)][p], f[s][p] + b[L + i][0]); } } } for (int p = 1; p <= k; p++) { f[s][p] = max(f[s][p], f[s][p - 1]); } } int ans = 0; for (int s = 0; s < (1 << R); s++) { for (int j = 0; j <= k; j++) { ans = max(ans, f[s][j]); } } for (int s = 0; s < (1 << L); s++) { if (__builtin_popcount(s) > k) { continue; } int t = (1 << R) - 1; bool ok = true; for (int i = 0; i < L; i++) { if (s >> i & 1) { for (int j = i + 1; j < L; j++) { if (s >> j & 1) { if (b[i][1] == b[j][1]) { ok = false; } if (b[i][1] == b[j][2]) { ok = false; } if (b[i][2] == b[j][1]) { ok = false; } if (b[i][2] == b[j][2]) { ok = false; } } } } } if (!ok) { continue; } for (int i = 0; i < L; i++) { if (s >> i & 1) { for (int j = 0; j < R; j++) { if (t >> j & 1) { bool found = false; if (b[i][1] == b[L + j][1]) { found = true; } if (b[i][1] == b[L + j][2]) { found = true; } if (b[i][2] == b[L + j][1]) { found = true; } if (b[i][2] == b[L + j][2]) { found = true; } if (found) { t ^= (1 << j); } } } } } int ft = 0; for (int i = 0; i < L; i++) { if (s >> i & 1) { ft += b[i][0]; } } ans = max(ans, ft + f[t][k - __builtin_popcount(s)]); } int sum = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { sum += a[i][j]; } } cout << sum - ans << '\n'; return 0; }

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

domino.cpp: In function 'int main()':
domino.cpp:82:25: error: no matching function for call to 'min(int, long long int)'
   82 |   int R = min(22, sz / 2);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from domino.cpp:5:
/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:
domino.cpp:82:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |   int R = min(22, sz / 2);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from domino.cpp:5:
/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:
domino.cpp:82:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |   int R = min(22, sz / 2);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from domino.cpp:5:
/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:
domino.cpp:82:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |   int R = min(22, sz / 2);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from domino.cpp:5:
/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:
domino.cpp:82:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |   int R = min(22, sz / 2);
      |                         ^