Skip to content

Instantly share code, notes, and snippets.

@haroldxin
Created September 23, 2014 09:06
Show Gist options
  • Save haroldxin/37b1caa85f38ac1d9196 to your computer and use it in GitHub Desktop.
Save haroldxin/37b1caa85f38ac1d9196 to your computer and use it in GitHub Desktop.
Rectangle 2
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 101;
int main () {
int n;
cin >> n;
int f[maxn][maxn];
for (int i=0;i<=100;i++){
for (int j=0;j<=100;j++){
f[i][j]=0;
}
}
for (int i=1;i<=n;i++){
int x1,x2,y1,y2;
cin >> x1;cin >> y1;cin >> x2;cin >> y2;
for(int i=x1+1;i<=x2;i++){
for (int j=y1+1;j<=y2;j++)f[i][j]=1;
}
}
int a=0;
for (int i=0;i<=maxn+1;i++){
for (int j=0;j<=maxn+1;j++){
if (f[i][j]==1)a=a+1;
}
}
cout << a;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment