পোস্টগুলি

SPOJ-INVERSE-SORT

Problem Algorithm: We have to generate  10!  combination of " abcdefghij  " by reversing and put appropriate distance from " abcdefghij  " So we need  key(string)->value  data structure. First thing comes to our mind is map<string,int> But it uses O(logN) time to insert a value as everything is ordered here So we use unordered_map ( Normally o(1) highest o(n) barely )  After that we take 2 string input and then find the relative string S from s1->s2 and another AC!! CODE Time needed 40-45sec .

C++ Class

ছবি
> Abstraction >E ncapsulation   /Access Modifiers >Inheritance #include <iostream> using namespace std; class vehicle { public:     vehicle()     {         cout<<"this is a constructor of vehicle"<<endl;     }     ~vehicle()     {         cout<<"this is a deconstructor of vehicle"<<endl;     } }; class fourwheeler { public:     fourwheeler()     {         cout<<"this is the constructor of fourwheeler"<<endl;     }     fourwheeler(string x)     {         cout<<"This is another constructor which has "<<x<<" with it"<<endl;     }     ~fourwheeler()     {         cout<<"this is deconstructor of fourwheeler"<<endl;     } }; //Single Inheritanc e class Car: public vehicle {     public:     Car()     {         cout<<"this is a derrived child class from vehicle 's constructor"&l

lightOJ-1072 Calm Down

Statement  #include<bits/stdc++.h> using namespace std; #define sf(a)                   scanf("%I64d",&a) #define sff(a,b)                scanf("%I64d %I64d",&a,&b) #define sfff(a,b,c)             scanf("%I64d %I64d %I64d",&a,&b,&c) #define sffff(a,b,c,d)          scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d) #define sfffff(a,b,c,d,e)       scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e) #define read                    freopen("input.txt","r",stdin) #define write                   freopen("output.txt","w",stdout) #define ll                      long long #define MAX                     1000009 #define Max                     100000000009 #define pb                      push_back #define all(c)                  c.begin(),c.end() #define mset(a,b)               memset(a,b,sizeof(a)) #define MOD

LightOJ - 1006 - Hex-a-bonacci

Statment #include<bits/stdc++.h> using namespace std; #define sf(a)                   scanf("%I64d",&a) #define sff(a,b)                scanf("%I64d %I64d",&a,&b) #define sfff(a,b,c)             scanf("%I64d %I64d %I64d",&a,&b,&c) #define sffl(a,b,c)             scanf("%lld %lld %lld",&a,&b,&c) #define sffff(a,b,c,d)          scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d) #define sfffff(a,b,c,d,e)       scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e) #define read                    freopen("input.txt","r",stdin) #define write                   freopen("output.txt","w",stdout) #define ll                      long long #define MAX                     1000009 #define Max                     100000000009 #define pb                      push_back #define all(c)                  c.begin(),c.end(

Subset Generator Using Bit Manipulation

#string int main() {    string a="AiKichi";    for(ll i=0;i<(1<<a.length());++i)    {        for(ll j=0;j<a.length();j++)        {            if(i & (1<<j))             cout<<a[j]<<" ";        }        cout<<endl;    } } #int_array int main() {    long long a[]={1,2,3,4,5,6};    long long n=sizeof(a)/sizeof(a[0]);    for(ll i=0;i<(1<<n);++i)    {        for(ll j=0;j<n;j++)        {            if(i & (1<<j))             cout<<a[j]<<" ";        }        cout<<endl;    } }

CP3 Exercise 1.2.3//5

#include<bits/stdc++.h> using namespace std; #define sf(a)                   scanf("%I64d",&a) #define sff(a,b)                scanf("%I64d %I64d",&a,&b) #define sfff(a,b,c)             scanf("%I64d %I64d %I64d",&a,&b,&c) #define sffff(a,b,c,d)          scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d) #define sfffff(a,b,c,d,e)       scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e) #define flop(m,n,q)             for(ll i=m;i<n;i+=q) #define read                    freopen("input.txt","r",stdin) #define write                   freopen("output.txt","w",stdout) #define ll                      long long int #define MAX                     1000009 #define Max                     1000000009 #define pb                      push_back #define all(c)                  c.begin(),c.end() #define sloop(a,itr)            for(it

finding out the day of the given WEEK

#include<bits/stdc++.h> using namespace std; #define sf(a)                   scanf("%I64d",&a) #define sff(a,b)                scanf("%I64d %I64d",&a,&b) #define sfff(a,b,c)             scanf("%I64d %I64d %I64d",&a,&b,&c) #define sffff(a,b,c,d)          scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d) #define sfffff(a,b,c,d,e)       scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e) #define flop(m,n,q)             for(ll i=m;i<n;i+=q) #define read                    freopen("input.txt","r",stdin) #define write                   freopen("output.txt","w",stdout) #define ll                      long long int #define MAX                     1000009 #define Max                     1000000009 #define pb                      push_back int day_of_week(int d,int m,int y) {     static int t[]={0,3,2,5,0,3,5,1,4,6,2,4};