제출 #720037

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
7200372023-04-07 10:01:35a_aguilo건포도 (IOI09_raisins)C++14
100 / 100
1612 ms29376 KiB
#include<bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<vector<vector<int>>>> DP;
//DP[x1][x2][y1][y2];
vector<vector<int>> preSum, raisinsMap;
int getSum(int x1, int x2, int y1, int y2){
int ans;
if(x1 <= 0){
if(y1 <= 0) ans = preSum[x2][y2];
else ans = preSum[x2][y2] - preSum[x2][y1-1];
}else{
if(y1 <= 0) ans = preSum[x2][y2]-preSum[x1-1][y2];
else{
ans = preSum[x2][y2] + preSum[x1-1][y1-1] - preSum[x2][y1-1] - preSum[x1-1][y2];
}
}
return ans;
}
int solve(int x1, int x2, int y1, int y2){
if(x1 == x2 && y1 == y2) return 0;
if(DP[x1][x2][y1][y2] != -1) return DP[x1][x2][y1][y2];
int payNow = getSum(x1, x2, y1, y2);
if(x1 == x2){
int ans = solve(x1, x2, y1+1, y2);
for(int dist = 1; (y1 + dist + 1) <= y2; ++dist){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...