Competitive Programming

Solution for various type of problems with C and C++.

Various Work

Work with other language or project without C and C++.

Linux Operating System

Needed some Linux software or apps or feature when i use LOS.

Shipu's Itrami

Timepass aa ami r amar gumonto protivha, kothakabbo r tumi.

Lightoj 1135 – Count the Multiples of 3

Problem Link Solution :- Count the Multiples of 3 C++ #include <bits/stdc++.h> using namespace std; #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() #define coff ios_base::sync_with_stdio(0); #define ff first #define se second #define pb push_back #define sz(a) ((int)a.size()) #define ST(v) sort(all(v)) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define cover(a,d) memset(a,d,sizeof(a)) #define popcount(i) __builtin_popcount(i) //count one. in long long use __builtin_popcountll(i) #define parity(i) __builtin_parity(i) //evenparity 0 and odd parity 1 #define btz(a) __builtin_ctz(a) //count binary trailling zero #define un(v) ST(v), (v).erase(unique(all(v)),v.end()) #define common(a,b) ST(a), ST(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end()) #define uncommon(a,b) ST(a), ST(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end()) typedef long long ll; typedef unsigned long long ull; template <typename T>string toString( T Number ){stringstream st;st << Number;return st.str();} int stringconvert(string s){int p; istringstream st(s); st>>p ; return p;} //upper bound and lower bound #define LB(a,value) (lower_bound(all(a),value)-a.begin()) #define UB(a,value) (upper_bound(all(a),value)-a.begin()) //Debug #define dbg(x) cout<<#x<<'='<<x<<endl; #define dbgarr(i,a) cout<<#a<<"["<<i<<"] = "<<a[i]<<" "<<endl; #define nl puts("") //File input/output #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) ll bigmod(ll a,ll b, ll m) { ll res = 1; while(b) { if(b & 1) { res = ( (res % m) * (a % m) ) %m ; } a= ((a%m) * (a%m)) %m; b >>= 1; } return res; } ll modInverse(ll a, ll m){return bigmod(a,m-2,m);} ////============ CONSTANT ===============//// #define inf 1<<30 //infinity value #define eps 1e-9 #define mx 100009 #define mod 1000000007 ////=====================================//// struct info //for combine single update segment tree and range update segment tree { int zero,one,two,lazy; }tree[6*mx]; void update_lazy(int node) { int temp = tree[node].zero; tree[node].zero=tree[node].two; tree[node].two=tree[node].one; tree[node].one=temp; } void update_node(int node,int left) { tree[left].lazy += tree[node].lazy; tree[left+1].lazy += tree[node].lazy; tree[node].lazy%=3; int shift = tree[node].lazy; while(shift) {... read more

Lightoj 1255 – Substring Frequency

Problem Link Solution :- Substring Frequency C++ /****************************************************************** *** Problem : *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Team : BUBT_Psycho *** *** My Blog : http://shipuahamed.blogspot.com *** *** Facebook : http://www.facebook.com/DeesheharaShipu *** ******************************************************************/ #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <stack> #include <queue> #include <vector> #include <utility> #include <string> #include <sstream> #include <iostream> #include <set> #include <map> #include <algorithm> #include <memory.h> #include <functional> #include <numeric> #include <bits/stdc++.h> using namespace std; #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() #define CP(a) cout<<a<<endl #define CPN(a) cout<<a<<" " #define ff first #define se second #define pb push_back #define ST(v) sort(all(v)) #define sz(x) (int)x.size() #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define maxall(v) *max_element(all(v)) #define minall(v) *min_element(all(v)) #define sqr(a) ((a)*(a)) #define abs(x) (((x)<0)?-(x):(x)) #define cover(a,d) memset(a,d,sizeof(a)) #define popcount(i) __builtin_popcount(i) //count one. in long long use __builtin_popcountll(i) #define parity(i) __builtin_parity(i) //evenparity 0 and odd parity 1 #define btz(a) __builtin_ctz(a) //count binary trailling zero #define un(v) ST(v), (v).erase(unique(all(v)),v.end()) #define common(a,b) ST(a), ST(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end()) #define uncommon(a,b) ST(a), ST(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end()) typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<string> vs; typedef set<int> si; typedef set<string> ss; typedef map<int,int> mii; typedef map<ll,ll> mll; typedef map<string,int> msi; typedef map<char,int> mci; template <typename T>string toString( T Number ){stringstream st;st << Number;return st.str();} template <typename T> T SOD(T n) {__typeof(n) sum=0;for(__typeof(n) i=1;i*i<=n;i++)sum+=(n%i)?0:((i*i==n)?i:i+n/i);return sum;} //For Define #define forab(i,a,b) for(__typeof(b) i=(a);i<=(b);i++) #define for0(i,n) forab(i,0,(n)-1) #define for1(i,n) forab(i,1,n) #define rforab(i,b,a) for(__typeof(b) i=(b);i>=(a);i--) #define rfor0(i,n) rforab(i,(n)-1,0) #define rfor1(i,n) rforab(i,n,1) #define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++)... read more

কাস্টমাইজ ডেস্কটপ using Cairo-Dock

উপরের ছবির মত তুমি যদি চাও তোমার উবুন্টু ডেস্কটপে এমন কিছু থাকবে সেজন্য নিচের স্টেপগুলো দেখো : প্রথমে টার্মিনাল ওপেন করতে হবে ……………  টার্মিনাল ওপেন করতে Ctrl+Alt+T  press করো  । তারপর নিচের কমান্ডগুলো একটির পর একটি টার্মিনালে পেস্ট করে Enter press করো : Command C++ sudo add-apt-repository ppa:cairo-dock-team/ppa sudo apt-get update sudo apt-get install cairo-dock cairo-dock-plug-ins 123 sudo add-apt-repository ppa:cairo-dock-team/ppasudo apt-get updatesudo apt-get install cairo-dock cairo-dock-plug-ins cairo- dock search করো নিচের ছবির মতো । তারপর cairo- dock ওপেন করো …  তারপর ডেস্কটপে গেলেই দেখবে cairo-dock চলে আসছে … যেটা ইন্সটাল হয়েছে সেটা Cairo-Dock 3.2 version । কিভাবে ইউজ করতে হবে সেটা তুমি নিজে একটু ঘাটা ঘাটি করলেই বুজতে পারবে । বিস্তারিত জানতে এখানে ক্লিক করও । এখন দেখা যাবে কম্পিউটার রিস্টার্ট দেয়ার পর Cairo Dock খুঁজে পাওয়া যাচ্ছে না ……  কম্পিউটার স্টার্ট হলে যেন Cairo-Dock auto – ওপেন হয় তার জন্য নিচের ধাপগুলো দেখো : কমান্ডটা টার্মিনালে পেস্ট করো …… আবারো টার্মিনাল ওপেন করতে হবে ……………  টার্মিনাল ওপেন করতে Ctrl+Alt+T  press করো  । তারপর নিচের কমান্ডটি টার্মিনালে পেস্ট করে Enter press করো : sudo gedit ~/.config/autostart/cairo-dock.desktop 1 sudo gedit ~/.config/autostart/cairo-dock.desktop সবার শেষে নিচের লেখাটা পেস্ট করে সেভ করো …… নিচের ছবিতে উদাহরণ দিলাম … X-GNOME-Autostart-Delay=20 1 X-GNOME-Autostart-Delay=20 Cairo Dock ড্যাশ থেকে Open করো । তারপর ডেস্কটপে Cairo Dock -এ Application menu –>System Tools –> Preference –> Startup Applications –> Add -এ ক্লিক করে Name : Cairo Dock 1 Cairo Dock Command : sh -c "sleep 30; exec cairo-dock -o" 1 sh -c "sleep 30; exec cairo-dock -o" এর পর Add button-এ ক্লিক করে কম্পিউটার restart দাও... read more

Uva 572 – Oil Deposits

Problem Link Solution :- Oil Deposits C++ /****************************************************************** *** Problem : *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Team : BUBT_Psycho *** *** My Blog : http://shipuahamed.blogspot.com *** *** Facebook : http://www.facebook.com/DeesheharaShipu *** ******************************************************************/ #include <bits/stdc++.h> using namespace std; #define ll long long #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() //input #define si(t) scanf("%d",&t) #define sl(t) scanf("%lld",&t) #define sf(t) scanf("%f",&t) #define sdb(t) scanf("%lf",&t) #define schar(c) scanf("%c",&c) #define sstring(s) scanf("%s",s) #define ssi(a,b) scanf("%d%d",&a,&b) #define ssl(a,b) scanf("%lld%lld",&a,&b) //Output #define P(a) printf("%d\n",a) #define PL(a) printf("%lld\n",a) #define PF(a) printf("%f\n",a) #define PDB(a) printf("%lf\n",a) #define PN(a) printf("%d ",a) #define PLN(a) printf("%lld ",a) #define PFN(a) printf("%f ",a) #define PDBN(a) printf("%lf ",a) #define CP(a) cout<<a<<endl #define CPN(a) cout<<a<<" " //Test Case & New line #define Case(no) printf("Case %d: ",++no) #define nl puts("") #define ff first #define se second #define pb push_back #define ppb pop_back #define mkp(a,b) make_pair(a,b) #define ST(v) sort(all(v)) #define sz(x) (int)x.size() #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define maxall(v) *max_element(all(v)) #define minall(v) *min_element(all(v)) #define cover(a,d) memset(a,d,sizeof(a)) #define popcount(i) __builtin_popcount(i) //count one #define parity(i) __builtin_parity(i) //evenparity 0 and odd parity 1 #define input freopen("in.txt","r",stdin) #define output freopen("out.txt","w",stdout) #define un(v) ST(v), (v).erase(unique(all(v)),v.end()) #define common(a,b) ST(a), ST(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end()) #define uncommon(a,b) ST(a), ST(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end()) typedef vector<int> vi; typedef vector<ll> vl; typedef vector<string> vs; typedef pair<int,int> pii; typedef vector<pii> vpii; typedef set<int> si; typedef set<string> ss; typedef map<int,int> mii; typedef map<string,int> msi; //For Define #define for0(i,n) for(__typeof(n) i=0;i<(n);i++) #define for1(i,n) for(__typeof(n) i=1;i<=(n);i++) #define rfor0(i,n) for(__typeof(n) i=(n);i>=0;i--) #define rfor1(i,n) for(__typeof(n) i=(n);i>=1;i--) #define For(i,a,b) for(__typeof(b) i=a;i<=b;i++) #define forstl(i,s) for(__typeof((s).end()) i=(s).begin(); i != (s).end();... read more

টার্মিনাল থেকে ব্রডব্যান্ড কানেকশন

স্টেপগুলো একটার পর একটা অনুসরণ করো : প্রথমে টার্মিনাল ওপেন করতে হবে ……………  টার্মিনাল ওপেন করতে Ctrl+Alt+T  press করো  । তারপর নিচের কমান্ডটি টার্মিনালে পেস্ট করে Enter press করো : sudo pppoeconf 1 sudo pppoeconf Yes press করো……… Yes press করো……… তোমার ISP ইমেইল অথবা উজার নেম তোমার ISP password দাও ………… Ok করার পর বাকি সব Yes press করবে  । এর পর যাই আসুক browser open করে যে কোন ওয়েব সাইট ভিসিট করে চেক করে নাও যে নেট কানেকশন হয়েছে কি না , যদি কানেকশন হয়ে থাকে তাহলে আর কখনোই Connect বা অন্য কিছু করতে হবে না । তোমার কম্পিউটার start হলে নেট auto কানেকশন হবে যদি না তোমার ISP কোন সমস্যা না থাকে । আরেকটা পোস্টে টার্মিনাল ছাড়া Broadband Connection কিভাবে করা যায় সেটা দেখাবো ইন শাহ্‌ আল্লাহ্‌ ।  ... read more

Uva 10004 – Bicoloring

Problem Link   BFS Solution :- Bicoloring C++ /****************************************************************** *** Problem Setter: Miguel Revilla *** *** Uva Problem No: 10004 *** *** Problem Name : Bicoloring *** *** Type : Graph theory,BFS,DFS,Bipartite graphs *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Facebook : http://www.facebook.com/DeesheharaShipu *** ******************************************************************/ #include <queue> #include <cstdio> #include <vector> #include <cstring> #include <iostream> using namespace std; #define pf printf #define pb push_back #define sii(t) scanf("%d",&t) #define ssii(a,b) scanf("%d%d",&a,&b) #define cover(a,d) memset(a,d,sizeof(a)) int main() { int n,e,p; while(sii(n)) { if(n==0) break; sii(e); vector<int>ed[100000]; int color[10000]; cover(color,-1); for(int i=0;i<e;i++) { int x,y; ssii(x,y); ed[x].pb(y); ed[y].pb(x); } queue<int>work; int f=0; color[0]=0; work.push(0); while(!work.empty()) { p=work.front(); work.pop(); int vsize=ed[p].size(); for(int i=0;i<vsize;i++) { if(color[ed[p][i]]==-1) { if(color[p]==0) color[ed[p][i]]=1; else color[ed[p][i]]=0; work.push(ed[p][i]); } else { if(color[ed[p][i]]==color[p]){ f=1; break; } } } if(f==1) break; } if(f==1) pf("NOT BICOLORABLE.n"); else pf("BICOLORABLE.n"); } return 0; } 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 /*********************************************************************   Problem Setter: Miguel Revilla                            ******   Uva Problem No: 10004                                     ******   Problem Name  : Bicoloring                                ******   Type          : Graph theory,BFS,DFS,Bipartite graphs     ******   Author        : Shipu Ahamed (Psycho Timekiller)          ******   E-mail        : shipuahamed01@gmail.com                   ******   University    : BUBT,Dept. of CSE                         ******   Facebook      : http://www.facebook.com/DeesheharaShipu   *********************************************************************/ #include <queue>#include <cstdio>#include <vector>#include <cstring>#include <iostream> using namespace std; #define pf printf#define pb push_back#define sii(t) scanf("%d",&t)#define ssii(a,b) scanf("%d%d",&a,&b)#define cover(a,d) memset(a,d,sizeof(a)) int main(){     int n,e,p;    while(sii(n))    {         if(n==0)        break;        sii(e);        vector<int>ed[100000];        int color[10000];        cover(color,-1);         for(int i=0;i<e;i++)        {            int x,y;            ssii(x,y);            ed[x].pb(y);            ed[y].pb(x);        }         queue<int>work;        int f=0;        color[0]=0;        work.push(0);         while(!work.empty())        {            p=work.front();            work.pop();            int vsize=ed[p].size();            for(int i=0;i<vsize;i++)            {                if(color[ed[p][i]]==-1)                {                    if(color[p]==0)                     color[ed[p][i]]=1;                    else                    color[ed[p][i]]=0;                     work.push(ed[p][i]);                }                else                {                    if(color[ed[p][i]]==color[p]){                        f=1;                        break;                    }                }            }            if(f==1)                break;        }        if(f==1)        pf("NOT BICOLORABLE.n");        else        pf("BICOLORABLE.n");    }     return 0;}   DFS Solution :- Bicoloring C++ /****************************************************************** *** Problem Setter: Miguel Revilla *** *** Uva Problem No: 10004 *** *** Problem Name : Bicoloring *** *** Type : Graph theory,BFS,DFS,Bipartite graphs *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Facebook... read more

Uva 108 – Maximum Sum

Problem Link Solution :- Maximum Sum C++ /****************************************************************** *** Problem : *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Team : BUBT_Psycho *** *** My Blog : http://shipuahamed.blogspot.com *** *** Facebook : http://www.facebook.com/DeesheharaShipu *** ******************************************************************/ #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <stack> #include <queue> #include <vector> #include <utility> #include <string> #include <sstream> #include <iostream> #include <set> #include <map> #include <algorithm> #include <memory.h> #include <functional> #include <numeric> #include <bits/stdc++.h> using namespace std; #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() //input #define si(t) scanf("%d",&t) #define sl(t) scanf("%lld",&t) #define sf(t) scanf("%f",&t) #define sd(t) scanf("%lf",&t) #define sc(c) scanf("%c",&c) #define sii(a,b) scanf("%d%d",&a,&b) #define sll(a,b) scanf("%lld%lld",&a,&b) //Output #define P(a) printf("%dn",a) #define PL(a) printf("%lldn",a) #define PF(a) printf("%fn",a) #define PD(a) printf("%lfn",a) #define PS(a) printf("%sn",a) #define PSN(a) printf("%s ",a) #define PN(a) printf("%d ",a) #define PLN(a) printf("%lld ",a) #define PFN(a) printf("%f ",a) #define PDN(a) printf("%lf ",a) #define PP(a,b) printf("%d %dn",a,b) #define PPN(a,b) printf("%d %d ",a,b) #define PPL(a,b) printf("%lld %lldn",a,b) #define PPLN(a,b) printf("%lld %lld ",a,b) #define CP(a) cout<<a<<endl #define CPN(a) cout<<a<<" " #define ff first #define se second #define pb push_back #define ST(v) sort(all(v)) #define sz(x) (int)x.size() #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define maxall(v) *max_element(all(v)) #define minall(v) *min_element(all(v)) #define sqr(a) ((a)*(a)) #define abs(x) (((x)<0)?-(x):(x)) #define cover(a,d) memset(a,d,sizeof(a)) #define popcount(i) __builtin_popcount(i) //count one. in long long use __builtin_popcountll(i) #define parity(i) __builtin_parity(i) //evenparity 0 and odd parity 1 #define btz(a) __builtin_ctz(a) //count binary trailling zero #define un(v) ST(v), (v).erase(unique(all(v)),v.end()) #define common(a,b) ST(a), ST(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end()) #define uncommon(a,b) ST(a), ST(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end()) typedef long long ll; typedef unsigned long long ull; typedef vector<int>... read more

Uva 191 – Intersection

Problem Link Solution :- Intersection C++ /****************************************************************** *** Problem : *** *** Author : Shipu Ahamed (Psycho Timekiller) *** *** E-mail : shipuahamed01@gmail.com *** *** University : BUBT,Dept. of CSE *** *** Team : BUBT_Psycho *** *** My Blog : http://shipuahamed.blogspot.com *** *** Facebook : http://www.facebook.com/DeesheharaShipu *** ******************************************************************/ #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <stack> #include <queue> #include <vector> #include <utility> #include <string> #include <sstream> #include <iostream> #include <set> #include <map> #include <algorithm> #include <memory.h> #include <functional> #include <numeric> #include <bits/stdc++.h> using namespace std; #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() //input #define si(t) scanf("%d",&t) #define sl(t) scanf("%lld",&t) #define sf(t) scanf("%f",&t) #define sd(t) scanf("%lf",&t) #define sc(c) scanf("%c",&c) #define sii(a,b) scanf("%d%d",&a,&b) #define sll(a,b) scanf("%lld%lld",&a,&b) //Output #define P(a) printf("%dn",a) #define PL(a) printf("%lldn",a) #define PF(a) printf("%fn",a) #define PD(a) printf("%lfn",a) #define PS(a) printf("%sn",a) #define PSN(a) printf("%s ",a) #define PN(a) printf("%d ",a) #define PLN(a) printf("%lld ",a) #define PFN(a) printf("%f ",a) #define PDN(a) printf("%lf ",a) #define PP(a,b) printf("%d %dn",a,b) #define PPN(a,b) printf("%d %d ",a,b) #define PPL(a,b) printf("%lld %lldn",a,b) #define PPLN(a,b) printf("%lld %lld ",a,b) #define CP(a) cout<<a<<endl #define CPN(a) cout<<a<<" " #define ff first #define se second #define pb push_back #define ST(v) sort(all(v)) #define sz(x) (int)x.size() #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define maxall(v) *max_element(all(v)) #define minall(v) *min_element(all(v)) #define sqr(a) ((a)*(a)) #define abs(x) (((x)<0)?-(x):(x)) #define cover(a,d) memset(a,d,sizeof(a)) #define popcount(i) __builtin_popcount(i) //count one. in long long use __builtin_popcountll(i) #define parity(i) __builtin_parity(i) //evenparity 0 and odd parity 1 #define btz(a) __builtin_ctz(a) //count binary trailling zero #define un(v) ST(v), (v).erase(unique(all(v)),v.end()) #define common(a,b) ST(a), ST(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end()) #define uncommon(a,b) ST(a), ST(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end()) typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi;... read more

Shipu’s Blog on Facebook

Recent comments

code_canyon_300x250