Debugging Problem 611 C

Правка en1, от BanazadehAria, 2019-06-14 12:10:31

This is my code for 611C problem on code forces

And this is my code but i dont know why it is wrong?

#include<bits/stdc++.h>
using namespace std;

const int MAXN = 1e3;
char graph[MAXN][MAXN];
int vertic[MAXN][MAXN],hort[MAXN][MAXN];

int main()
{
    int row,col;cin >> row >> col;
    for(int i=0;i<row;++i){
        for(int j=0;j<col;++j){
            cin >> graph[i][j];
        }
    }
    // Now we precompute all of them
    vertic[0][0]=0;
    for(int i=1;i<row;++i){
        vertic[0][i] = vertic[0][i-1];
        if(graph[0][i] == graph[0][i-1] && graph[0][i]=='.') ++vertic[0][i];
    }
    for(int i=1;i<col;++i){
        hort[i][0] = hort[i-1][0];
        if(graph[i][0] == graph[i-1][0] && graph[i][0]=='.') ++hort[i][0];
    }
    for(int i=1;i<row;++i){
        for(int j=1;j<col;++j){
            vertic[i][j] = vertic[i-1][j] + vertic[i][j-1] - vertic[i-1][j-1] + (graph[i][j-1]=='.' && graph[i][j]=='.');
            hort[i][j] = hort[i-1][j] + hort[i][j-1] - hort[i-1][j-1] + (graph[i-1][j] =='.' && graph[i][j]=='.');
        }
    }
    int q;cin >> q;
    for(int i=0;i<q;++i){
        int r1,c1,r2,c2;cin >> r1 >> c1 >> r2 >> c2;--r1;--c1;--r2;--c2;
        int vecOne = vertic[r2][c2] - vertic[r2][c1] - vertic[r1][c2] + vertic[r1][c1];
        int horOne = hort[r2][c2] - hort[r2][c1] - hort[r1][c2] + hort[r1][c1];
        cout << vecOne + horOne << endl;
    }
}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский BanazadehAria 2019-06-14 12:10:31 1477 Initial revision (published)