15bfca2432 2012-01-31 kinaba: #include <iostream> 15bfca2432 2012-01-31 kinaba: #include <sstream> 15bfca2432 2012-01-31 kinaba: #include <iomanip> 15bfca2432 2012-01-31 kinaba: #include <vector> 15bfca2432 2012-01-31 kinaba: #include <string> 15bfca2432 2012-01-31 kinaba: #include <map> 15bfca2432 2012-01-31 kinaba: #include <set> 15bfca2432 2012-01-31 kinaba: #include <algorithm> 15bfca2432 2012-01-31 kinaba: #include <numeric> 15bfca2432 2012-01-31 kinaba: #include <iterator> 15bfca2432 2012-01-31 kinaba: #include <functional> 15bfca2432 2012-01-31 kinaba: #include <complex> 15bfca2432 2012-01-31 kinaba: #include <queue> 15bfca2432 2012-01-31 kinaba: #include <stack> 15bfca2432 2012-01-31 kinaba: #include <cmath> 15bfca2432 2012-01-31 kinaba: #include <cassert> 15bfca2432 2012-01-31 kinaba: #include <cstring> 15bfca2432 2012-01-31 kinaba: #ifdef __GNUC__ 15bfca2432 2012-01-31 kinaba: #include <ext/hash_map> 15bfca2432 2012-01-31 kinaba: #define unordered_map __gnu_cxx::hash_map 15bfca2432 2012-01-31 kinaba: #else 15bfca2432 2012-01-31 kinaba: #include <unordered_map> 15bfca2432 2012-01-31 kinaba: #endif 15bfca2432 2012-01-31 kinaba: using namespace std; 15bfca2432 2012-01-31 kinaba: typedef long long LL; 15bfca2432 2012-01-31 kinaba: typedef complex<double> CMP; 15bfca2432 2012-01-31 kinaba: 15bfca2432 2012-01-31 kinaba: class GogoXCake { public: 15bfca2432 2012-01-31 kinaba: string solve(vector <string> cake, vector <string> cutter) 15bfca2432 2012-01-31 kinaba: { 15bfca2432 2012-01-31 kinaba: const int theX = cutter[0].find('.'); 15bfca2432 2012-01-31 kinaba: 15bfca2432 2012-01-31 kinaba: for(int y=0; y<cake.size(); ++y) 15bfca2432 2012-01-31 kinaba: for(int x=0; x<cake[y].size(); ++x) { 15bfca2432 2012-01-31 kinaba: if( cake[y][x] == '.' ) { 15bfca2432 2012-01-31 kinaba: if( !place(cake, y, x-theX, cutter) ) 15bfca2432 2012-01-31 kinaba: return "NO"; 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: return "YES"; 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: 15bfca2432 2012-01-31 kinaba: bool place(vector <string>& cake, int Y, int X, const vector <string>& cutter) 15bfca2432 2012-01-31 kinaba: { 15bfca2432 2012-01-31 kinaba: for(int y=0; y<cutter.size(); ++y) 15bfca2432 2012-01-31 kinaba: for(int x=0; x<cutter[y].size(); ++x) 15bfca2432 2012-01-31 kinaba: { 15bfca2432 2012-01-31 kinaba: int yy = Y+y, xx = X+x; 15bfca2432 2012-01-31 kinaba: if( yy<0 || cake.size()<=yy || xx<0 || cake[0].size()<=xx ) 15bfca2432 2012-01-31 kinaba: return false; 15bfca2432 2012-01-31 kinaba: if( cutter[y][x]=='.' ) { 15bfca2432 2012-01-31 kinaba: if( cake[yy][xx]=='X' ) 15bfca2432 2012-01-31 kinaba: return false; 15bfca2432 2012-01-31 kinaba: cake[yy][xx] = 'X'; 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: return true; 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: }; 15bfca2432 2012-01-31 kinaba: 15bfca2432 2012-01-31 kinaba: // BEGIN CUT HERE 15bfca2432 2012-01-31 kinaba: #include <ctime> 15bfca2432 2012-01-31 kinaba: double start_time; string timer() 15bfca2432 2012-01-31 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 15bfca2432 2012-01-31 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 15bfca2432 2012-01-31 kinaba: { os << "{ "; 15bfca2432 2012-01-31 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 15bfca2432 2012-01-31 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 15bfca2432 2012-01-31 kinaba: void verify_case(const string& Expected, const string& Received) { 15bfca2432 2012-01-31 kinaba: bool ok = (Expected == Received); 15bfca2432 2012-01-31 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 15bfca2432 2012-01-31 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 15bfca2432 2012-01-31 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 15bfca2432 2012-01-31 kinaba: #define END verify_case(_, GogoXCake().solve(cake, cutter));} 15bfca2432 2012-01-31 kinaba: int main(){ 15bfca2432 2012-01-31 kinaba: 15bfca2432 2012-01-31 kinaba: CASE(0) 15bfca2432 2012-01-31 kinaba: string cake_[] = {"X.X" 15bfca2432 2012-01-31 kinaba: ,"..." 15bfca2432 2012-01-31 kinaba: ,"..." 15bfca2432 2012-01-31 kinaba: ,"X.X"}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {".X" 15bfca2432 2012-01-31 kinaba: ,".." 15bfca2432 2012-01-31 kinaba: ,"X."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "YES"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(1) 15bfca2432 2012-01-31 kinaba: string cake_[] = {"..XX" 15bfca2432 2012-01-31 kinaba: ,"...X" 15bfca2432 2012-01-31 kinaba: ,"X..." 15bfca2432 2012-01-31 kinaba: ,"XX.."}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {".." 15bfca2432 2012-01-31 kinaba: ,".."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "NO"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(2) 15bfca2432 2012-01-31 kinaba: string cake_[] = {"...X..."}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {"..."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "YES"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(3) 15bfca2432 2012-01-31 kinaba: string cake_[] = {".X." 15bfca2432 2012-01-31 kinaba: ,"X.X" 15bfca2432 2012-01-31 kinaba: ,".X."}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {"."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "YES"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(4) 15bfca2432 2012-01-31 kinaba: string cake_[] = {"XXXXXXX" 15bfca2432 2012-01-31 kinaba: ,"X.....X" 15bfca2432 2012-01-31 kinaba: ,"X.....X" 15bfca2432 2012-01-31 kinaba: ,"X.....X" 15bfca2432 2012-01-31 kinaba: ,"XXXXXXX"}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {".X." 15bfca2432 2012-01-31 kinaba: ,"XXX" 15bfca2432 2012-01-31 kinaba: ,".X."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "NO"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(5) 15bfca2432 2012-01-31 kinaba: string cake_[] = {".." 15bfca2432 2012-01-31 kinaba: ,"X." 15bfca2432 2012-01-31 kinaba: ,".X"}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {".." 15bfca2432 2012-01-31 kinaba: ,".X" 15bfca2432 2012-01-31 kinaba: ,"X."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "NO"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(6) 15bfca2432 2012-01-31 kinaba: string cake_[] = {"X.." 15bfca2432 2012-01-31 kinaba: ,".XX" 15bfca2432 2012-01-31 kinaba: ,".XX"}; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = {".XX" 15bfca2432 2012-01-31 kinaba: ,".XX" 15bfca2432 2012-01-31 kinaba: ,"X.."}; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = "NO"; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: /* 15bfca2432 2012-01-31 kinaba: CASE(7) 15bfca2432 2012-01-31 kinaba: string cake_[] = ; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = ; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = ; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: CASE(8) 15bfca2432 2012-01-31 kinaba: string cake_[] = ; 15bfca2432 2012-01-31 kinaba: vector <string> cake(cake_, cake_+sizeof(cake_)/sizeof(*cake_)); 15bfca2432 2012-01-31 kinaba: string cutter_[] = ; 15bfca2432 2012-01-31 kinaba: vector <string> cutter(cutter_, cutter_+sizeof(cutter_)/sizeof(*cutter_)); 15bfca2432 2012-01-31 kinaba: string _ = ; 15bfca2432 2012-01-31 kinaba: END 15bfca2432 2012-01-31 kinaba: */ 15bfca2432 2012-01-31 kinaba: } 15bfca2432 2012-01-31 kinaba: // END CUT HERE