コード例 #1
0
ファイル: FoxAndFencing.cpp プロジェクト: yuzhou627/TopCoder
bool KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, int p3, int p4, bool hasAnswer, string p5) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << p2 << "," << p3 << "," << p4;
	cout << "]" << endl;
	FoxAndFencing *obj;
	string answer;
	obj = new FoxAndFencing();
	clock_t startTime = clock();
	answer = obj->WhoCanWin(p0, p1, p2, p3, p4);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << "\"" << p5 << "\"" << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << "\"" << answer << "\"" << endl;
	if (hasAnswer) {
		res = answer == p5;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
コード例 #2
0
// BEGIN CUT HERE
void main( int argc, char* argv[] ) {
    {
        FoxAndFencing theObject;
        eq(0, theObject.WhoCanWin(1212548, 4702178, 5032818, 1951676, 7426047),"Draw");
    }
    {
        FoxAndFencing theObject;
        eq(1, theObject.WhoCanWin(2, 1, 1, 100, 50),"Liss");
    }
    {
        FoxAndFencing theObject;
        eq(2, theObject.WhoCanWin(2, 1, 1, 100, 150),"Draw");
    }
    {
        FoxAndFencing theObject;
        eq(3, theObject.WhoCanWin(100, 100, 100, 100, 100000000),"Draw");
    }
    {
        FoxAndFencing theObject;
        eq(4, theObject.WhoCanWin(100, 1, 100, 1, 100000000),"Ciel");
    }
    {
        FoxAndFencing theObject;
        eq(5, theObject.WhoCanWin(100, 1, 100, 250, 100000000),"Draw");
    }
    {
        FoxAndFencing theObject;
        eq(6, theObject.WhoCanWin(100, 1, 100, 150, 100000000),"Ciel");
    }
    {
        FoxAndFencing theObject;
        eq(7, theObject.WhoCanWin(100, 50, 100, 1, 100000000),"Ciel");
    }
    {
        FoxAndFencing theObject;
        eq(8, theObject.WhoCanWin(100, 150, 100, 1, 100000000),"Draw");
    }
}