Submission #966284

#TimeUsernameProblemLanguageResultExecution timeMemory
966284andrej246Catfish Farm (IOI22_fish)C++17
0 / 100
1129 ms2097152 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; #define NL '\n' #define EL cout << NL #define FOR(i,n) for(int i = 0; i < (n); i++) #define FORS(i,s,n) for(int i = (s); i < (n); i++) #define PRINTV(v) for(auto a:v) {cout << a << " ";} EL; #define PRINTVV(v) for(auto a:v) {PRINTV(a);} #define f first #define s second #define all(v) (v).begin(),(v).end() #define STRP(p) "{" << (p).f << "," << (p).s << "}" #define PRINTVP(v) for(auto a:v) {cout << STRP(a) << " ";} EL; #define PRINTVVP(v) for(auto a:v) {PRINTVP(a);} typedef long long ll; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll,ll> pl; typedef vector<pl> vpl; typedef vector<vpl> vvpl; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { vvl a(N,vl(N)); FOR(i,M) { a[X[i]][Y[i]] = W[i]; } vvl dp_up(N,vl(N,-1e18)); vvl dp_down(N,vl(N,-1e18)); FOR(i,N) { dp_up[i][0] = a[i][0]; } FOR(i,N) { FOR(j,N) { if (j >= 1) { dp_up[i][j] = max(dp_up[i][j],dp_up[i][j-1] + a[i][j]); if (i >= 1) { dp_up[i][j] = max(dp_up[i][j],dp_up[i-1][j-1] + a[i][j]); } } FORS(k,i-6,i) { if (k < 0) continue; dp_up[i][j] = max(dp_up[i][j],dp_down[k][j] + a[i][j]); } } FOR(_j,N) { ll j = N-_j-1; if (j < N-1) { dp_down[i][j] = max(dp_down[i][j],dp_down[i][j+1] + a[i][j]); if (i >= 1) { dp_down[i][j] = max(dp_down[i][j],dp_down[i-1][j+1] + a[i][j]); } } FORS(k,i-6,i-1) { if (k < 0) continue; dp_down[i][j] = max(dp_down[i][j],dp_up[k][j] + a[i][j]); } } } // PRINTVV(a); EL; // FOR(_j,N) { // ll j = N-_j-1; // FOR(i,N) { // cout << a[i][j] << " "; // } // EL; // } EL; // FOR(_j,N) { // ll j = N-_j-1; // FOR(i,N) { // cout << dp_up[i][j] << " "; // } // EL; // } EL; // FOR(_j,N) { // ll j = N-_j-1; // FOR(i,N) { // cout << dp_down[i][j] << " "; // } // EL; // } EL; ll ans = 0; FOR(i,N-1) { FOR(j,N) { ans = max(ans,dp_up[i][j]); } } FOR(j,N) { ans = max(ans,dp_up[1][j]); } FOR(i,N) { FOR(j,N) { ans = max(ans,dp_down[i][j]); } } return ans; }
#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...