比赛 20161116 评测结果 AAAAAAAAAA
题目名称 删除他们! 最终得分 100
用户昵称 Hoohan(%Dalao) 运行时间 0.007 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2016-11-16 10:37:27
显示代码纯文本
//deleteit.cpp
//By Hoohan
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int n,m,q;
int now,endx,ans;

void init(){
	cin>>n>>m>>q;
	now=n-1;endx=m-1;ans=n*m;
}

int cal_s(int x1,int y1,int x2,int y2) //x2>x1;y2>y1
{
	if(x1>x2 || y1>y2 || x1<0 || y1<0) return 0;
	return (x2-x1+1)*(y2-y1+1);
}

void del(int s)
{
	ans-=s;
	endx-=s;
	while(endx<0)
	{
		endx+=m;
		now--;
	}
}

void work(){
	int x1,y1,x2,y2;
	int s=0;
	cin>>x1>>y1>>x2>>y2;
//	cout<<"\tx1,x2,y1,y2="<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
	if(x1>now) return;
	else if(x2<now){
		s=cal_s(x1,y1,x2,y2);
		del(s);
		return;
	}
	else{
		if(x1!=now)  {s=cal_s(x1,y1,now-1,y2);}
	 	if(y1<=endx)
	 	{
	 		if(y2>endx) del(endx-y1+1);
	 		else /* if(y2<=endx) */ del(y2-y1+1);
		}
		else del(0);
		del(s);
	}
}

int main()
{
	freopen("deleteit.in","r",stdin);
	freopen("deleteit.out","w",stdout);
	init();
	for(int i=0;i<q;i++)
	{
//		cout<<"Q"<<i<<":";
//		cout<<"\tnow="<<now<<"\tendx="<<endx<<endl;		
		work();
		if(now<0) break;
	}
//	cout<<"Finally:\tnow="<<now<<"\tendx="<<endx<<endl;
//	cout<<cal_s(0,1,0,2)<<endl<<cal_s(0,2,1,2)<<endl;
	cout<<ans<<endl;
	return 0; 
}