AC代码
主要思路见此题解
其实说白了就是有个公式可以算x轴投影重叠长度 y轴投影重叠长度 两个相乘就好
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <bits/stdc++.h>
using namespace std; typedef long long ll; ll n;
int main() { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); ll a,b; cin>>n>>a>>b; ll ans=0; for(ll i=1;i<=n;++i) { ll c,d,e,f; cin>>c>>d>>e>>f; ans+=max(0LL,min(a,e)-max(0LL,c))*max(0LL,min(b,f)-max(0LL,d)); } cout<<ans<<endl; return 0; }
|
心路历程(WA,TLE,MLE……)