Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("asciimat.in");
  6. ofstream fout("asciimat.out");
  7.  
  8. int a[302][702];
  9. char s[3001];
  10. int t, k, n, poz, lin = 0, m, lung, rez_t2, rez_maxx;
  11.  
  12. bitset <7> caracter;
  13.  
  14. void copiaza()
  15. {
  16. int fin = poz + 6, poz1 = 6;
  17. for (; poz <= fin; ++poz)
  18. {
  19. a[n][poz] = caracter[poz1--];
  20. }
  21. poz = fin + 1;
  22. }
  23.  
  24. int main()
  25. {
  26. fin >> t;
  27. fin.ignore();
  28. fin.getline(s, 3000);
  29. char *p = strtok(s, " ");
  30. while (p != NULL)
  31. {
  32. lung = strlen(p);
  33. poz = 1;
  34. n++;
  35. if (7 * lung > m) m = 7 * lung;
  36. for (int i = 0; i < lung; ++i)
  37. {
  38. caracter = p[i];
  39. copiaza();
  40. }
  41. p = strtok(NULL, " ");
  42. }
  43. fin >> k;
  44. for (int i = 1; i <= n; ++i)
  45. {
  46. for (int j = 1; j <= m; ++j)
  47. {
  48. if (a[i][j]) a[i][j] = min(a[i - 1][j - 1], min(a[i - 1][j], a[i][j - 1])) + 1;
  49. if (a[i][j] > rez_maxx)
  50. rez_maxx = a[i][j];
  51. }
  52. }
  53. for (int i = 1; i <= n; ++i)
  54. {
  55. for (int j = 1; j <= m; ++j)
  56. {
  57. if (a[i][j] >= k) rez_t2++;
  58. }
  59. }
  60. if (t == 1)
  61. fout << rez_maxx;
  62. else
  63. fout << rez_t2;
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement