QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219760 | #7581. Radar Scanner | PhantomThreshold# | AC ✓ | 206ms | 8720kb | C++20 | 1016b | 2023-10-19 18:07:47 | 2023-10-19 18:07:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
int n;
cin>>n;
vector<tuple<int,int,int,int>> r(n+5);
for(int i=1;i<=n;i++)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
r[i]={a,b,c,d};
}
unsigned long long ans=0;
for(int dx=0;dx<=1;dx++)
{
for(int dy=0;dy<=1;dy++)
{
vector<vector<int>> s(1005,vector<int>(1005));
for(int i=1;i<=n;i++)
{
auto [a,b,c,d]=r[i];
s[a][b]++;
s[c+1-dx][b]--;
s[a][d+1-dy]--;
s[c+1-dx][d+1-dy]++;
}
for(int i=1;i<=1000;i++)
for(int j=1;j<=1000;j++)
s[i][j]+=s[i][j-1];
for(int i=1;i<=1000;i++)
for(int j=1;j<=1000;j++)
s[i][j]+=s[i-1][j];
unsigned long long sum=0;
for(int i=1;i<=1000;i++)
for(int j=1;j<=1000;j++)
sum+=1ll*s[i][j]*(s[i][j]-1)*(s[i][j]-2)/6;
if((dx+dy)%2==0)ans+=sum;
else ans-=sum;
}
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 7280kb
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
output:
0 4
result:
ok 2 number(s): "0 4"
Test #2:
score: 0
Accepted
time: 206ms
memory: 8720kb
input:
10 5 2 1 3 3 1 5 1 5 1 2 2 3 4 1 5 3 1 2 4 4 10 3 3 7 5 3 4 3 4 5 4 6 6 8 1 10 6 6 1 9 8 2 6 8 10 3 2 8 7 5 1 5 8 2 2 7 7 1 1 2 3 100 1 37 28 37 1 5 6 40 9 29 47 30 12 9 12 9 40 14 45 14 13 28 16 34 44 8 46 47 23 9 40 42 13 1 35 17 9 31 46 31 1 10 34 48 5 35 46 50 16 21 28 49 3 6 3 24 5 3 39 28 30 8...
output:
1 31 16256 29932636832595 20948001862043 20395156087285 20094030388871 20143137954387 19922797032244 20114049116806
result:
ok 10 numbers