Artifact Content
Not logged in

Artifact 18ebe86cb67a2579ff136ec4aa921e4373716a39


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
#ifdef __GNUC__
#include <ext/hash_map>
#define unordered_map __gnu_cxx::hash_map
#else
#include <unordered_map>
#endif
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class GogoXCake { public:
	string solve(vector <string> cake, vector <string> cutter)
	{
		const int theX = cutter[0].find('.');

		for(int y=0; y<cake.size(); ++y)
		for(int x=0; x<cake[y].size(); ++x) {
			if( cake[y][x] == '.' ) {
				if( !place(cake, y, x-theX, cutter) )
					return "NO";
			}
		}
		return "YES";
	}

	bool place(vector <string>& cake, int Y, int X, const vector <string>& cutter)
	{
		for(int y=0; y<cutter.size(); ++y)
		for(int x=0; x<cutter[y].size(); ++x)
		{
			int yy = Y+y, xx = X+x;
			if( yy<0 || cake.size()<=yy || xx<0 || cake[0].size()<=xx )
				return false;
			if( cutter[y][x]=='.' ) {
				if( cake[yy][xx]=='X' )
					return false;
				cake[yy][xx] = 'X';
			}
		}
		return true;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, GogoXCake().solve(cake, cutter));}
int main(){

CASE(0)
	string cake_[] = {"X.X"
,"..."
,"..."
,"X.X"};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {".X"
,".."
,"X."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "YES"; 
END
CASE(1)
	string cake_[] = {"..XX"
,"...X"
,"X..."
,"XX.."};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {".."
,".."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "NO"; 
END
CASE(2)
	string cake_[] = {"...X..."};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {"..."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "YES"; 
END
CASE(3)
	string cake_[] = {".X."
,"X.X"
,".X."};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {"."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "YES"; 
END
CASE(4)
	string cake_[] = {"XXXXXXX"
,"X.....X"
,"X.....X"
,"X.....X"
,"XXXXXXX"};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {".X."
,"XXX"
,".X."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "NO"; 
END
CASE(5)
	string cake_[] = {".."
,"X."
,".X"};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {".."
,".X"
,"X."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "NO"; 
END
CASE(6)
	string cake_[] = {"X.."
,".XX"
,".XX"};
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = {".XX"
,".XX"
,"X.."};
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = "NO"; 
END
/*
CASE(7)
	string cake_[] = ;
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = ;
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = ; 
END
CASE(8)
	string cake_[] = ;
	  vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 
	string cutter_[] = ;
	  vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 
	string _ = ; 
END
*/
}
// END CUT HERE