Ejemplo n.º 1
0
bool KawigiEdit_RunTest(int testNum, vector <int> p0, vector <int> p1, bool hasAnswer, int p2) {
    cout << "Test " << testNum << ": [" << "{";
    for (int i = 0; int(p0.size()) > i; ++i) {
        if (i > 0) {
            cout << ",";
        }
        cout << p0[i];
    }
    cout << "}" << "," << "{";
    for (int i = 0; int(p1.size()) > i; ++i) {
        if (i > 0) {
            cout << ",";
        }
        cout << p1[i];
    }
    cout << "}";
    cout << "]" << endl;
    SnowyWinter *obj;
    int answer;
    obj = new SnowyWinter();
    clock_t startTime = clock();
    answer = obj->snowyHighwayLength(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;
}
Ejemplo n.º 2
0
// BEGIN CUT HERE
void main( int argc, char* argv[] ) {
    {
        int startPointsARRAY[] = {17,85,57};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {33,86,84};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(0, theObject.snowyHighwayLength(startPoints, endPoints),44);
    }
    {
        int startPointsARRAY[] = {45,100,125,10,15,35,30,9};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {46,200,175,20,25,45,40,10};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(1, theObject.snowyHighwayLength(startPoints, endPoints),132);
    }
    {
        int startPointsARRAY[] = {4387,711,2510,1001,4687,3400,5254,584,284,1423,3755,929,2154,5719,1326,2368,554};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {7890,5075,2600,6867,7860,9789,6422,5002,4180,7086,8615,9832,4169,7188,9975,8690,1423};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(2, theObject.snowyHighwayLength(startPoints, endPoints),9691);
    }
    {
        int startPointsARRAY[] = {4906,5601,5087,1020,4362,2657,6257,5509,5107,5315,277,6801,2136,2921,5233,5082,497,8250,3956,5720};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {4930,9130,9366,2322,4687,4848,8856,6302,5496,5438,829,9053,4233,4119,9781,8034,3956,9939,4908,5928};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(3, theObject.snowyHighwayLength(startPoints, endPoints),9510);
    }
    {
        int startPointsARRAY[] = {51,807,943,4313,8319,3644,481,220,2161,448,465,1657,6290,22,6152,647,3185,4474,2168};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {1182,912,1832,7754,9557,7980,4144,3194,7129,5535,1172,2043,6437,7252,9508,4745,8313,8020,4017};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(4, theObject.snowyHighwayLength(startPoints, endPoints),9535);
    }
    {
        int startPointsARRAY[] = {8786,7391,201,4414,5822,5872,157,1832,7487,7518,2267,1763,3984,3102,7627,4099,524,1543,1022,3060};
        vector <int> startPoints( startPointsARRAY, startPointsARRAY+ARRSIZE(startPointsARRAY) );
        int endPointsARRAY[] = {9905,7957,3625,6475,9314,9332,4370,8068,8295,8177,7772,2668,7191,8480,9211,4802,2625,1924,9970,4180};
        vector <int> endPoints( endPointsARRAY, endPointsARRAY+ARRSIZE(endPointsARRAY) );
        SnowyWinter theObject;
        eq(5, theObject.snowyHighwayLength(startPoints, endPoints),9813);
    }
}