Ad
  • Default User Avatar

    After verification, the C++ test suite is definitely broken. This is an example of input for the medium tests in C++ :
    {3,6,3,5,7,3,5,8,6,10,5,7,6,5,7,7,7,3,1,8,3,3,6,1,6,10,8,5,7,2,10,1,8,4,5,6,8,9,5,5,1,10,1,6,4,7,4,2,2,5,9,4,9,6,6,5,5,5,9,1,7,10,3,6,3,8,1,10,8,6,4,8,5,4,6,10,3,9,1,4,3,1,9,2,7,7,8,3,1,6,4,9,5,8,4,9,5,7,8,5,2,3,2,8,8,7,9,10,6,9,5,10,1,4,3,7,10,10,10,2,5,5,1,1,2,6,1,9,2,8,3,5,2,4,2,10,3,10,1,10,10,8,9,1,1,2,9,2,1,8,5,8,4,7,10,6,3,1,6,6,10,8,1,2,1,4,3,5,6,5,4,5,2,5,7,4,6,6,7,8,5,2,7,9,8,7,6,2,9,1,8,10,8,10,3,10,5,5,7,10,2,10,7,3,4,3,9,1,10,5,1,5,6,7,5,6,5,10,9,5,2,8,5,9,7,7,10,2,4,6,3,5,8,9,9,3,4,9,4,5,4,6,1,1,4,5,8,9,6,7,5,7,4,9,7,3,8,7,6,1,4,8,7,3,9,7,6,4,6,1,10,9,6,1,1,9,5,9,9,1,7,4,9,10,4,6,4,1,4,9,1,9,9,7,2,7,4,7,2,1,7,1,9,4,1,9,2,8,9,3,8,5,6,6,7,9,3,10,2,6,9,2,5,7,1,6,5,6,4,6,6,2,6,6,5,9,6,8,6,5,10,5,9,7,2,5,8,5,7,9,2,5,2,8,3,2,3,7,9,8,2,6,9,9,1,3,9,7,3,4,3,4,8,3,1,2,10,8,6,6,8,7,10,9,5,2,3,9,10,1,9,1,7,7,1,9,2,10,7,4,3,9,7,3,4,9,4,3,8,1,8,5,9,9,4,5,2,6,6,1,8,4,3,6,10,3,5,1,4,3,6,9,4,5,1,7,3,6,9,1,8,8,5,6,6,10,1,7,7,6,9,5,1,1,2,10,5,8,3,9,1,8,7,4,4,9,10,7,6,10,7,3,7,3,8,4,3,10,10,9,7,10,5,7,10,7,7,6,6,1,4,6,10,2,1,4,10,2,10,5}

    and the correct output (computed with the Python reference solution) is
    9189219707931193199459304195173016683771551867906074348090583697662521149392759681823894170077096644424564514318051866413296335691814331382722620500757801464266905719107348148032214941363160214553271053804378298390939293712808946127253452553014633676202571044656910855336273969534459600000
    which is far too big for an unsigned long long to hold.

  • Default User Avatar

    I'm encountering the same problem. My C++ solution overflows on medium and large tests, but passes all tests when rewritten in Python (so the algorithm it uses is likely correct). The intermediate values it manipulates are smaller than the total result, which would indicate that the expected result for medium and large tests does not fit in 64-bit integers, and that the reference C++ solution either overflows or does modular arithmetic over an unspecified constant