//In the name of GOD #include #include #include #include #define MAX 35 using namespace std; int numparts=0,m,n,ans[MAX][MAX],numans,part[2][MAX],M,N; ofstream fout; string ncast(int x){ string s; if(!x) return "0" ; for (;x; s=char((x%10)+'0')+s , x/=10); return s; } const char* Filename(int x,int y,string t){ string s=ncast(x)+t+ncast(y)+(string)(".txt"); const char *filename=s.c_str(); return filename; } void print(){ numans++; for (int i=0;i> mat; int t1=0,t2=0; for (int dd=0;dd> r[i][j]; if (km/2) return false; return true; } void solve(){ if (m!=M || n!=N || check()) bt(0,0); } void partition(int x,int y,int maxx,int maxy){ if (!x && !y) solve(); if (!x || !y || !maxy || x>y) return ; if (maxy<=y) for (int i=1;i<=maxx && i<=x && i<=maxy;++i){ part[0][numparts]=i; part[1][numparts]=maxy; numparts++; partition(x-i,y-maxy,i,maxy); numparts--; } partition(x,y,x,maxy-1); } void Total_Partition(int x,int y){ fout.open("output.txt"); numans=0; m=x;n=y; numparts=0; partition(x,y,x,y); part[0][0]=1; part[1][0]=0; numparts=1; partition(x-1,y,x-1,y); fout.close(); ifstream in ("output.txt"); ofstream out (m==M && n==N ? Filename(m,n,"result") : Filename(m,n,"comp")); out << numans << endl; for (int i=0;i> bl; out << bl << ' '; } in.close(); out.close(); } int main(){ cout << "Enter the number of different rows(Haplotypes)"<> M ; cout << "Enter the number of different columns(SNPs)"<> N ; if (M>N+1 || M==1 && N==1){ ofstream out (Filename(M,N,"result")); out << 0 << endl; out.close(); return 0; } Total_Partition(1,1); Total_Partition(2,1); for (int i=2;i<=N;++i) for (int j=1;j<=i+1 && j<=M/2;++j) Total_Partition(j,i); Total_Partition(M,N); }