UVA 10963 The Swallowing Ground Solution

Hints:
খুব ই সহজ সমাধান :-) ইনপুট এ w দেয়া থাকবে । মানে , w এতগুলো কলাম বিবেচনা করতে হবে । প্রতিটা কলাম এ কিছু গর্ত / থাকবে (y1 upper y co-ordinate , y2 -lower y coordinate) । ছবির কালো অংশগুলো । আর সাদা অংশগুলো বুঝাচ্ছে ground। এখন অই গর্ত গুলো ঢাকতে হবে সাদা অংশ সরিয়ে ।case 1 এ সাদা অংশ ২ unit নিচে সরালেই হচ্ছে কিন্তু case 2 তে ১ unit নিচে নিলেও ১ টা গর্ত থেকে যাচ্ছে ।

Solution in c++:
///**********ALLAH IS ALMIGHTY************///
     ///AH Tonmoy
    ///Department of CSE,23rd batch
    ///Islamic University,Bangladesh
#include<iostream>
using namespace std;
int main()
{
    int a,b,t,n,d,f,s;
    cin>>t;
    while(t--)
    {
        f=0;
        cin>>n;
        cin>>a>>b;
        d=a-b;
        for(int i=1; i<n; i++)
        {
            cin>>a>>b;
            if(d!=a-b)
            {
                f=1;
            }

        }
        if(f==0)
            cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;
            
            
        if(t>0)
        cout<<endl;
    }
}

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.