Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- using namespace std;
- class GogoXCake {
- public:
- string solve(vector<string> cake, vector<string> cutter) {
- int n = cake.size(), m = cake[0].length();
- int p = cutter.size(), q = cutter[0].length();
- for (int i = 0; i + p <= n; ++i) {
- for (int j = 0; j + q <= m; ++j) {
- bool ok = true;
- for (int a = 0; a < p && ok; ++a) {
- for (int b = 0; b < q && ok; ++b) {
- if (cutter[a][b] == '.' && cake[i + a][j + b] == 'X') ok = false;
- }
- }
- if (!ok) continue;
- for (int a = 0; a < p; ++a) {
- for (int b = 0; b < q; ++b) {
- if (cutter[a][b] == '.') cake[i + a][j + b] = 'X';
- }
- }
- }
- }
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < m; ++j) {
- if (cake[i][j] == '.') return "NO";
- }
- }
- return "YES";
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement