Sunday, 14 April 2019

Bishops LightOj 1202

In this problem you just have to find out some conditions relevant to row and column differences.
One important thing is maximum move will be two(where one bishop can reach another but they are not in same diagonal)

so, you have to just find out conditions for each output(1,2 and impossible)


code:
/*
Author : Mohammad Morsalin Hossain
Dept of ICE,NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define IOS ios::sync_with_stdio(false);
using namespace std;
int main()
{
    IOS
    int test;
    cin>>test;
    int to=0;
    while(test--)
    {
        int row1,col1,row2,col2;
        cin>>row1>>col1>>row2>>col2;
        if((row1+col2 == row2+col1)||(abs(row1-row2)==abs(col1-col2)))
            cout << "Case "<<++to<<": 1\n";
        else if((row1+col2)==abs(row2-col1)||(abs(row1-col2)==row2+col1)||(row1+row2)%2==(col1+col2)%2)
            cout << "Case "<<++to<<": 2\n";
        else
            cout <<"Case "<<++to<<": impossible\n";
    }
    return 0;
}

No comments:

Post a Comment

If you have any doubts, let me know through comments

Monkey Banana Problem lightoj 1004

  In this problem we will check which adjacent cell will benefits the monkey best. For this, we will check all possible solution of this pro...