diff --git a/Problem-setting/Goddbott-1/explanation.txt b/Problem-setting/Goddbott-1/explanation.txt new file mode 100644 index 0000000..38c575c --- /dev/null +++ b/Problem-setting/Goddbott-1/explanation.txt @@ -0,0 +1,10 @@ +Explanation: + +https://drive.google.com/file/d/11H9PEmoWNaFNNrrQ6WS2Oof5cvMt1CeR/view?usp=sharing + +First we calculate the difference between the coordinates of starting point and ending point. +a= X2-X1 and b=Y2-Y1 + +One can observe that if a is greater than b or any of a or b is negative then it is impossible to reach the ending point. +If a is equal to b then one can directly move diagonally to reach the ending point in minimum time. +If a is less than b then we first move diagonally then move up to reach the ending point in minimum time. diff --git a/Problem-setting/Goddbott-1/solution.cpp b/Problem-setting/Goddbott-1/solution.cpp new file mode 100644 index 0000000..a90e659 --- /dev/null +++ b/Problem-setting/Goddbott-1/solution.cpp @@ -0,0 +1,25 @@ +#include +#define int long long +using namespace std; +int32_t main(){ + int t; + cin>>t; + while(t--){ + int m,n; + cin>>m>>n; + int x1,y1,x2,y2; + cin>>x1>>y1>>x2>>y2; + int a= x2-x1; + int b= y2-y1; + if (a<0 || b<0 || a>b){ + cout<<-1<a){ + cout<