Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("asciimat.in");
- ofstream fout("asciimat.out");
- int a[302][702];
- char s[3001];
- int t, k, n, poz, lin = 0, m, lung, rez_t2, rez_maxx;
- bitset <7> caracter;
- void copiaza()
- {
- int fin = poz + 6, poz1 = 6;
- for (; poz <= fin; ++poz)
- {
- a[n][poz] = caracter[poz1--];
- }
- poz = fin + 1;
- }
- int main()
- {
- fin >> t;
- fin.ignore();
- fin.getline(s, 3000);
- char *p = strtok(s, " ");
- while (p != NULL)
- {
- lung = strlen(p);
- poz = 1;
- n++;
- if (7 * lung > m) m = 7 * lung;
- for (int i = 0; i < lung; ++i)
- {
- caracter = p[i];
- copiaza();
- }
- p = strtok(NULL, " ");
- }
- fin >> k;
- for (int i = 1; i <= n; ++i)
- {
- for (int j = 1; j <= m; ++j)
- {
- if (a[i][j]) a[i][j] = min(a[i - 1][j - 1], min(a[i - 1][j], a[i][j - 1])) + 1;
- if (a[i][j] > rez_maxx)
- rez_maxx = a[i][j];
- }
- }
- for (int i = 1; i <= n; ++i)
- {
- for (int j = 1; j <= m; ++j)
- {
- if (a[i][j] >= k) rez_t2++;
- }
- }
- if (t == 1)
- fout << rez_maxx;
- else
- fout << rez_t2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement