Submission #8423

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
84232014-09-13 18:12:42tncks0121On grid (kriii2_O)C++98
4 / 4
44 ms2140 KiB
#include <cstdio>
#include <algorithm>
using namespace std;
int R, C;
int A[300][300], S[300][300];
int Table[300][300];
int sumA (int x1, int y1, int x2, int y2) {
return S[x2][y2] - S[x2][y1-1] - S[x1-1][y2] + S[x1-1][y1-1];
}
int main() {
scanf("%d%d", &R, &C);
for(int i = 0; i < R; i++) {
for(int j = 0; j < C; j++) {
scanf("%d", &A[i][j]);
if(i == 0 && j == 0) S[i][j] = A[i][j];
else if(i == 0) S[i][j] = S[i][j-1] + A[i][j];
else if(j == 0) S[i][j] = S[i-1][j] + A[i][j];
else S[i][j] = S[i-1][j] + S[i][j-1] - S[i-1][j-1] + A[i][j];
}
}
Table[0][0] = A[0][0];
for(int i = 1; i < R; i++) Table[i][0] = Table[i-1][0] + A[i][0];
for(int j = 1; j < C; j++) Table[0][j] = Table[0][j-1] + A[0][j];
for(int i = 1; i < R; i++) for(int j = 1; j < C; j++) Table[i][j] = sumA(0,0,i,j);
/*for(int i = 1; i < R; i++) for(int j = 1; j < C; j++) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...