Posts

SPOJ BUGLIFE (2SAT Basic/Bipartite Checking)

SPOJ BUGLIFE (2SAT Basic/Bipartite Checking) // /==================================================/// // / HELLO WORLD !! /// // / IT'S ME /// // / BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define nl printf("\n") # define SZ ( x ) (int)(x.size()) # define pb ( x ) push_back(x) # define pii pair<int,int> # define pll pair<ll,ll> // /--------------------- # define S ( a ) scanf("%d",&a) # define P ( a ) printf("%d",a) # define SL ( a ) scanf("%lld",&a) # define S2 ( a , b ) scanf("%d%d",&a,&b) # define SL2 ( a , b ) scanf("%lld%lld",&a,&b) // /-------------------------------...

CF:Gym problem-G ( Digit DP )

CF:Gym problem-G ( Digit DP ) Accoring to problem, You have given interval L,R. You have to print number which have maximum product of the digits. Idea: Digit DP storing state of 1. Position-p 2. flag for did I take small (chhoto)-ch 3.flag for did I take large(boro)-br 4.flag for statting of nonzero val-z // /==================================================/// // / HELLO WORLD !! /// // / IT'S ME /// // / BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define nl printf("\n") # define SZ ( x ) (int)(x.size()) # define pb ( x ) push_back(x) # define pii pair<int,int> # define pll pair<ll,ll> // /--------------------- # define S ( a ) sca...

CF: EduRound10: Nested Segments(data structure)

CF: EduRound10: Nested Segments(data structure)     Idea: We have to find total segments withing main segment, For this if we sort segments on the basis of which ends  earlier comes first, we may easily get answer by updating starting points withing segment range using BIT.     // /==================================================/// // / HELLO WORLD !! /// // / IT'S ME /// // / BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define nl printf("\n") # define SZ ( x ) (int)(x.size()) # define pb ( x ) push_back(x) # define pii pair<int,int> # define pll pair<ll,ll> // /--------------------- # define S ( a ) scanf("%d",&a) # define P ( a ) printf(...

CF 396/C :On Changing Tree ( BIT, Data Structure )

CF 396 /C :On Changing Tree ( BIT, Data Structure ) // /==================================================/// // / HELLO WORLD !! /// // / IT'S ME /// // / BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define nl printf("\n") # define SZ ( x ) (int)(x.size()) # define pb ( x ) push_back(x) # define pii pair<int,int> # define pll pair<ll,ll> // /--------------------- # define S ( a ) scanf("%d",&a) # define P ( a ) printf("%d",a) # define SL ( a ) scanf("%lld",&a) # define S2 ( a , b ) scanf("%d%d",&a,&b) # define SL2 ( a , b ) scanf("%lld%lld",&a,&b) // /------------------------...

UVA : 11486 - Finding Paths in Grid (Matrix expo, math)

UVA : 11486 - Finding Paths in Grid (Matrix expo, math) // /==================================================/// // / !! HELLO WORLD !! /// // / IT'S ME - BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define pll pair<ll,ll> # define pii pair<int,int> # define pb ( x ) push_back(x) # define nl printf("\n") # define Max ( a , b ) ((a>b)?a:b) # define Min ( a , b ) ((a<b)?a:b) # define SZ ( x ) (int)(x.size()) // /--------------------- # define S ( a ) scanf("%d",&a) # define P ( a ) printf("%d",a) # define SL ( a ) scanf("%lld",&a) # define S2 ( a , b ) scanf("%d%d",&a,&b) # define SL2 ( a , b ) scanf("%lld%lld",&a,&b) /...

UVA: 11551 - Experienced Endeavour (Matrix expoentiation)

UVA: 11551 - Experienced Endeavour (Matrix expoentiation) // /==================================================/// // / !! HELLO WORLD !! /// // / IT'S ME - BISHAL GAUTAM /// // / [ bsal.gautam16@gmail.com ] /// // /==================================================/// #include<bits/stdc++.h> # define X first # define Y second # define mpp make_pair # define pll pair<ll,ll> # define pii pair<int,int> # define pb ( x ) push_back(x) # define nl printf("\n") # define Max ( a , b ) ((a>b)?a:b) # define Min ( a , b ) ((a<b)?a:b) # define SZ ( x ) (int)(x.size()) // /--------------------- # define S ( a ) scanf("%d",&a) # define P ( a ) printf("%d",a) # define SL ( a ) scanf("%lld",&a) # define S2 ( a , b ) scanf("%d%d",&a,&b) # define SL2 ( a , b ) scanf("%lld%lld",&a,&b)...

UVA: 10459 - The Tree Root ( Diameter of Tree, DP )

UVA : 10459 - The Tree Root ( Diameter of Tree , DP ) Problem : The problem asked to find longest level of tree assuming all node ( 1 to N ) as root . Then to find best and worst levels we got from different nodes . Idea : find starting and ending nodes of diameter of tree , then answer for each node will be maximum of distance from these endpoints . //==================================================/// /// HELLO WORLD !! /// /// IT ' S ME /// /// BISHAL GAUTAM /// /// [ bsal . gautam16@gmail . com ] /// ///==================================================/// # include < bits / stdc ++. h > # define X first # define Y second # define mpp make_pair # define nl printf( " \n " ) # define SZ (x) (int)(x . size () ) # define pb(x) push_back(x) # define pii pair < int , int > # define pll p...