比赛 20161116 评测结果 AAAAAAAAAA
题目名称 删除他们! 最终得分 100
用户昵称 Riolu 运行时间 0.003 s
代码语言 C++ 内存使用 4.13 MiB
提交时间 2016-11-16 09:26:17
显示代码纯文本
/*=========================================*
  * Auther: Riolu
  * Time: 2016.11.16
  * ©Copyright 2016 Riolu. All Rights Reserved.
  *=========================================*/

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
//#include<cmath>
#include<string>
#include<ctime>
#include<cstring>
using namespace std;

typedef long long ll;
typedef double db;
const int N =1e6+1;
int n,m,q;
int a[N],x1,x2,y1,y2,s,xs,ys;

void change(){
	xs=(s-1)/m;
	ys=s-xs*m-1;
	//if(ys<0)ys=m-1;
}

int main(){

	freopen("deleteit.in","r",stdin);
	freopen("deleteit.out","w",stdout);

	cin>>n>>m>>q;
	s=n*m;xs=n-1;ys=m-1;
	
	while(q){
		q--;
		//cout<<s<<' '<<xs<<' '<<ys<<endl;
		cin>>x1>>y1>>x2>>y2;
		if(x1>x2)swap(x1,x2);
		if(y1>y2)swap(y1,y2);
		if(x1>xs)continue;
		s-=((x2-x1+1)*(y2-y1+1));
		//cout<<"t"<<s<<endl;
		if(x2<xs){
			change();
			continue;
		}else {
			s+=((x2-xs)*(y2-y1+1));
			//cout<<"t"<<s<<endl;
			if(y1>ys){
				s+=(y2-y1+1);
				//cout<<"t"<<s<<' '<<y1<<' '<<y2<<' '<<(y2-y1+1)<<endl;
			}else if(y2<=ys)change();
			else s+=(y2-ys);
			change();
		}
	}
	//cout<<s<<' '<<xs<<' '<<ys<<endl;
	cout<<s<<endl;
	
	fclose(stdin);fclose(stdout);
	return 0;
}
/*
9
1 3 3 2 100 100 100  999 888
*/