This is not fair CodeChef. You had clearly written integers in the question. So why are you accepting solutions in which it is taken float. Just because of this, I could not submit a correct answer, which actually is the correct answer.
the solution which is actually the correct answer, but given wrong by CodeChef
the solution which is actually the wrong answer, but given correct by CodeChef
It can clearly be seen in the solutions, the only difference is the data type.
And it can also be seen that CodeChef clearly specified to use integer data type:
Why do you think your implementation is correct?
If using int
would not pass, then why was my submission accepted?
My Solution using Integers
void solve() {
int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
cin >> x1 >> y1 >> x2 >> y2;
if(x1 * y2 > x2 * y1) {
cout << "-1" << '\n';
}
else if(x1 * y2 < x2 * y1) {
cout << "1" << '\n';
}
else {
cout << 0 << '\n';
}
}
FYI: Arithmetic operators - cppreference.com
If you divide two integers the result will always be an integer. if you want float you have to do implicit casting
Example:
int a = 8;
int b = 5;
float c = a/b;
Here even though c is float, the value in c will be 1 not 1.6
int a = 8;
int b = 5;
float c = (float) a/b;
Here the value of c will be 1.6
If you don’t want to do casting you can take both values as a float then on dividing the resultant value will also be float
float a = 8;
float b = 5;
float c = a/b;
Here the value of c will be 1.6
Then what is the reason that my solution didn’t get accepted? 
I could not understand how is this information related to what I am saying !?