d4ec396a23 2014-04-21 kinaba: #include <iostream> d4ec396a23 2014-04-21 kinaba: #include <sstream> d4ec396a23 2014-04-21 kinaba: #include <iomanip> d4ec396a23 2014-04-21 kinaba: #include <vector> d4ec396a23 2014-04-21 kinaba: #include <string> d4ec396a23 2014-04-21 kinaba: #include <map> d4ec396a23 2014-04-21 kinaba: #include <set> d4ec396a23 2014-04-21 kinaba: #include <algorithm> d4ec396a23 2014-04-21 kinaba: #include <numeric> d4ec396a23 2014-04-21 kinaba: #include <iterator> d4ec396a23 2014-04-21 kinaba: #include <functional> d4ec396a23 2014-04-21 kinaba: #include <complex> d4ec396a23 2014-04-21 kinaba: #include <queue> d4ec396a23 2014-04-21 kinaba: #include <stack> d4ec396a23 2014-04-21 kinaba: #include <cmath> d4ec396a23 2014-04-21 kinaba: #include <cassert> d4ec396a23 2014-04-21 kinaba: #include <tuple> d4ec396a23 2014-04-21 kinaba: using namespace std; d4ec396a23 2014-04-21 kinaba: typedef long long LL; d4ec396a23 2014-04-21 kinaba: typedef complex<double> CMP; d4ec396a23 2014-04-21 kinaba: d4ec396a23 2014-04-21 kinaba: class SpamChecker { public: d4ec396a23 2014-04-21 kinaba: string spamCheck(string judgeLog, int good, int bad) d4ec396a23 2014-04-21 kinaba: { d4ec396a23 2014-04-21 kinaba: return isBad(judgeLog, good, bad) ? "SPAM" : "NOT SPAM"; d4ec396a23 2014-04-21 kinaba: } d4ec396a23 2014-04-21 kinaba: d4ec396a23 2014-04-21 kinaba: bool isBad(string judgeLog, int good, int bad) d4ec396a23 2014-04-21 kinaba: { d4ec396a23 2014-04-21 kinaba: int score = 0; d4ec396a23 2014-04-21 kinaba: for(char c: judgeLog) d4ec396a23 2014-04-21 kinaba: if((score += c=='o' ? good : -bad) < 0) d4ec396a23 2014-04-21 kinaba: return true; d4ec396a23 2014-04-21 kinaba: return false; d4ec396a23 2014-04-21 kinaba: } d4ec396a23 2014-04-21 kinaba: }; d4ec396a23 2014-04-21 kinaba: d4ec396a23 2014-04-21 kinaba: // BEGIN CUT HERE d4ec396a23 2014-04-21 kinaba: #include <ctime> d4ec396a23 2014-04-21 kinaba: double start_time; string timer() d4ec396a23 2014-04-21 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } d4ec396a23 2014-04-21 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) d4ec396a23 2014-04-21 kinaba: { os << "{ "; d4ec396a23 2014-04-21 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) d4ec396a23 2014-04-21 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } d4ec396a23 2014-04-21 kinaba: void verify_case(const string& Expected, const string& Received) { d4ec396a23 2014-04-21 kinaba: bool ok = (Expected == Received); d4ec396a23 2014-04-21 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; d4ec396a23 2014-04-21 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } d4ec396a23 2014-04-21 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); d4ec396a23 2014-04-21 kinaba: #define END verify_case(_, SpamChecker().spamCheck(judgeLog, good, bad));} d4ec396a23 2014-04-21 kinaba: int main(){ d4ec396a23 2014-04-21 kinaba: d4ec396a23 2014-04-21 kinaba: CASE(0) d4ec396a23 2014-04-21 kinaba: string judgeLog = "ooooxxxo"; d4ec396a23 2014-04-21 kinaba: int good = 2; d4ec396a23 2014-04-21 kinaba: int bad = 3; d4ec396a23 2014-04-21 kinaba: string _ = "SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(1) d4ec396a23 2014-04-21 kinaba: string judgeLog = "ooooxxxo"; d4ec396a23 2014-04-21 kinaba: int good = 3; d4ec396a23 2014-04-21 kinaba: int bad = 4; d4ec396a23 2014-04-21 kinaba: string _ = "NOT SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(2) d4ec396a23 2014-04-21 kinaba: string judgeLog = "xooooooooooooooooooooooooooo"; d4ec396a23 2014-04-21 kinaba: int good = 1000; d4ec396a23 2014-04-21 kinaba: int bad = 1; d4ec396a23 2014-04-21 kinaba: string _ = "SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(3) d4ec396a23 2014-04-21 kinaba: string judgeLog = "oxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; d4ec396a23 2014-04-21 kinaba: int good = 1000; d4ec396a23 2014-04-21 kinaba: int bad = 1; d4ec396a23 2014-04-21 kinaba: string _ = "NOT SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(4) d4ec396a23 2014-04-21 kinaba: string judgeLog = "ooxoxoxooxoxxoxoxooxoxoxoxxoxx"; d4ec396a23 2014-04-21 kinaba: int good = 15; d4ec396a23 2014-04-21 kinaba: int bad = 17; d4ec396a23 2014-04-21 kinaba: string _ = "SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(5) d4ec396a23 2014-04-21 kinaba: string judgeLog = "oooxoxoxoxoxoxooxooxoxooxo"; d4ec396a23 2014-04-21 kinaba: int good = 16; d4ec396a23 2014-04-21 kinaba: int bad = 18; d4ec396a23 2014-04-21 kinaba: string _ = "NOT SPAM"; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: /* d4ec396a23 2014-04-21 kinaba: CASE(6) d4ec396a23 2014-04-21 kinaba: string judgeLog = ; d4ec396a23 2014-04-21 kinaba: int good = ; d4ec396a23 2014-04-21 kinaba: int bad = ; d4ec396a23 2014-04-21 kinaba: string _ = ; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: CASE(7) d4ec396a23 2014-04-21 kinaba: string judgeLog = ; d4ec396a23 2014-04-21 kinaba: int good = ; d4ec396a23 2014-04-21 kinaba: int bad = ; d4ec396a23 2014-04-21 kinaba: string _ = ; d4ec396a23 2014-04-21 kinaba: END d4ec396a23 2014-04-21 kinaba: */ d4ec396a23 2014-04-21 kinaba: } d4ec396a23 2014-04-21 kinaba: // END CUT HERE