Algorithm
problem Link : https://www.codechef.com/problems/TRUESCORE
Problem
Chef is watching a football match. The current score is , that is, team has scored goals and team has scored goals. Chef wonders if it is possible for the score to become at a later point in the game (i.e. team has scored goals and team has scored goals). Can you help Chef by answering his question?
Input Format
- The first line contains a single integer - the number of test cases. Then the test cases follow.
- The first line of each test case contains two integers and - the intial number of goals team and team have scored respectively.
- The second line of each test case contains two integers and - the final number of goals team and team must be able to score respectively.
Output Format
For each testcase, output POSSIBLE
if it is possible for the score to become at a later point in the game, IMPOSSIBLE
otherwise.
You may print each character of POSSIBLE
and IMPOSSIBLE
in uppercase or lowercase (for example, possible
, pOSsiBLe
, Possible
will be considered identical).
Constraints
Sample 1:
3 1 5 3 5 3 4 2 6 2 2 2 2
POSSIBLE IMPOSSIBLE POSSIBLE
Explanation:
Test case 1: The current score is . If team scores more goals, the score will become . Thus is a possible score.
Test case 2: The current score is . It can be proven that no non-negative pair of integers exists such that if team scores more goals and team scores more goals the score becomes from . Thus in this case is an impossible score.
Test case 3: The current score is already . Hence it is a possible score.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int t,a,b,c,d;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %d %d",&a,&b,&c,&d);
if(c>=a && d>=b) printf("POSSIBLE\n");
else printf("IMPOSSIBLE\n");
}
}
Copy The Code &
Try With Live Editor
Input
1 5
3 5
3 4
2 6
2 2
2 2
Output
IMPOSSIBLE
POSSIBLE
Demonstration
CodeChef solution TRUESCORE - Is the Score Consistent Codechef solution in C,C++