Ejemplo n.º 1
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, int p0, vector <int> p1, vector <int> p2, vector <int> p3, bool hasAnswer, string p4) {
	cout << "Test " << testNum << ": [" << p0 << "," << "{";
	for (int i = 0; int(p1.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p1[i];
	}
	cout << "}" << "," << "{";
	for (int i = 0; int(p2.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p2[i];
	}
	cout << "}" << "," << "{";
	for (int i = 0; int(p3.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p3[i];
	}
	cout << "}";
	cout << "]" << endl;
	InverseRMQ *obj;
	string answer;
	obj = new InverseRMQ();
	clock_t startTime = clock();
	answer = obj->possible(p0, p1, p2, p3);
	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" << "\"" << p4 << "\"" << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << "\"" << answer << "\"" << endl;
	if (hasAnswer) {
		res = answer == p4;
	}
	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;
}
Ejemplo n.º 2
0
void main( int argc, char* argv[] ) {
    {
	    //{10, {4, 5, 6}, {5, 6, 7}, {6, 7, 5}}
        int AARRAY[] = {4, 5, 6};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {5, 6, 7};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {6, 7, 5};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(0, theObject.possible(10, A, B, ans),"Impossible");
    }
    {
        int AARRAY[] = {1,2,3};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {1,2,3};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {3,3,3};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(1, theObject.possible(3, A, B, ans),"Impossible");
    }
    {
        int AARRAY[] = {1,101,201,301,401,501};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {100,200,300,400,500,600};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {100,200,300,400,500,600};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(2, theObject.possible(600, A, B, ans),"Possible");
    }
    {
        int AARRAY[] = {1234,1234};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {5678,5678};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {10000,20000};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(3, theObject.possible(1000000000, A, B, ans),"Impossible");
    }
    {
        int AARRAY[] = {1,2,3,4,5,6,7,8};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {1,2,3,4,5,6,7,8};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {4,8,2,5,6,3,7,1};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(4, theObject.possible(8, A, B, ans),"Possible");
    }
    {
        int AARRAY[] = {1};
        vector <int> A( AARRAY, AARRAY+ARRSIZE(AARRAY) );
        int BARRAY[] = {1000000000};
        vector <int> B( BARRAY, BARRAY+ARRSIZE(BARRAY) );
        int ansARRAY[] = {19911120};
        vector <int> ans( ansARRAY, ansARRAY+ARRSIZE(ansARRAY) );
        InverseRMQ theObject;
        eq(5, theObject.possible(1000000000, A, B, ans),"Impossible");
    }
}