Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力

时间:2023-03-08 19:09:42
Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力

A. Vanya and Table

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/552/problem/A

Description

Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.

In this table, Vanya chose n rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of rectangles.

Each of the following n lines contains four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ 100, 1 ≤ y1 ≤ y2 ≤ 100), where x1 and y1 are the number of the column and row of the lower left cell and x2 and y2 are the number of the column and row of the upper right cell of a rectangle.

Output

In a single line print the sum of all values in the cells of the table.

Sample Input

2
1 1 2 3
2 2 3 3

Sample Output

10

HINT

题意

有n个操作,每次操作会将使得一个矩形区域都加上1

然后问你这个100×100的区域的和是多少

题解:

数据范围很小,暴力做就好了

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 1000010
#define mod 1000000007
#define eps 1e-6
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** ll g[][]; int main()
{
int n=read();
for(int ii=;ii<n;ii++)
{
int x1=read(),y1=read(),x2=read(),y2=read();
for(int i=x1;i<=x2;i++)
{
for(int j=y1;j<=y2;j++)
g[i][j]++;
}
}
ll ans=;
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
ans+=g[i][j];
}
cout<<ans<<endl;
}