結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
mugen_1337
|
| 提出日時 | 2020-06-06 00:17:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 1,670 bytes |
| コンパイル時間 | 1,960 ms |
| コンパイル使用メモリ | 200,756 KB |
| 最終ジャッジ日時 | 2025-01-10 23:08:07 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
struct RectangleUnion{
map<long long,long long> data;
ll sum;
RectangleUnion():sum(0){
data[0]=1ll<<60;// banpei
data[1ll<<60]=0;
}
// x>=0 and y>=0
void add_point(long long x,long long y){
auto ite=data.lower_bound(x);
if(ite->second>=y) return ;
long long yn=ite->second;
ite--;
while(ite->second<=y){
auto k=*ite;
// 削除した場所の次のiteratorを返す
ite=--data.erase(ite);
sum-=(k.first-ite->first)*(k.second-yn);
}
sum+=(x-ite->first)*(y-yn);
data[x]=y;
}
ll get_sum(){
return sum;
}
};
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n;cin>>n;
RectangleUnion ur,ul,dr,dl;
ll pre=0;
rep(i,n){
ll xp,yp,xm,ym;cin>>xm>>ym>>xp>>yp;
ur.add_point(xp,yp);
ul.add_point(-xm,yp);
dr.add_point(xp,-ym);
dl.add_point(-xm,-ym);
ll sum=ur.get_sum()+ul.get_sum()+dr.get_sum()+dl.get_sum();
cout<<sum-pre<<endl;
pre=sum;
}
return 0;
}
mugen_1337