Cod sursa(job #102418)

Utilizator the_alch3m1stJeler Stefan the_alch3m1st Data 14 noiembrie 2007 13:14:36
Problema Jocul Flip Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.19 kb
#include<iostream.h>
#include<fstream.h>


typedef int stiva[100];
int n,k,ev,as,a[1<<4][1<<4],N,M,b[1<<4][1<<4],c[1<<16][1<<4];
int suma=0,l=1;
stiva st;
void citire()
{int i,j;
     fstream fin("flip.in",ios::in);
     fin>>N;
     fin>>M;
     for(i=1;i<=N;i++)
     for(j=1;j<=M;j++) fin>>a[i][j];
     fin.close();
     
 }

void init()
{
     st[k]=-1;
}

int succesor()
{
    if(st[k]<1)
    {st[k]=st[k]+1; return 1;}
     else return 0;
     
}

int valid()
{
    return 1;
}

int solutie()
{
    return k==n;
}


     
void tipar()
{   
    for(int i=1;i<=n;i++)c[l][i]=st[i];
    l++;                 
}

void bt()
{
     k=1;
     init();
     while(k>0)
     {
               as=1;ev=0;
               while(as && !ev)
               {
                        as=succesor();
                        if(as) ev=valid();
               }
     if(as)
           if(solutie()) tipar();
                                else {k++;init();}
           else k--;
           
     }
}


void scrie()
{
     fstream fout("flip.out",ios::out);
     fout<<suma;
     fout.close();
}
int main()
{
 citire();
 n=M;
 bt();
 scrie();

}