记录编号 194961 评测结果 AAAAAAAAAAA
题目名称 窗体面积 最终得分 100
用户昵称 Gravatarmikumikumi 是否通过 通过
代码语言 C++ 运行时间 0.005 s
提交时间 2015-10-17 18:53:09 内存使用 0.32 MiB
显示代码纯文本
#include<cstdio>
#include<set>
#include<vector>
#include<cstring>
#include<deque>
#include<cstring>
#include<map>
#include<algorithm>
#include<iomanip>
#include<iostream>
using namespace std;
const int SIZEN=200;
int tot=0,ma=0,mi=0;
class miku
{
public:
	int xu,yu,yd,xd;//右下角和左上角
	int id,h;
	miku(){}
	miku(int a,int b,int c,int d,int e,int f)
	{
		xu=a,yu=b,xd=c,yd=d,id=e,h=f;
	}
	int sum()
	{
		return (xd-xu)*(yd-yu);
	}
	void print()
	{
		cout<<"id:"<<id<<endl;
		cout<<"xu:"<<xu<<endl;
		cout<<"yu:"<<yu<<endl;
		cout<<"xd:"<<xd<<endl;
		cout<<"yd:"<<yd<<endl;
		cout<<"h:"<<h<<endl;
		cout<<endl;
	}
}P[SIZEN];
int get(char id)
{
	int ans=0;
	if('0'<=id&&'9'>=id) ans=id-'0'+1;
	if('a'<=id&&id<='z') ans=id-'a'+11;
	if('A'<=id&&id<='Z') ans=id-'A'+37;
	return ans;
}
void creat(int id,int xu,int yu,int xd,int yd)
{
	ma++;
	P[++tot]=miku(xu,yu,xd,yd,id,ma);
}
void up(int id)
{
	ma++;
	for(int i=1;i<=tot;i++) if(P[i].id==id) {P[i].h=ma;break;}
}
void down(int id)
{
	mi--;
	for(int i=1;i<=tot;i++) if(P[i].id==id) {P[i].h=mi;break;}
}
void delet(int id)
{
	for(int i=1;i<=tot;i++) if(P[i].id==id) {P[i].id=0;break;}
}
int cut(int now,int xu,int yu,int xd,int yd,int pos)
{
	miku v;
	int ans=0;
	do
	{
		pos++;
		v=P[pos];
	}while(pos<=tot&&(v.id==0||pos==now||v.h<P[now].h||v.xd<=xu||v.yd<=yu||v.xu>=xd||v.yu>=yd));
	if(pos>tot)
	{
		ans+=(xd-xu)*(yd-yu);
		return ans;
	}
	if(v.xu>xu)
	{
		ans+=cut(now,xu,yu,v.xu,yd,pos);
		xu=v.xu;
	}
	if(v.xd<xd)
	{
		ans+=cut(now,v.xd,yu,xd,yd,pos);
		xd=v.xd;
	}
	if(v.yu>yu) ans+=cut(now,xu,yu,xd,v.yu,pos);
	if(v.yd<yd) ans+=cut(now,xu,v.yd,xd,yd,pos);
	return ans;
}
void sum(int id)
{
	miku v;
	int now=0;
	for(int i=1;i<=tot;i++) if(P[i].id==id) v=P[i],now=i;
	now=cut(now,v.xu,v.yu,v.xd,v.yd,0);
	double ans=(double)now/(double)v.sum()*100.0;
	printf("%.3lf\n",ans);
}
bool work()
{
	char cmd;
	cin>>cmd;
	if(cin.eof()) return 0;
	getchar();
	char id;
	int x,y,X,Y;
	//cout<<cmd<<endl;
	if(cmd=='w')
	{
		scanf("%c",&id);
		int nd=get(id);
		getchar();
		scanf("%d",&x);
		getchar();
		scanf("%d",&y);
		getchar();
		scanf("%d",&X);
		getchar();
		scanf("%d",&Y);
		int xu=min(x,X),xd=max(x,X),yu=min(y,Y),yd=max(y,Y);
		//cout<<nd<<" "<<xu<<" "<<yu<<" "<<xd<<" "<<yd<<endl;
		creat(nd,xu,yu,xd,yd);
	}
	else 
	{
		scanf("%c",&id);
		int nd=get(id);
		if(cmd=='t') up(nd);
		else if(cmd=='b') down(nd);
		else if(cmd=='d') delet(nd);
		else if(cmd=='s') sum(nd);
	}
	getchar();
	if(cin.eof()) return 0;
	return 1;
}
int main()
{
	freopen("windowus.in","r",stdin);
	freopen("windowus.out","w",stdout);
	while(work());
	return 0;
}