Submission #1008324

#TimeUsernameProblemLanguageResultExecution timeMemory
1008324AmrSoccer Stadium (IOI23_soccer)C++17
0 / 100
2 ms1628 KiB
#include "soccer.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; using namespace std; #define F first #define S second #define sz size() #define all(x) (x).begin(), (x).end() const int N = 32; ll n; vector<vector<int> > a; ll dp[N][N][N][2]; ll pre[N][N]; int biggest_stadium(int N, std::vector<std::vector<int>> F) { n = N, a = F; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) pre[i][j] = pre[i][j-1]+a[i-1][j-1]; //for(int i = 1; i <= n; i++) {for(int j = 1; j <= n;j++) cout << pre[i][j] << " "; cout << endl;} // base case for(int r = 1; r <= n; r++) for(int i = 1; i <= n; i++) for(int j = i; j <= n ;j++) { ll cnt = pre[r][j]-pre[r][i-1]; if(cnt>0) continue; dp[r][i][j][0] = j-i+1; // cout << dp[1][i][j][0] << " "; } for(int r = 2; r<= n; r++) for(int i2 = 1; i2 <= n; i2++) { for(int j2 = i2; j2 <= n; j2++) { ll cnt = pre[r-1][j2]-pre[r-1][i2-1]; if(cnt>0) continue; for(int i = 1; i <= n; i++) { for(int j =i ; j <= n; j++) { cnt = pre[r][j]-pre[r][i-1]; if(cnt>0) continue; // if(i==2&&j==5&&r==2&&i2==1&&j2==5) cout << dp[r-1][i2][j2][0] << endl; if(i2>=i&&j2<=j) // prev is sub from me {dp[r][i][j][0] = max(dp[r][i][j][0],dp[r-1][i2][j2][0]+j-i+1); dp[r][i][j][1] = max(dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1); } if(i2<=i&&j2>=j) dp[r][i][j][1] = max({dp[r][i][j][1],dp[r-1][i2][j2][0]+j-i+1,dp[r-1][i2][j2][1]+j-i+1}); } } } } // cout << dp[2][3][4][1] << endl; ll best = 0; for(int r = 1; r <= n; r++) for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) //if(dp[r][i][j][1]==21) cout<<r << i << " " << j << endl; best = max({best,dp[r][i][j][0],dp[r][i][j][1]}); } return best; } /* 5 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 */
#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...