my output should satisfy the below condition.
Your output will be considered to be correct if the difference between your output and the actual answer is not more than 10^−6.
Without seeing a link to the original problem, it’s hard to know for sure, but having the answers x1 and x2 be ints instead of doubles will only give the correct answer in fairly rare circumstances.
I think while printing x1 and x2 with cout doesn’t gave output till precision 10^-6 .
instead use setprecision or printf for printing with a precision of 10^-6.
eg. printf("%0.6lf\n%0.6lf",x1,x2);