Count the Overlap by b_jonas

#include<stdio.h>
#include<string.h>
int main(){int x,y,w,h,k=2,u,v,b[9999],p[9]={3,5,6,7};char m[][9]={"ab","ac","bc","abc"};while(3<scanf("%*s%d%*s%d%*s%d%*s%d",&x,&y,&w,&h)){if(!(k=(k+1)%3))for(u=0;u<9999;u++)b[u]=0;for(u=x;u<x+w;u++)for(v=y;v<y+h;v++)b[u+88*v]|=1<<k;if(1<k)for(x=0;x<4;x++){y=0;for(u=0;u<9999;u++)y+=p[x]==(p[x]&b[u]);printf("%s %d%c",m[x],y,2<x?10:32);}}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page