Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream fin("asciimat.in");
- int c, k, x, colmx;
- char s[3005], *p;
- int mat[3005][3005];
- int main()
- {
- fin >> c;
- fin.get();
- fin.getline(s, 3005);
- fin >> k;
- int linie = 1;
- p = strtok(s, " ");
- while(p){
- if(strlen(p) > colmx)
- colmx = strlen(p);
- int col = 7;
- for(int i = 0 ; i < strlen(p); i++){
- x = p[i];
- int h = 1;
- while(x){
- mat[linie][col-h+1] = x%2;
- h++;
- x /= 2;
- }
- col += 7;
- }
- linie++;
- p = strtok(NULL, " ");
- }
- colmx = colmx*7;
- int l = 0, nr = 0;
- for(int i =1; i < linie; i++)
- for(int j = 1; j <= colmx; j++){
- if(mat[i][j] == 1)
- mat[i][j] += min(mat[i-1][j], min(mat[i-1][j-1],mat[i][j-1]));
- if(mat[i][j] > l)
- l = mat[i][j];
- if(mat[i][j] >= k)
- nr++;
- }
- if(c == 1)
- cout << l;
- else
- cout << nr;
- // for(int i = 1; i < linie; i++){
- // for(int j = 1; j <= colmx; j++)
- // cout << mat[i][j] << " ";
- // cout << "\n";
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement