#include #include #include "subset.h" #include "input.h" #include "output.h" //Prints the output as explained in 2.2 of of Borrels.pdf void printOutput(Input* in, Output* out){ for(int h=0;hm-1;h++){ printf("%d,", out->s[h]+1); } printf("%d\n",out->s[in->m-1]+1); for(int i=0;in;i++){ for(int j=0;jnI[i];j++){ bool first = true; for(int k=0;kobl[i][j].n;k++){ if(out->obl[i][j].elem[k]){ if(!first)printf(","); first = false; printf("%d",k+in->I[i][j].r+1); } } printf("\n"); } } printf("%d\n",out->maxTotAtt); } Output initOutput(Input* in){ Output r; r.maxTotAtt = -1; r.s = malloc(sizeof(int)*in->m); r.obl = malloc(sizeof(Subset*)*in->n); r.borrelAtTime = malloc(sizeof(bool)*in->t); for(int h=0;hm;h++){ r.s[h] = 0; } for(int i=0;in;i++){ r.obl[i] = malloc(sizeof(Subset)*in->nI[i]); for(int j=0;jnI[i];j++){ subsetInit(r.obl[i]+j, in->I[i][j].d-in->I[i][j].r+1); } } r.in = in; return r; } void copyOutput(Output* from,Output* to){ //Because the input never changes, it does not need to copy the input for(int i=0;iin->n;i++) for(int j=0;jin->nI[i];j++) to->obl[i][j] = from->obl[i][j]; for(int h=0;hin->m;h++) to->s[h] = from->s[h]; for(int i =0; iin->t; i++) to->borrelAtTime[i]=from->borrelAtTime[i]; to->maxTotAtt = from->maxTotAtt; }