Created
September 16, 2018 09:22
-
-
Save sr6033/aca205ebdd0ea1ec396d62668ff799d2 to your computer and use it in GitHub Desktop.
STL implementation of heapsort algorithm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main() | |
| { | |
| int n, m; | |
| cin >> n >> m; | |
| char mat[n][m]; | |
| for(int i = 0; i < n; i++) | |
| for(int j = 0; j < m; j++) | |
| cin >> mat[i][j]; | |
| int c = 0; | |
| int row[n][m], col[n][m]; | |
| for(int i = 0; i < n; i++) | |
| { | |
| for(int j = 0; j < m; j++) | |
| { | |
| row[i][j] = 0; | |
| col[i][j] = 0; | |
| } | |
| } | |
| if(mat[0][m-1] == '.') | |
| row[0][m-1] = 1; | |
| for(int i = 0; i < n; i++) | |
| { | |
| for(int j = m-1; j >= 0; j--) | |
| { | |
| if(j != m-1 && mat[i][j+1] == '.') | |
| { | |
| if(mat[i][j] == '.') | |
| row[i][j] = row[i][j+1] + 1; | |
| } | |
| else | |
| if(mat[i][j] == '.') | |
| row[i][j] = 1; | |
| else | |
| row[i][j] = 0; | |
| } | |
| } | |
| if(mat[0][0] == '.') | |
| col[0][0] = 1; | |
| for(int i = 0; i < m; i++) | |
| { | |
| for(int j = 0; j < n; j++) | |
| { | |
| if(j != 0 && mat[j-1][i] == '.') | |
| { | |
| if(mat[j][i] == '.') | |
| col[j][i] = col[j-1][i] + 1; | |
| } | |
| else | |
| if(mat[j][i] == '.') | |
| col[j][i] = 1; | |
| else | |
| col[j][i] = 0; | |
| } | |
| } | |
| int large = 0; | |
| for(int i = 0; i < n; i++) | |
| { | |
| int sum = 0; | |
| for(int j = 0; j < m; j++) | |
| { | |
| if(i != 0 && j != m-1 && mat[i][j-1] == '*' && mat[i+1][j] == '*') | |
| { | |
| sum = row[i][j] + col[i][j] - 1; | |
| } | |
| else | |
| if(i == n-1 && j != 0 && mat[i][j-1] == '*') | |
| sum = row[i][j] + col[i][j] - 1; | |
| else | |
| { | |
| if(i == n-1 && j == 0) | |
| sum = row[i][j] + col[i][j] - 1; | |
| } | |
| } | |
| if(large < sum) | |
| large = sum; | |
| } | |
| if(large != 0) | |
| cout << "YES" << endl << large << endl; | |
| else | |
| cout << "NO" << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment