제출 #785141

#제출 시각아이디문제언어결과실행 시간메모리
785141ono_de206Catfish Farm (IOI22_fish)C++17
컴파일 에러
0 ms0 KiB
#include "fish.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second // #define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; template<typename T> void mxx(T &a, T b) { if(a < b) a = b; } long long max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W) { vector<vector<pair<int, long long>>> pos(n); for(int i = 0; i < m; i++) { pos[X[i]].eb(Y[i], W[i]); } vector<vector<pair<long long, long long>>> dp(n); for(int i = 0; i < n; i++) { sort(all(pos[i])); dp[i].resize(pos[i].size(), make_pair(0, 0)); } long long ans = 0; for(int i = 1; i < n; i++) { int sz = (int)pos[i].size(), l = 0, mx = 0; for(int j = 0; j < pos[i - 1].size(); j++) { mxx(mx, dp[i - 1][j].ss); } for(int j = 0; j < sz; j++) { dp[i][j].ff = max(ans, mx); if(dp[i - 1].size()) mxx(dp[i][j].ff, dp[i - 1][0].ss); if(j) mxx(dp[i][j].ff, dp[i][j - 1].ff); while(l < pos[i - 1].size() && pos[i - 1][l].ff < pos[i][j].ff) { dp[i][j].ff = max(dp[i][j].ff + pos[i - 1][l].ss, dp[i - 1][l].ff + pos[i - 1][l].ss); l++; } } if(i - 2 >= 0) { long long sum = 0; for(int j = (int)pos[i - 2].size() - 1; j >= 0; j--) { sum += pos[i - 2][j].ss; mxx(ans, dp[i - 2][j].ff + sum); } } int r = (int)pos[i - 1].size() - 1; for(int j = sz - 1; j >= 0; j--) { dp[i][j].ss = ans + pos[i][j].ss; if(j + 1 < sz) mxx(dp[i][j].ss, dp[i][j + 1].ss + pos[i][j].ss); while(r >= 0 && pos[i - 1][r].ff > pos[i][j].ff) { mxx(dp[i][j].ss, max(dp[i - 1][r].ff, dp[i - 1][r].ss) + pos[i][j].ss); r--; } } for(int j = 0; j < (int)pos[i - 1].size(); j++) { mxx(ans, dp[i - 1][j].ss); } } long long sum = 0; for(int j = (int)pos[n - 2].size() - 1; j >= 0; j--) { sum += pos[n - 2][j].ss; mxx(ans, dp[n - 2][j].ff + sum); } for(int j = 0; j < pos.back().size(); j++) { mxx(ans, dp.back()[j].ss); } return ans; }

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

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int j = 0; j < pos[i - 1].size(); j++) {
      |                  ~~^~~~~~~~~~~~~~~~~~~
fish.cpp:40:27: error: no matching function for call to 'mxx(int&, long long int&)'
   40 |    mxx(mx, dp[i - 1][j].ss);
      |                           ^
fish.cpp:22:6: note: candidate: 'template<class T> void mxx(T&, T)'
   22 | void mxx(T &a, T b) {
      |      ^~~
fish.cpp:22:6: note:   template argument deduction/substitution failed:
fish.cpp:40:27: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   40 |    mxx(mx, dp[i - 1][j].ss);
      |                           ^
fish.cpp:43:29: error: no matching function for call to 'max(long long int&, int&)'
   43 |    dp[i][j].ff = max(ans, mx);
      |                             ^
In file included from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.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:
fish.cpp:43:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   43 |    dp[i][j].ff = max(ans, mx);
      |                             ^
In file included from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.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:
fish.cpp:43:29: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   43 |    dp[i][j].ff = max(ans, mx);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:2:
/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:
fish.cpp:43:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |    dp[i][j].ff = max(ans, mx);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:2:
/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:
fish.cpp:43:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |    dp[i][j].ff = max(ans, mx);
      |                             ^
fish.cpp:46:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    while(l < pos[i - 1].size() && pos[i - 1][l].ff < pos[i][j].ff) {
      |          ~~^~~~~~~~~~~~~~~~~~~
fish.cpp:76:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |  for(int j = 0; j < pos.back().size(); j++) {
      |                 ~~^~~~~~~~~~~~~~~~~~~