aca31be9a5 2011-12-24 kinaba: #include <iostream> aca31be9a5 2011-12-24 kinaba: #include <sstream> aca31be9a5 2011-12-24 kinaba: #include <iomanip> aca31be9a5 2011-12-24 kinaba: #include <vector> aca31be9a5 2011-12-24 kinaba: #include <string> aca31be9a5 2011-12-24 kinaba: #include <map> aca31be9a5 2011-12-24 kinaba: #include <set> aca31be9a5 2011-12-24 kinaba: #include <algorithm> aca31be9a5 2011-12-24 kinaba: #include <numeric> aca31be9a5 2011-12-24 kinaba: #include <iterator> aca31be9a5 2011-12-24 kinaba: #include <functional> aca31be9a5 2011-12-24 kinaba: #include <complex> aca31be9a5 2011-12-24 kinaba: #include <queue> aca31be9a5 2011-12-24 kinaba: #include <stack> aca31be9a5 2011-12-24 kinaba: #include <cmath> aca31be9a5 2011-12-24 kinaba: #include <cassert> aca31be9a5 2011-12-24 kinaba: #include <cstring> aca31be9a5 2011-12-24 kinaba: #ifdef __GNUC__ aca31be9a5 2011-12-24 kinaba: #include <ext/hash_map> aca31be9a5 2011-12-24 kinaba: #define unordered_map __gnu_cxx::hash_map aca31be9a5 2011-12-24 kinaba: #else aca31be9a5 2011-12-24 kinaba: #include <unordered_map> aca31be9a5 2011-12-24 kinaba: #endif aca31be9a5 2011-12-24 kinaba: using namespace std; aca31be9a5 2011-12-24 kinaba: typedef long long LL; aca31be9a5 2011-12-24 kinaba: typedef complex<double> CMP; aca31be9a5 2011-12-24 kinaba: aca31be9a5 2011-12-24 kinaba: class CheatingQuiz { public: aca31be9a5 2011-12-24 kinaba: vector <int> howMany(string answers) aca31be9a5 2011-12-24 kinaba: { aca31be9a5 2011-12-24 kinaba: int N = answers.size(); aca31be9a5 2011-12-24 kinaba: vector<int> re; aca31be9a5 2011-12-24 kinaba: int A = count(answers.begin(), answers.end(), 'A'); aca31be9a5 2011-12-24 kinaba: int B = count(answers.begin(), answers.end(), 'B'); aca31be9a5 2011-12-24 kinaba: int C = count(answers.begin(), answers.end(), 'C'); aca31be9a5 2011-12-24 kinaba: for(int i=0; i<N; ++i) { aca31be9a5 2011-12-24 kinaba: re.push_back(!!A + !!B + !!C); aca31be9a5 2011-12-24 kinaba: (answers[i]=='A' ? A : answers[i]=='B' ? B : C)--; aca31be9a5 2011-12-24 kinaba: } aca31be9a5 2011-12-24 kinaba: return re; aca31be9a5 2011-12-24 kinaba: } aca31be9a5 2011-12-24 kinaba: }; aca31be9a5 2011-12-24 kinaba: aca31be9a5 2011-12-24 kinaba: // BEGIN CUT HERE aca31be9a5 2011-12-24 kinaba: #include <ctime> aca31be9a5 2011-12-24 kinaba: double start_time; string timer() aca31be9a5 2011-12-24 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } aca31be9a5 2011-12-24 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) aca31be9a5 2011-12-24 kinaba: { os << "{ "; aca31be9a5 2011-12-24 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) aca31be9a5 2011-12-24 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } aca31be9a5 2011-12-24 kinaba: void verify_case(const vector <int>& Expected, const vector <int>& Received) { aca31be9a5 2011-12-24 kinaba: bool ok = (Expected == Received); aca31be9a5 2011-12-24 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; aca31be9a5 2011-12-24 kinaba: cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } } aca31be9a5 2011-12-24 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); aca31be9a5 2011-12-24 kinaba: #define END verify_case(_, CheatingQuiz().howMany(answers));} aca31be9a5 2011-12-24 kinaba: int main(){ aca31be9a5 2011-12-24 kinaba: aca31be9a5 2011-12-24 kinaba: CASE(0) aca31be9a5 2011-12-24 kinaba: string answers = "AAAAA"; aca31be9a5 2011-12-24 kinaba: int __[] = {1, 1, 1, 1, 1 }; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: CASE(1) aca31be9a5 2011-12-24 kinaba: string answers = "AAABBB"; aca31be9a5 2011-12-24 kinaba: int __[] = {2, 2, 2, 1, 1, 1 }; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: CASE(2) aca31be9a5 2011-12-24 kinaba: string answers = "CAAAAAC"; aca31be9a5 2011-12-24 kinaba: int __[] = {2, 2, 2, 2, 2, 2, 1 }; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: CASE(3) aca31be9a5 2011-12-24 kinaba: string answers = "BBCA"; aca31be9a5 2011-12-24 kinaba: int __[] = {3, 3, 2, 1 }; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: CASE(4) aca31be9a5 2011-12-24 kinaba: string answers = "BACACABCBBBBCAAAAACCCABBCAA"; aca31be9a5 2011-12-24 kinaba: int __[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1 }; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: /* aca31be9a5 2011-12-24 kinaba: CASE(5) aca31be9a5 2011-12-24 kinaba: string answers = ; aca31be9a5 2011-12-24 kinaba: int __[] = ; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: CASE(6) aca31be9a5 2011-12-24 kinaba: string answers = ; aca31be9a5 2011-12-24 kinaba: int __[] = ; aca31be9a5 2011-12-24 kinaba: vector <int> _(__, __+sizeof(__)/sizeof(*__)); aca31be9a5 2011-12-24 kinaba: END aca31be9a5 2011-12-24 kinaba: */ aca31be9a5 2011-12-24 kinaba: } aca31be9a5 2011-12-24 kinaba: // END CUT HERE