제출 #652799

#제출 시각아이디문제언어결과실행 시간메모리
652799Lobo메기 농장 (IOI22_fish)C++17
14 / 100
587 ms36704 KiB
#include "fish.h" #include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define fr first #define sc second #define all(x) x.begin(),x.end() const int maxn = 1e3+10; const int maxqh = 12; const int inf = 1e18+10; int n, m, dp[maxn][maxqh][maxqh], pf[maxn][maxn]; vector<pair<int,int>> fish[maxn]; // fishs from column i vector<int> hr[maxn]; // important heights from column i, the ones that can be chosen long long max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) { n = N; m = M; for(int i = 0; i < m; i++) { fish[X[i]+1].pb(mp(Y[i]+1,W[i])); hr[X[i]+1].pb(Y[i]); } for(int i = 0; i <= n; i++) { hr[i].pb(0); hr[i].pb(n); sort(all(hr[i])); sort(all(fish[i])); hr[i].erase(unique(all(hr[i])),hr[i].end()); for(auto aux : fish[i]) { int y = aux.fr; int w = aux.sc; pf[i][y]+= w; } // Do a prefix sum on the weight of the fishs int it = 0; for(int j = 1; j <= n; j++) { pf[i][j]+= pf[i][j-1]; } } // dp[i][h1][h] = until i and with h[i-1] = hr[i-1][h1] and h[i] = hr[i][h-1] // dp[1][0][x] = 0; for(int i = 0; i < hr[i].size(); i++) dp[1][0][i] = 0; for(int i = 2; i <= n; i++) { for(int h1 = 0; h1 < hr[i-1].size(); h1++) { for(int h = 0; h < hr[i].size(); h++) { dp[i][h1][h] = 0; int plus10 = 0; // fishs that 1 catchs in 0 // for(auto aux : fish[i]) { // int y = aux.fr; // int w = aux.sc; // if(y > hr[i][h] && y <= hr[i-1][h1]) plus10+= w; // } plus10 = max((int) 0,pf[i][hr[i-1][h1]]-pf[i][hr[i][h]]); for(int h2 = 0; h2 < hr[i-2].size(); h2++) { int plus01 = 0; // fishs that 0 catchs in 1 and had not been caught by 2 for(auto aux : fish[i-1]) { int y = aux.fr; int w = aux.sc; if(y > hr[i-1][h1] && y <= hr[i][h] && y > hr[i-2][h2]) plus01+= w; } dp[i][h1][h] = max(dp[i][h1][h],dp[i-1][h2][h1]+plus01 + plus10); } } } } int ans = 0; for(int h = 0; h < hr[n].size(); h++) { for(int h1 = 0; h1 < hr[n-1].size(); h1++) { ans = max(ans,dp[n][h1][h]); } } return ans; }

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

fish.cpp: In function 'long long int max_weights(int32_t, int32_t, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:41:13: warning: unused variable 'it' [-Wunused-variable]
   41 |         int it = 0;
      |             ^~
fish.cpp:50:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < hr[i].size(); i++) dp[1][0][i] = 0;
      |                    ~~^~~~~~~~~~~~~~
fish.cpp:52:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int h1 = 0; h1 < hr[i-1].size(); h1++) {
      |                         ~~~^~~~~~~~~~~~~~~~
fish.cpp:53:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             for(int h = 0; h < hr[i].size(); h++) {
      |                            ~~^~~~~~~~~~~~~~
fish.cpp:65:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |                 for(int h2 = 0; h2 < hr[i-2].size(); h2++) {
      |                                 ~~~^~~~~~~~~~~~~~~~
fish.cpp:80:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int h = 0; h < hr[n].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~
fish.cpp:81:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |         for(int h1 = 0; h1 < hr[n-1].size(); h1++) {
      |                         ~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...