/* SWERC'97 - Island of Logic */ /* 11/6/97 - Matthias Ruhl */ #include #define DIVINE 0 #define EVIL 1 #define HUMAN 2 #define DAY 0 #define NIGHT 1 #define MAXPERSONS 5 #define STATENUM 3*3*3*3*3*2 FILE *inp; char state[STATENUM]; /* Auxiliary functions */ int type(int state, int p) { state /= 2; while(p--) state /= 3; return (state % 3); } int lying(int state, int p) { int daynight,t; daynight = state % 2; t = type(state,p); return (t == EVIL || (t == HUMAN && daynight == NIGHT)); } void init() { int i; for(i=0;i= 0) { printf("%c is %s.\n",i+'A',names[possible[i]]); deduction = 1; } if(daynight >= 0) { printf("It is %s.\n",daynight==DAY?"day":"night"); deduction = 1; } if(!deduction) printf("No facts are deducible.\n"); printf("\n"); } int main() { int i,n; inp = fopen("island.in","r"); while(fscanf(inp,"%d ",&n) && n != 0) { init(); for(i=0;i