当前位置:网站首页>B - Code Party (girls' competition)
B - Code Party (girls' competition)
2022-07-06 16:03:00 【It's Xiao Zhang, ZSY】
B - Code Party
Sample Input
2
3
3 1 3 1
1 1 2 3
2 1 3 2
5
1 1 4 5
2 1 3 2
2 2 3 3
4 5 4 5
1 2 2 4
Sample Output
0
4
// Now it's time ,2021 year 10 month 28 Number 00:38 I finally ac 了 ,,,, Woo woo
/* Their thinking Using the difference and two-dimensional prefix sum, the number of intervals covered on each lattice is calculated g[i][j]. If you ask at this time C(g[i][j],3) And , Then there will be a lot of repetition , Because the same three intervals can cover multiple grids . So we only keep the grid in the upper left corner of the coverage area , Because this grid must be on the top and left of the interval , So the final answer is : The sum of the - Delete the sum after the left - Delete the sum after the top + Delete the sum after the top and left ( This piece has been repeatedly reduced in the front , So add it back ). */
#include<iostream>
#include<cstdio>
#include <cstring>
#include <algorithm>
#include <cstring>
#define N 1005
using namespace std;
typedef long long ll;
int a1[N][N],a2[N][N],a3[N][N],a4[N][N];
ll c3[100005];
ll wo(int a[N][N])
{
for(int i=1;i<=1000;i++){
for(int j=1;j<=1000;j++){
a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];// Sum up ;
}
}
ll ans=0;
for(int i=1;i<=1000;i++){
for(int j=1;j<=1000;j++){
ans+=c3[a[i][j]]; // altogether ( Buckle ) Overlapping ans;
}
}
return ans;
}
int main(){
int T;
c3[3]=1;
cin>>T;
for(int i=4;i<=100000;i++){
c3[i]=(ll)i*(i-1)*(i-2)/6;// If there is i The situation of the same Geke team
}
while(T--)
{
int n;
cin>>n;
memset(a1,0,sizeof(a1));// Each cycle assignment 0;
memset(a2,0,sizeof(a2));
memset(a3,0,sizeof(a3));
memset(a4,0,sizeof(a4));
int x1,y1,x2,y2;
for(int i=1;i<=n;i++){
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);// It works cin It's over time , There will be no competition in the future cin;
a1[x1][y1]++,a1[x2+1][y1]--,a1[x1][y2+1]--,a1[x2+1][y2+1]++;
// Two dimensional difference , Give (x1,y1) To (x2,y2) Add 1;
a2[x1+1][y1]++,a2[x2+1][y1]--,a2[x1+1][y2+1]--,a2[x2+1][y2+1]++;
// Subtract the left from each matrix ( Except for the first line ),x1+1;
a3[x1][y1+1]++,a3[x2+1][y1+1]--,a3[x1][y2+1]--,a3[x2+1][y2+1]++;
// Subtract the upper edge from each matrix ( Except for the first column ),y1+1;
a4[x1+1][y1+1]++,a4[x2+1][y1+1]--,a4[x1+1][y2+1]--,a4[x2+1][y2+1]++;
// Plus plus minus ;
}
cout<<wo(a1)-wo(a2)-wo(a3)+wo(a4)<<endl;
}
return 0;
}
边栏推荐
- Matlab comprehensive exercise: application in signal and system
- 【练习-5】(Uva 839)Not so Mobile(天平)
- Opencv learning log 33 Gaussian mean filtering
- 【练习-6】(PTA)分而治之
- Opencv learning log 16 paperclip count
- Pyside6 signal, slot
- 【练习-4】(Uva 11988)Broken Keyboard(破损的键盘) ==(链表)
- Information security - threat detection engine - common rule engine base performance comparison
- 【练习4-1】Cake Distribution(分配蛋糕)
- 基于web的照片数码冲印网站
猜你喜欢
信息安全-史诗级漏洞Log4j的漏洞机理和防范措施
Penetration test (8) -- official document of burp Suite Pro
1010 things that college students majoring in it must do before graduation
动态规划前路径问题优化方式
Borg Maze (BFS+最小生成树)(解题报告)
PySide6 信号、槽
VS2019初步使用
Penetration test (1) -- necessary tools, navigation
渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞
[exercise-5] (UVA 839) not so mobile (balance)
随机推荐
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
TCP的三次握手与四次挥手
China earth moving machinery market trend report, technical dynamic innovation and market forecast
E. Breaking the Wall
Truck History
1010 things that college students majoring in it must do before graduation
Opencv learning log 14 - count the number of coins in the picture (regardless of overlap)
Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
【练习-9】Zombie’s Treasure Chest
CS zero foundation introductory learning record
【练习-8】(Uva 246)10-20-30==模拟
Nodejs+vue网上鲜花店销售信息系统express+mysql
F - Birthday Cake(山东省赛)
[exercise-4] (UVA 11988) broken keyboard = = (linked list)
想应聘程序员,您的简历就该这样写【精华总结】
Shell Scripting
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
Record of brushing questions with force deduction -- complete knapsack problem (I)
Accounting regulations and professional ethics [1]
0-1 knapsack problem (I)