예제 #1
0
파일: srm218.cpp 프로젝트: pcodex/TopCoder
int main()
{
	AccessLevel al;

	vector<int> r = { 34, 78, 9, 52, 11, 1 };
	int mp = 49;
	string op = al.canAccess(r, mp);
	
	return 0;
}
예제 #2
0
int test3() {
    vector<int> rights = {34, 78, 9, 52, 11, 1};
    int minPermission = 49;
    AccessLevel* pObj = new AccessLevel();
    clock_t start = clock();
    string result = pObj->canAccess(rights, minPermission);
    clock_t end = clock();
    delete pObj;
    string expected = "DADADD";
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #3
0
int test11() {
    vector<int> rights = {0, 1, 2, 3, 4, 5};
    int minPermission = 2;
    AccessLevel* pObj = new AccessLevel();
    clock_t start = clock();
    string result = pObj->canAccess(rights, minPermission);
    clock_t end = clock();
    delete pObj;
    string expected = "DDAAAA";
    if(result == expected) {
        cout << "Test Case 11: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 11: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #4
0
int test6() {
    vector<int> rights = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50};
    int minPermission = 25;
    AccessLevel* pObj = new AccessLevel();
    clock_t start = clock();
    string result = pObj->canAccess(rights, minPermission);
    clock_t end = clock();
    delete pObj;
    string expected = "DDDDDDDDDDDDDDDDDDDDDDDDAAAAAAAAAAAAAAAAAAAAAAAAAA";
    if(result == expected) {
        cout << "Test Case 6: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 6: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
예제 #5
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, vector <int> p0, int p1, bool hasAnswer, string p2) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p0[i];
	}
	cout << "}" << "," << p1;
	cout << "]" << endl;
	AccessLevel *obj;
	string answer;
	obj = new AccessLevel();
	clock_t startTime = clock();
	answer = obj->canAccess(p0, p1);
	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" << "\"" << p2 << "\"" << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << "\"" << answer << "\"" << endl;
	if (hasAnswer) {
		res = answer == p2;
	}
	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;
}