Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class GogoXCake {
  6. public:
  7. string solve(vector<string> cake, vector<string> cutter) {
  8. int n = cake.size(), m = cake[0].length();
  9. int p = cutter.size(), q = cutter[0].length();
  10.  
  11. for (int i = 0; i + p <= n; ++i) {
  12. for (int j = 0; j + q <= m; ++j) {
  13. bool ok = true;
  14. for (int a = 0; a < p && ok; ++a) {
  15. for (int b = 0; b < q && ok; ++b) {
  16. if (cutter[a][b] == '.' && cake[i + a][j + b] == 'X') ok = false;
  17. }
  18. }
  19. if (!ok) continue;
  20.  
  21. for (int a = 0; a < p; ++a) {
  22. for (int b = 0; b < q; ++b) {
  23. if (cutter[a][b] == '.') cake[i + a][j + b] = 'X';
  24. }
  25. }
  26. }
  27. }
  28.  
  29. for (int i = 0; i < n; ++i) {
  30. for (int j = 0; j < m; ++j) {
  31. if (cake[i][j] == '.') return "NO";
  32. }
  33. }
  34. return "YES";
  35. }
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement