Submission #1070588

#TimeUsernameProblemLanguageResultExecution timeMemory
1070588beaconmcCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 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 = 305; bool fish[maxn][maxn]; ll weights[maxn][maxn];a// #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 = 3005; bool fish[maxn][maxn]; ll weights[maxn][maxn]; ll p[maxn][maxn]; ll dp[maxn][maxn][2]; ll pref[maxn][maxn][2]; ll pref2[maxn][maxn][2]; ll suff[maxn][maxn][2]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { FOR(i,0,maxn){ FOR(j,0,maxn){ weights[i][j] = 0; fish[i][j] = false; dp[i][j][0] = 0; dp[i][j][1] = 0; pref[i][j][0] = 0; pref[i][j][1] = 0; pref2[i][j][0] = 0; pref2[i][j][1] = 0; suff[i][j][0] = 0; suff[i][j][1] = 0; } } FOR(i,0,M){ Y[i]++; fish[X[i]][Y[i]] = true; weights[X[i]][Y[i]] = W[i]; } FOR(i,0,maxn){ p[i][0] = 0; FOR(j,1,maxn){ p[i][j] = p[i][j-1] + weights[i][j]; } } FOR(i,0,N+1){ FOR(j,0,N+1){ FOR(k,0,2){ if (i<2) continue; ll temp = 0; ll add = 0; if (k==0){ temp = max(temp, suff[i-1][j+1][0] - p[i-1][j]); temp = max(temp, suff[i-1][j+1][1] - p[i-1][j]); // FOR(p,j+1,N+1){ // if (fish[i-1][p]) add += weights[i-1][p]; // temp = max(temp, dp[i-1][p][0] + add); // temp = max(temp, dp[i-1][p][1] + add); // } }else{ temp = max(temp, pref[i-1][j][0]); temp = max(temp, pref[i-1][j][1] + p[i-2][j]); // FOR(p,0,j+1) if (fish[i-2][p]) add += weights[i-2][p]; // FOR(p,0,j+1){ // if (fish[i-2][p]) add -= weights[i-2][p]; // temp = max(temp, dp[i-1][p][0]); // temp = max(temp, dp[i-1][p][1] + add); // } } dp[i][j][k] = temp; } } FOR(k,0,2){ ll tempadd = 0; ll tempadd2 = 0; FOR(j,0,N+1){ tempadd += weights[i][j]; suff[i][j][k] = dp[i][j][k]+tempadd; } FOR(j,0,N+1){ if (i>1) tempadd2 -= weights[i-1][j]; pref[i][j][k] = dp[i][j][k] + tempadd2; pref2[i][j][k] = dp[i][j][k]; } FOR(j,1,N+1){ pref[i][j][k] = max(pref[i][j][k], pref[i][j-1][k]); pref2[i][j][k] = max(pref2[i][j][k], pref2[i][j-1][k]); } FORNEG(j,N,-1){ suff[i][j][k] = max(suff[i][j][k], suff[i][j+1][k]); } } } ll ans = 0; FOR(i,0,N+1) FOR(j,0,N+1)FOR(k,0,2){ //if (dp[i][j][k]==305) cout << i << " " << j << " " << k << endl; ans = max(ans, dp[i][j][k]); } return ans; } ll p[maxn][maxn]; ll dp[maxn][maxn][2]; ll pref[maxn][maxn][2]; ll pref2[maxn][maxn][2]; ll suff[maxn][maxn][2]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { FOR(i,0,maxn){ FOR(j,0,maxn){ weights[i][j] = 0; fish[i][j] = false; dp[i][j][0] = 0; dp[i][j][1] = 0; pref[i][j][0] = 0; pref[i][j][1] = 0; pref2[i][j][0] = 0; pref2[i][j][1] = 0; suff[i][j][0] = 0; suff[i][j][1] = 0; } } FOR(i,0,M){ Y[i]++; fish[X[i]][Y[i]] = true; weights[X[i]][Y[i]] = W[i]; } FOR(i,0,maxn){ p[i][0] = 0; FOR(j,1,maxn){ p[i][j] = p[i][j-1] + weights[i][j]; } } FOR(i,0,N+1){ FOR(j,0,N+1){ FOR(k,0,2){ if (i<2) continue; ll temp = 0; ll add = 0; if (k==0){ temp = max(temp, suff[i-1][j+1][0] - p[i-1][j]); temp = max(temp, suff[i-1][j+1][1] - p[i-1][j]); // FOR(p,j+1,N+1){ // if (fish[i-1][p]) add += weights[i-1][p]; // temp = max(temp, dp[i-1][p][0] + add); // temp = max(temp, dp[i-1][p][1] + add); // } }else{ temp = max(temp, pref[i-1][j][0]); temp = max(temp, pref[i-1][j][1] + p[i-2][j]); // FOR(p,0,j+1) if (fish[i-2][p]) add += weights[i-2][p]; // FOR(p,0,j+1){ // if (fish[i-2][p]) add -= weights[i-2][p]; // temp = max(temp, dp[i-1][p][0]); // temp = max(temp, dp[i-1][p][1] + add); // } } dp[i][j][k] = temp; } } FOR(k,0,2){ ll tempadd = 0; ll tempadd2 = 0; FOR(j,0,N+1){ tempadd += weights[i][j]; suff[i][j][k] = dp[i][j][k]+tempadd; } FOR(j,0,N+1){ if (i>1) tempadd2 -= weights[i-1][j]; pref[i][j][k] = dp[i][j][k] + tempadd2; pref2[i][j][k] = dp[i][j][k]; } FOR(j,1,N+1){ pref[i][j][k] = max(pref[i][j][k], pref[i][j-1][k]); pref2[i][j][k] = max(pref2[i][j][k], pref2[i][j-1][k]); } FORNEG(j,N,-1){ suff[i][j][k] = max(suff[i][j][k], suff[i][j+1][k]); } } } ll ans = 0; FOR(i,0,N+1) FOR(j,0,N+1)FOR(k,0,2){ //if (dp[i][j][k]==305) cout << i << " " << j << " " << k << endl; ans = max(ans, dp[i][j][k]); } return ans; }

Compilation message (stderr)

fish.cpp:16:24: error: 'a' does not name a type
   16 | ll weights[maxn][maxn];a// #pragma GCC optimize("O3,unroll-loops")
      |                        ^
fish.cpp:27:10: error: redefinition of 'const ll maxn'
   27 | const ll maxn = 3005;
      |          ^~~~
fish.cpp:12:10: note: 'const ll maxn' previously defined here
   12 | const ll maxn = 305;
      |          ^~~~
fish.cpp:30:6: error: redefinition of 'bool fish [305][305]'
   30 | bool fish[maxn][maxn];
      |      ^~~~
fish.cpp:15:6: note: 'bool fish [305][305]' previously declared here
   15 | bool fish[maxn][maxn];
      |      ^~~~
fish.cpp:31:4: error: redefinition of 'll weights [305][305]'
   31 | ll weights[maxn][maxn];
      |    ^~~~~~~
fish.cpp:16:4: note: 'll weights [305][305]' previously declared here
   16 | ll weights[maxn][maxn];a// #pragma GCC optimize("O3,unroll-loops")
      |    ^~~~~~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:84:20: warning: unused variable 'add' [-Wunused-variable]
   84 |                 ll add = 0;
      |                    ^~~
fish.cpp: At global scope:
fish.cpp:152:4: error: redefinition of 'll p [305][305]'
  152 | ll p[maxn][maxn];
      |    ^
fish.cpp:33:4: note: 'll p [305][305]' previously declared here
   33 | ll p[maxn][maxn];
      |    ^
fish.cpp:156:4: error: redefinition of 'll dp [305][305][2]'
  156 | ll dp[maxn][maxn][2];
      |    ^~
fish.cpp:37:4: note: 'll dp [305][305][2]' previously declared here
   37 | ll dp[maxn][maxn][2];
      |    ^~
fish.cpp:158:4: error: redefinition of 'll pref [305][305][2]'
  158 | ll pref[maxn][maxn][2];
      |    ^~~~
fish.cpp:39:4: note: 'll pref [305][305][2]' previously declared here
   39 | ll pref[maxn][maxn][2];
      |    ^~~~
fish.cpp:159:4: error: redefinition of 'll pref2 [305][305][2]'
  159 | ll pref2[maxn][maxn][2];
      |    ^~~~~
fish.cpp:40:4: note: 'll pref2 [305][305][2]' previously declared here
   40 | ll pref2[maxn][maxn][2];
      |    ^~~~~
fish.cpp:160:4: error: redefinition of 'll suff [305][305][2]'
  160 | ll suff[maxn][maxn][2];
      |    ^~~~
fish.cpp:41:4: note: 'll suff [305][305][2]' previously declared here
   41 | ll suff[maxn][maxn][2];
      |    ^~~~
fish.cpp:163:11: error: redefinition of 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)'
  163 | long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
      |           ^~~~~~~~~~~
fish.cpp:44:11: note: 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)' previously defined here
   44 | long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
      |           ^~~~~~~~~~~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:203:20: warning: unused variable 'add' [-Wunused-variable]
  203 |                 ll add = 0;
      |                    ^~~