Cod sursa(job #2129771)

Utilizator GeorgeCalinPetruta George-Calin GeorgeCalin Data 13 februarie 2018 08:52:03
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.25 kb
#include <fstream>
#define nmax 17
#define mmax 23
using namespace std;
ifstream fin("immortal.in");
ofstream fout("immortal.out");

struct nod{
    int p,z;
}v[nmax];

struct lin{
    int l,c;
};
lin depl[5]={{1,0},{0,1},{-1,0},{0,-1}};

int x[nmax];
int a[mmax][mmax],n,m,k,q;

int cond()
{
    int lin=v[x[q]].p;
    int col=v[x[q]].z;
    if()
}

int bkt2()
{
    q=1;
    while(q)
    {
        if(l[q]<4)
        {
            l[q]++;
            if(cond())
            {
                if(q==n-1)
                {
                    afis();
                    return 1;
                }
                else
                {
                    q++;
                    l[q]=0;
                }
            }
        }
        else
            q--;
    }
    return 0;
}


void bkt()
{
    k=1;
    while(k)
    {
        if(x[k]<n)
        {
            x[k]++;
            if(k==n-1)
            {
                if(bkt2())
                    return;
            }
            else
            {
                k++;
                x[k]=x[k-1];
            }
        }
        else
            k--;
    }
}

int main()
{
    fin>>n>>m>>q;
    for(int i=1;i<=q;i++)
    {
        fin>>v[i].p>>v[i].z;
        a[v[i].p][v[i].z]=1;
    }
    bkt();
    return 0;
}