/*
ID: niepeng1
PROG: window
LANG: C++
*/
/*矩形切割,要注意不能切割出被观察的矩形*/
#include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define min(x,y) x<y?x:y
#define max(x,y) x>y?x:y
struct Node{
int lx;a
int ly;
int hx;
int hy;
int level;
};
int top=1,bottom=0;
bool cond[256]={false};
Node window[256];
void w(int lx,int ly,int hx,int hy,char i)
{
if(cond[i]==true)
printf("Bad command /n");
else
cond[i]=true;
window[i].hx=hx;
window[i].hy=hy;
window[i].lx=lx;
window[i].ly=ly;
window[i].level=top++;
}
inline void d(char i)
{
if(cond[i]==false)
printf("Bad command /n");
cond[i]=false;
}
inline void b(char i)
{
if(cond[i]==false)
printf("Bad command /n");
window[i].level=bottom--;
}
inline void t(char i)
{
if(cond[i]==false)
printf("Bad command /n");
window[i].level=top++;
}
inline int area(int lx,int ly,int hx,int hy,int level)
{
int j,tem1,tem2,tem3,tem4;
if(ly>=hy||lx>=hx)
return 0;
for(j=0;j<256;j++){
if(cond[j]==true&&window[j].level>level)
if(!
(hy<=window[j].ly || window[j].hy<=ly ||
hx<=window[j].lx || lx >= window[j].hx) )
{
tem1=area(lx,max(ly,window[j].ly),min(window[j].lx,hx),min(hy,window[j].hy),level);
tem2=area(max(lx,window[j].hx),max(ly,window[j].ly),hx,min(hy,window[j].hy),level);
tem3=area(lx,ly,hx,min(hy,window[j].ly),level);
tem4=area(lx,max(ly,window[j].hy),hx,hy,level);
return tem1+tem2+tem3+tem4;
}
}
return (hx-lx)*(hy-ly);
}
inline double s(char i)
{
return area(window[i].lx,window[i].ly,window[i].hx,window[i].hy,window[i].level)*(float)100/((window[i].hx-window[i].lx)*(window[i].hy-window[i].ly));
}
int main()
{
int lx,ly,hx,hy;
char blank,cmd,i;
freopen("window.in","r",stdin);
freopen("window.out","w",stdout);
while(scanf("%c",&cmd)!=EOF){
switch(cmd){
case 'w':
scanf("%c%c%c%d%c%d%c%d%c%d%c%c",&blank,&i,&blank,&lx,&blank,&ly,&blank,&hx,&blank,&hy,&blank,&blank);
w(min(lx,hx),min(ly,hy),max(lx,hx),max(ly,hy),i);
break;
case 's':
scanf("%c%c%c%c",&blank,&i,&blank,&blank);
printf("%.3lf/n",s(i));
break;
case 'd':
scanf("%c%c%c%c",&blank,&i,&blank,&blank);
d(i);
break;
case 'b':
scanf("%c%c%c%c",&blank,&i,&blank,&blank);
b(i);
break;
case 't':
scanf("%c%c%c%c",&blank,&i,&blank,&blank);
t(i);
break;
}
}
return 0;
}