Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int row, col;
- int main(){
- scanf("%d %d", &row, &col);
- int memo[row + 1][col + 1];
- char m[col + 10];
- //vector<vector<int>> memo(row + 1, vector<int>(col + 1, 0));
- vector<int> erode(max(row, col) + 1, 0);
- int cnt1 = 0;
- for(int i = 1; i <= row; ++i){
- scanf(" %s", &m);
- for(int j = 1; j <= col; ++j){
- if(m[j - 1] == '0'){
- memo[i][j] = 0;
- continue;
- }
- ++cnt1;
- if(i == 1 || j == 1){
- memo[i][j] = 1;
- ++erode[1];
- } else {
- memo[i][j] = min(memo[i - 1][j - 1], min(memo[i - 1][j], memo[i][j - 1])) + 1;
- ++erode[memo[i][j]];
- }
- }
- }
- for(int i = 0; i <= min(row, col) - 1; ++i){
- cout << cnt1 - erode[i] << "\n";
- cnt1 -= erode[i];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement