[cpp]

#include <iostream>

#include <vector>

using namespace std;

vector<vector<char> > matrix(100,vector<char>(100));

long int count;

int calc3(int x, int x2, int y, int y2)

{

for(int i = x; i <= x2; i++)

{

count++;

if(matrix

*[y2] != '1')*

return 0;

}

return 1;

}

int calc2(int tamY, int x, int x2, int y)

{

int sum = 0;

int fitaY;

for(fitaY = y; fitaY < tamY; fitaY++)

{

if(matrix[x][fitaY] != '1' || matrix[x2][fitaY] != '1')

break;

}

for(int j = y; j < fitaY; j++)

sum += calc3(x,x2,y,j);

return sum;

}

int calc(int tamX, int tamY, int x, int y)

{

int sum = 0;

int fitaX;

for(fitaX = x; fitaX < tamX; fitaX++)

{

if(matrix[fitaX][y] != '1')

break;

}

for(int i = x; i < fitaX; i++)

sum += calc2(tamY,x,i,y);

return sum;

}

int proces(int x, int y)

{

int sum = 0;

count = 0;

for(int i = 0; i < x; i++)

{

for(int j = 0; j < y; j++)

cin >> matrix

return 0;

}

return 1;

}

int calc2(int tamY, int x, int x2, int y)

{

int sum = 0;

int fitaY;

for(fitaY = y; fitaY < tamY; fitaY++)

{

if(matrix[x][fitaY] != '1' || matrix[x2][fitaY] != '1')

break;

}

for(int j = y; j < fitaY; j++)

sum += calc3(x,x2,y,j);

return sum;

}

int calc(int tamX, int tamY, int x, int y)

{

int sum = 0;

int fitaX;

for(fitaX = x; fitaX < tamX; fitaX++)

{

if(matrix[fitaX][y] != '1')

break;

}

for(int i = x; i < fitaX; i++)

sum += calc2(tamY,x,i,y);

return sum;

}

int proces(int x, int y)

{

int sum = 0;

count = 0;

for(int i = 0; i < x; i++)

{

for(int j = 0; j < y; j++)

cin >> matrix

*[j];*

}

for(int i2 = 0; i2 < x; i2++)

{

for(int j2 = 0; j2 < y; j2++)

{

if(matrix[i2][j2] == '1')

sum += calc(x,y,i2,j2);

}

}

//cout << count << endl;

return sum;

}

int main()

{

int x, y;

while(cin >> x >> y)

cout << proces(x,y) << endl;

return 0;

}

[/cpp]}

for(int i2 = 0; i2 < x; i2++)

{

for(int j2 = 0; j2 < y; j2++)

{

if(matrix[i2][j2] == '1')

sum += calc(x,y,i2,j2);

}

}

//cout << count << endl;

return sum;

}

int main()

{

int x, y;

while(cin >> x >> y)

cout << proces(x,y) << endl;

return 0;

}

[/cpp]