题目:http://118.190.20.162/view.page?gpid=T15
输入:
2
1 1 4 4
2 3 6 5
1.10分
#include <bits/stdc++.h>
using namespace std;
struct Window
{
int x1,y1,x2,y2;
};
int n,m;
Window window[11];
map<int,bool>mp;
int main()
{
ios::sync_with_stdio(false);
cin>>n;
int area=0;
int x1,y1,x2,y2;
for(int i=0;i<n;i++)
{
cin>>x1>>y1>>x2>>y2;
for(int j=x1;j<x2;j++)
{
for(int k=y1;k<y2;k++)
{
if(!mp[j*10+k])
{
mp[j*10+k]=true;
area++;
}
}
}
}
cout<<area;
return 0;
}
2.100分
#include <bits/stdc++.h>
using namespace std;
int flag[101][101]={0};
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
int area=0;
int x1,y1,x2,y2;
for(int i=0;i<n;i++)
{
cin>>x1>>y1>>x2>>y2;
area+=(x2-x1)*(y2-y1);
for(int j=x1;j<x2;j++)
{
for(int k=y1;k<y2;k++)
{
if(flag[j][k])
{
area--;
}
else
flag[j][k]=1;
}
}
}
cout<<area;
return 0;
}