e87d5512af 2011-06-03 kinaba: #include <iostream> e87d5512af 2011-06-03 kinaba: #include <sstream> e87d5512af 2011-06-03 kinaba: #include <iomanip> e87d5512af 2011-06-03 kinaba: #include <vector> e87d5512af 2011-06-03 kinaba: #include <string> e87d5512af 2011-06-03 kinaba: #include <map> e87d5512af 2011-06-03 kinaba: #include <set> e87d5512af 2011-06-03 kinaba: #include <algorithm> e87d5512af 2011-06-03 kinaba: #include <numeric> e87d5512af 2011-06-03 kinaba: #include <iterator> e87d5512af 2011-06-03 kinaba: #include <functional> e87d5512af 2011-06-03 kinaba: #include <complex> e87d5512af 2011-06-03 kinaba: #include <queue> e87d5512af 2011-06-03 kinaba: #include <stack> e87d5512af 2011-06-03 kinaba: #include <cmath> e87d5512af 2011-06-03 kinaba: #include <cassert> e87d5512af 2011-06-03 kinaba: #include <cstring> e87d5512af 2011-06-03 kinaba: using namespace std; e87d5512af 2011-06-03 kinaba: typedef long long LL; e87d5512af 2011-06-03 kinaba: typedef complex<double> CMP; e87d5512af 2011-06-03 kinaba: e87d5512af 2011-06-03 kinaba: class CubeStickers { public: e87d5512af 2011-06-03 kinaba: string isPossible(vector <string> sticker) e87d5512af 2011-06-03 kinaba: { e87d5512af 2011-06-03 kinaba: map<string,int> mp; e87d5512af 2011-06-03 kinaba: for(int i=0; i<sticker.size(); ++i) e87d5512af 2011-06-03 kinaba: mp[sticker[i]]++; e87d5512af 2011-06-03 kinaba: int cnt = 0; e87d5512af 2011-06-03 kinaba: for(map<string,int>::iterator it=mp.begin(); it!=mp.end(); ++it) e87d5512af 2011-06-03 kinaba: cnt += min(2, it->second); e87d5512af 2011-06-03 kinaba: return cnt>=6 ? "YES" : "NO"; e87d5512af 2011-06-03 kinaba: } e87d5512af 2011-06-03 kinaba: }; e87d5512af 2011-06-03 kinaba: e87d5512af 2011-06-03 kinaba: // BEGIN CUT HERE e87d5512af 2011-06-03 kinaba: #include <ctime> e87d5512af 2011-06-03 kinaba: double start_time; string timer() e87d5512af 2011-06-03 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } e87d5512af 2011-06-03 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) e87d5512af 2011-06-03 kinaba: { os << "{ "; e87d5512af 2011-06-03 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) e87d5512af 2011-06-03 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } e87d5512af 2011-06-03 kinaba: void verify_case(const string& Expected, const string& Received) { e87d5512af 2011-06-03 kinaba: bool ok = (Expected == Received); e87d5512af 2011-06-03 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; e87d5512af 2011-06-03 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } e87d5512af 2011-06-03 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); e87d5512af 2011-06-03 kinaba: #define END verify_case(_, CubeStickers().isPossible(sticker));} e87d5512af 2011-06-03 kinaba: int main(){ e87d5512af 2011-06-03 kinaba: e87d5512af 2011-06-03 kinaba: CASE(0) e87d5512af 2011-06-03 kinaba: string sticker_[] = {"cyan","magenta","yellow","purple","black","white","purple"}; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = "YES"; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: CASE(1) e87d5512af 2011-06-03 kinaba: string sticker_[] = {"blue","blue","blue","blue","blue","blue","blue","blue","blue","blue"}; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = "NO"; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: CASE(2) e87d5512af 2011-06-03 kinaba: string sticker_[] = {"red","yellow","blue","red","yellow","blue","red","yellow","blue"}; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = "YES"; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: CASE(3) e87d5512af 2011-06-03 kinaba: string sticker_[] = {"purple","orange","orange","purple","black","orange","purple"}; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = "NO"; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: CASE(4) e87d5512af 2011-06-03 kinaba: string sticker_[] = {"white","gray","green","blue","yellow","red","target","admin"}; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = "YES"; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: /* e87d5512af 2011-06-03 kinaba: CASE(5) e87d5512af 2011-06-03 kinaba: string sticker_[] = ; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = ; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: CASE(6) e87d5512af 2011-06-03 kinaba: string sticker_[] = ; e87d5512af 2011-06-03 kinaba: vector <string> sticker(sticker_, sticker_+sizeof(sticker_)/sizeof(*sticker_)); e87d5512af 2011-06-03 kinaba: string _ = ; e87d5512af 2011-06-03 kinaba: END e87d5512af 2011-06-03 kinaba: */ e87d5512af 2011-06-03 kinaba: } e87d5512af 2011-06-03 kinaba: // END CUT HERE