Cod sursa(job #3158150)

Utilizator vladmanolescuManolescu Vlad Andrei vladmanolescu Data 17 octombrie 2023 21:15:39
Problema Grigo Scor 0
Compilator cpp-64 Status done
Runda HLO 2023 - Lot - Tema 0 Marime 0.75 kb
#include <iostream>
#include <fstream>
using namespace std;

int x[10], n, m, k = 0;

void Afis()
{
    for (int j = 1; j <= n; j++)
        cout << x[j] << " ";
    cout << endl;
    k++;
}

bool OK(int k)
{
    for (int i = 1; i < k; i++)
        if (x[k] == x[i])
            return false;
    return true;
}

bool Solutie(int k)
{
    return k == n;
}

void back(int k)
{
    if (k > n)
    {
        if (x[m] == n)
            Afis();
        return;
    }
    for (int i = 1; i <= n; i++)
    {
        x[k] = i;
        if (OK(k))
            back(k + 1);
    }
}

int main()
{
    ifstream fin("date.in");
    ofstream fout("date.out");
    fin >> n >> m;
    back(1);
    fout << k % 1000003;
    return 0;
}