//Squares // 2005 ECNA ACM contest // t feil #include using namespace std; #define DEBUG false int rooms[1000][4], n; //count squares in n by m rectangle int CountSq(int n, int m){ int count=0, temp; if(n>m){ temp=n; n=m; m=temp;} for(int i=0;i=(y2-2) || b2<=(y1+2))) return true; else return false; else return false; } //count squares overlapping in both rooms int CountCommonSq(int x1, int y1, int x2, int y2, int a1, int b1, int a2, int b2){ int left, right, width; //if A meets on soutside or northside if(overlap(x1,y1,y2,a2,b1,b2) || overlap(x2,y1,y2,a1,b1,b2)){ left = (y1+1>b1+1 ? y1+1 : b1+ 1); right = (y2-1a1+1 ? x1+1 : a1+1); right = (x2-1>n; while(n>0){ count=0; for(int i=0;i>x1>>y1>>x2>>y2; if(x1>rooms[i][j]; } //first count squares in all the rooms for(int i=0;i>n; } return 0; }