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;
void run(int n_run) {
if (n_run >= LEN) {
//cout << "Trovata\n";
for (int x = 0; x < n_run; x++) {
printf("%d ", cell[x]);
}
printf("\n");
return;
}
for (int color = 0; color < 2; color++) {
if (deny[color][n_run] > 0) continue;
cell[n_run] = color;
for (int cell_before = max(0, (3*n_run -(LEN - 1)) / 2); cell_before < n_run; cell_before++) {
if (cell[cell_before] == color) {
warn[color][2*n_run - cell_before][warn_n[color][2*n_run - cell_before]] = 3*n_run - 2*cell_before;
warn_n[color][2*n_run - cell_before]++;
}
}
for (int denial = 0; denial < warn_n[color][n_run]; denial++) {
deny[ color ][ warn[ color ][ n_run ][ denial ]]++;
}
run(n_run+1);
for (int denial = 0; denial < warn_n[color][n_run]; denial++) {
deny[ color ][ warn[ color ][ n_run ][ denial ]]--;
}
for (int cell_before = max(0, (3*n_run -(LEN - 1)) / 2); cell_before < n_run; cell_before++) {
if (cell[cell_before] == color) {
warn_n[color][2*n_run - cell_before]--;
warn[color][2*n_run - cell_before][warn_n[color][2*n_run - cell_before]] = 0;
}
}
if ((n_run == 0) && (color == 0)) {
debug++;
}
}
cell[n_run] = -1;
#if 0
if ((deny[0][n_run] > 0) && (deny[1][n_run] > 0)) {
printf("Dead end at %d\n", n_run);
for (int x = 0; x < n_run; x++) {
printf("%d ", cell[x]);
}
printf("\n\n");
}
#endif
}
int main()
{
cout<<"Hello World\n";
for (int x = 0; x < LEN; x++) {
cell[x] = -1;
}
for (int x = 0; x < 2; x++) {
for (int y = 0; y < LEN; y++) {
for (int z = 0; z < 50; z++) {
warn[x][y][z] = 0;
}
}
}
for (int x = 0; x < 2; x++) {
for (int y = 0; y < LEN; y++) {
warn_n[x][y]= 0;
deny[x][y]= 0;
}
}
run(0);
return 0;
}
3m0o ha scritto:Ecco provate questo: Colorare \( \mathbb{N} \) con due colori in modo tale che non esiste una progressione aritmetica infinita colorata tutta con lo stesso colore.
A*A*A**A**A**A***A***A***A***A...
Visitano il forum: Nessuno e 1 ospite