fork download
  1. // SAVE PALESTINE
  2. // SAVE THE MUSLIMS
  3. #include <bits/stdc++.h>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6. using namespace std;
  7. #define ll long long
  8. #define endl '\n'
  9. #define all(x) x.begin(), x.end()
  10. #define rall(x) x.rbegin(), x.rend()
  11. #define mem(a, b) memset(a, b, sizeof(a))
  12. #define read(x) \
  13.   for (auto &it : x) \
  14.   cin >> it;
  15. const int MOD = 1e9 + 7;
  16. const int N = 1e5 + 7;
  17. #ifndef ONLINE_JUDGE
  18. #include "template.cpp"
  19. #else
  20. #define debug(...)
  21. #define debugArr(...)
  22. #endif
  23. typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
  24.  
  25. /*
  26. unordered_map<ll, ll> mp1;
  27. mp.reserve(1024);
  28. mp.max_load_factor(0.25);
  29. */
  30. ll n, m;
  31. vector<string> s;
  32. bool valid(ll l, ll r)
  33. {
  34. if (l < 0 || l >= n || r < 0 || r >= m || s[l][r] == '.')
  35. {
  36. return 0;
  37. }
  38.  
  39. return 1;
  40. }
  41.  
  42. int32_t main()
  43. {
  44. ios::sync_with_stdio(false);
  45. cin.tie(NULL);
  46.  
  47. cin >> n >> m;
  48. s.resize(n);
  49.  
  50. for (int i = 0; i < n; i++)
  51. {
  52. cin >> s[i];
  53. }
  54. vector<tuple<ll, ll, ll>> ans;
  55.  
  56. vector<vector<ll>> vis(n, vector<ll>(m));
  57.  
  58. for (int i = 0; i < n; i++)
  59. {
  60. for (int j = 0; j < m; j++)
  61. {
  62. ll f = 1;
  63. while (valid(i, j + f) && valid(i, j - f) && valid(i + f, j) && valid(i - f, j))
  64. {
  65.  
  66. vis[i][j + f] = 1;
  67. vis[i + f][j] = 1;
  68. vis[i][j - f] = 1;
  69. vis[i - f][j] = 1;
  70. f++;
  71. }
  72.  
  73. if (f > 1)
  74. {
  75. vis[i][j] = 1;
  76. ans.push_back({i, j, f - 1});
  77. }
  78. }
  79. }
  80.  
  81. ll k = 0;
  82.  
  83. for (int i = 0; i < n; i++)
  84. {
  85. for (int j = 0; j < m; j++)
  86. {
  87. if (s[i][j] == '*' && !vis[i][j])
  88. {
  89. k = 1;
  90. break;
  91. }
  92. }
  93.  
  94. if (k)
  95. break;
  96. }
  97.  
  98. if (k)
  99. cout << -1 << endl;
  100.  
  101. else
  102. {
  103.  
  104. cout << ans.size() << endl;
  105.  
  106. for (auto [a, b, c] : ans)
  107. {
  108. cout << a + 1 << " " << b + 1 << " " << c << endl;
  109. }
  110. }
  111.  
  112. return 0;
  113. }
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
0