比赛 |
20161116 |
评测结果 |
AWWWWWWWWW |
题目名称 |
删除他们! |
最终得分 |
10 |
用户昵称 |
1azyReaper |
运行时间 |
0.012 s |
代码语言 |
C++ |
内存使用 |
1.27 MiB |
提交时间 |
2016-11-16 10:22:53 |
显示代码纯文本
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define max 1000010
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll n,m,q,all;
ll ln,col;
bool map[max];
inline ll read()
{
char tmp=getchar();
ll f=1,ans=0;
while(tmp<'0'||tmp>'9')
{
if(tmp=='-')
f=-f;
tmp=getchar();
}
while(tmp>='0'&&tmp<='9')
{
ans=ans*10-'0'+tmp;
tmp=getchar();
}
return ans*f;
}
ll work(ll x1,ll x2,ll y1,ll y2)
{
ll tmp=0;
if(ln<x1)
return 0;
if(ln>x2)
{
all-=(x2-x1+1)*(y2-y1+1);
return 0;
}
x2=ln;
all-=(x2-x1+1)*(y2-y1+1);
if(col<y1)
{
all+=y2-y1+1;
return 0;
}
if(col>y2)
{
return 0;
}
y2=col;
all+=y2-y1+1;
}
ll doit()
{
ln=n,col=m;
all=n*m;
ll x1,x2,y1,y2;
for(ll i=1;i<=q;i++)
{
x1=read();x2=read();y1=read();y2=read();
work(x1+1,x2+1,y1+1,y2+1);
ln=all/m;
if(all%m)
ln++;
col=all%m;
if(col==0)
col=m;
}
}
int main(int argc, char** argv)
{
freopen("deleteit.in","r",stdin);
freopen("deleteit.out","w",stdout);
memset(map,false,sizeof(map));
n=read();
m=read();
q=read();
doit();
printf("%lld\n",all);
//work();
//com();
return 0;
}