Example #1
0
int main() {
    ifstream in("/home/joshua/Downloads/s4.4.in");
    while(1) {
        done=0;
        int N;
        in>>N;
        if(!N) break;
        for(int i=0;i<32609;i++) MHASH[i].clear();
        _.clear();
        m.clear();
        int X;
        for(int i=0;i<N;i++) {
            place p,v;
            in>>X;
            p.push_back(X);
            _.push_back(p);
            v.push_back(i+1);
            m.push_back(v);
        }
        superhash=hash(m);
        recurse(_,0);
        while(Q.size()) {
            state l=Q.front().first;
            int m=Q.front().second;
            Q.pop_front();
            recurse(l,m);
        }
        bool ok=0;
        for(set<gstate>::iterator it=MHASH[superhash].begin();it!=MHASH[superhash].end();++it) {
            if((*it).first==m) { ok=1; cout<< ((*it).second)<<endl; break; }
        }
        if(!ok) cout<<"IMPOSSIBLE"<<endl;
    }
}
Example #2
0
void PTS::phase_add_ttls(state& the_state, double p) const {
  unsigned int binary_code=phase_ttl_values(p);
  std::vector<ttlout>::const_iterator mask=ttl_masks.begin();
  while (mask!=ttl_masks.end()) {
    /* obeye negative logic */
    if ((binary_code & 1<<11)==0 ^ negative_logic==0) the_state.push_back(mask->copy_new());
    binary_code<<=1;
    binary_code&=0xFFF;
    ++mask;
  }
  if (binary_code!=0) fprintf(stderr,"Warning! Insufficient phase precision for %f\n",p);
}