int verify_case( int casenum, const double &expected, const double &received ) { cerr << "Example " << casenum << "... "; cerr.precision(9); if ( topcoder_fequ( expected, received ) ) { cerr << "PASSED"; double rerr = moj_relative_error( expected, received ); if ( rerr > 0 ) cerr << " (relative error " << rerr << ")"; cerr << endl; return 1; } else { cerr << "FAILED" << endl; cerr << " Expected: " << expected << endl; cerr << " Received: " << received << endl; return 0; } }
int verify_case(int casenum, const double &expected, const double &received, clock_t elapsed) { cerr << "Example " << casenum << "... "; string verdict; vector<string> info; char buf[100]; if (elapsed > CLOCKS_PER_SEC / 200) { sprintf(buf, "time %.2fs", elapsed * (1.0/CLOCKS_PER_SEC)); info.push_back(buf); } if (topcoder_fequ(expected, received)) { verdict = "PASSED"; double rerr = moj_relative_error(expected, received); if (rerr > 0) { sprintf(buf, "relative error %.3e", rerr); info.push_back(buf); } } else { verdict = "FAILED"; } cerr << verdict; if (!info.empty()) { cerr << " ("; for (int i=0; i<(int)info.size(); ++i) { if (i > 0) cerr << ", "; cerr << info[i]; } cerr << ")"; } cerr << endl; if (verdict == "FAILED") { cerr << " Expected: " << expected << endl; cerr << " Received: " << received << endl; } return verdict == "PASSED"; }
int verify_case( int casenum, long long starttime, const double &expected, const double &received ) { cerr << "Example " << casenum << "... "; cerr.precision(9); if ( topcoder_fequ( expected, received ) ) { cerr << "PASSED"; #if defined(_SYS_TIME_H_) || defined(_SYS_TIME_H) cerr << " " << (get_time()-starttime)/1000 << "ms"; #endif double rerr = moj_relative_error( expected, received ); if ( rerr > 0 ) cerr << " (rerr " << rerr << ")"; cerr << endl; return 1; } else { cerr << "FAILED"; #if defined(_SYS_TIME_H_) || defined(_SYS_TIME_H) cerr << " " << (get_time()-starttime)/1000 << "ms"; #endif cerr << endl; cerr << " Expected: " << expected << endl; cerr << " Received: " << received << endl; return 0; } }