// Does instance A admit any infinite valid schedule (from the all-fresh start) that has an idle day? // Explore ALL reachable states under moves {serve task j, idle}; no pruning except that a // task whose remaining slack hits 0 kills the state. Then greatest fixed point for "alive". // State: r_i in [1..a_i] = number of days (including today) within which task i must be served. #include #include #include #include #define MAXN 16 static int n,a[MAXN]; static uint64_t rad[MAXN]; static uint64_t *keys; static uint8_t *alive; static uint64_t tsize,tmask,cnt=0; static uint64_t enc(const int*r){uint64_t k=0;for(int i=0;i=0;i--){r[i]=k%a[i]+1;k/=a[i];}} static uint64_t hh(uint64_t x){x^=x>>33;x*=0xff51afd7ed558ccdULL;x^=x>>33;x*=0xc4ceb9fe1a85ec53ULL;x^=x>>33;return x;} static int64_t lookup(uint64_t k,int ins){uint64_t i=hh(k)&tmask;while(keys[i]){if(keys[i]==k)return i;i=(i+1)&tmask;}if(!ins)return -1;keys[i]=k;cnt++;if(cnt*2>tsize){fprintf(stderr,"table full\n");exit(2);}return -(int64_t)i-2;} // successor by move j (j==n: idle). returns 0 if illegal static int succ(const int*r,int j,int*o){for(int i=0;i A + (M) unschedulable for every M\n"); return 0; }