Posts

CF: 381Div1 ( Sack, DSU on Tree )

CF: 381Div1 ( Sack, DSU on Tree ) ///==================================================/// /// 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 OnBit ( i ) __builtin_popcount(i) ///----------------------------------- # 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: 138-D World of Darkraft ( Game Theory )

CF : 138 - D World of Darkraft ( Game Theory ) /// Given Matrix of 'L', 'R' or 'X' characters /// Move is: /// 1.) if choose 'L' remove containing second diagnonal /// 2.) if choose 'R' remove containing main diagonal /// 3.) if choose 'X' remove containing both diagonals /// We have to print, If you move first, will you WIN or LOSE? /// Idea: is of Representing both diagonals in DP /// then give all possible move and partision grid /// onto diagnonals & finally find out MEX of all /// dp returns calls; ///==================================================/// /// HELLO WORLD !! /// /// IT'S ME /// /// BISHAL GAUTAM /// /// [ bsal.gautam16@gmail.com ] /// ///==================================================/// #include <bits / stdc + + .h> #define X first #define Y second #defin...

CF Div2-88E Interesting Game( Game theory )

CF div2-88E Interesting Game ( Game theory ) ///==================================================/// /// 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) ///------------------------------------ # define all (...

13154 - Extreme XOR Sum (Observation, Precal )

UVA  13154 - Extreme XOR Sum (Observation, Precal ) /// Story Behind This Problem!! /// As problem pattern was similar to another problem which I had faced /// recently on HackerRank( XOR MATRIX ) /// I easily figured out the pattern of NcR. Main Problem was with complexity!! /// But, this problem luckily passed within 2 sec, as there was not strong pretests. /// I heard after contest that complexity can be reduced to O( q*sqrt(n) ). I have no /// proper idea of this Sqrt decomposition solution. /// My solution is based on following idea: /// 1. Observe the patten for different length. /// 2. If ncr[ len ][ j ] is odd then include jth item of that len otherwise exclude. /// 3. Now, As XOR follows cummulative property answer each xor sum of subsegment /// containing odd values only on that len. ///==================================================/// /// HELLO WORLD !! /// /// IT'S ME /// /// ...

HackerEarth: Mojo,Jojo and Game( Game Theory )

HackerEarth: Mojo,Jojo and Game( Game Theory ) ///==================================================/// /// 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) ///------------------------------------ # define all...

UVA 10319 - Manhattan ( 2SAT, SCC )

UVA 10319 - Manhattan ( 2SAT, SCC ) /// Is there is a way to assign direction of all rows /// and Column such that there will be a way to reach /// from every (a,b) to (c,d)? /// Idea: for each location to reach from (a,b) to (c,d) /// either we have to go from dir of (a&d) or (b&c), which /// is further reducible to (a|b) & (a&c) & (d|b) & (d&c) ///==================================================/// /// 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> ///-...

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) // /-------------------------------...