Submission #1069328

#TimeUsernameProblemLanguageResultExecution timeMemory
1069328beaconmcCatfish Farm (IOI22_fish)C++17
9 / 100
1046 ms141908 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) const ll maxn = 100005; unordered_set<ll> fish[maxn]; map<basic_string<ll>, ll> weights; ll dp[8][8][maxn]; unordered_set<ll> temppos[maxn]; basic_string<ll> possibles[maxn]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { FOR(i,0,8){ FOR(j,0,8){ FOR(k,0,maxn){ dp[i][j][k] = 0; } } } FOR(i,0,maxn) temppos[i].insert(0); FOR(i,0,M){ Y[i]++; fish[X[i]].insert(Y[i]); weights[{X[i], Y[i]}] = W[i]; if (X[i] > 0) temppos[X[i]-1].insert(Y[i]); temppos[X[i]+1].insert(Y[i]); temppos[X[i]].insert(Y[i]); } FOR(i,0,maxn){ for (auto&k : temppos[i]) possibles[i].push_back(k); } FOR(i,0,maxn) sort(possibles[i].begin(), possibles[i].end()); FOR(k,0,N){ FOR(X,0,8){ FOR(Y,0,8){ ll i=0,j=0; if (k>=2 && possibles[k-2].size() <= X) continue; else if (k>=2) i = possibles[k-2][X]; if (k>=1 && possibles[k-1].size() <= Y) continue; else if (k>=1) j = possibles[k-1][Y]; ll temp = 0; FOR(Z, 0, 8){ if (possibles[k].size() <= Z) continue; ll height = possibles[k][Z]; if (fish[k+1].count(height)) temp += weights[{k+1, height}]; if (fish[k].count(height) && j>=height) temp -= weights[{k, height}]; if (k>0 && fish[k-1].count(height) && i < height && j<height) temp += weights[{k-1, height}]; dp[Y][Z][k+1] = max(dp[Y][Z][k+1], dp[X][Y][k] + temp); } } } } ll ans = 0; FOR(i,0,8){ FOR(j,0,8){ FOR(k,0,N+1){ ans = max(ans, dp[i][j][k]); //if (dp[i][j][k]==11) cout << i << " " << j << " " << k << endl; } } } return ans; }

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:56:51: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   56 |                 if (k>=2 && possibles[k-2].size() <= X) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
fish.cpp:58:51: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   58 |                 if (k>=1 && possibles[k-1].size() <= Y) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
fish.cpp:65:45: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   65 |                     if (possibles[k].size() <= Z) continue;
      |                         ~~~~~~~~~~~~~~~~~~~~^~~~
#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...