Pagini recente » Cod sursa (job #3032488) | Istoria paginii runda/vacanta_11_3 | Cod sursa (job #3187626) | Cod sursa (job #380522) | Cod sursa (job #2831124)
#include <fstream>
#include <cstring>
#include <vector>
#define nmax 11
using namespace std;
ifstream fin("copii.in");
ofstream fout("copii.out");
int x[12], mx[12];
int cnt = 0;
int ct;
char s[nmax][nmax];
bool verif(int nr) {
if (nr == 1) return 0;
int graf_echipe[nmax][nmax] = {0};
for (int i = 1; i <= ct; ++i)
for (int j = 1; j <= ct; ++j)
if (s[i][j] == '1') {
graf_echipe[x[i]][x[j]] = 1;
}
for (int i = 1; i <= nr; ++i) {
for (int j = 1; j <= nr; ++j) {
if (i != j && graf_echipe[i][j] == 0) return 0;
}
}
return 1;
}
void Back(int k, int n) {
if (k == ct + 1) cnt += verif(n);
else {
for (int i = 1; i <= n + 1; i++) {
x[k] = i;
if (i <= n) Back(k + 1, n);
else Back(k + 1, n + 1);
}
}
}
int main() {
fin >> ct;
for (int i = 1; i <= ct; ++i) {
fin >> (s[i] + 1);
}
Back(1, 0);
fout << cnt;
return 0;
}