結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2020-06-07 16:39:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 83 ms / 2,000 ms |
| コード長 | 2,453 bytes |
| コンパイル時間 | 2,588 ms |
| コンパイル使用メモリ | 201,736 KB |
| 最終ジャッジ日時 | 2025-01-10 23:53:47 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i @hamayanhamayan0
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
struct MergedRect {
map<ll, ll> Points;
ll area = 0;
MergedRect() {
Points[0] = infl;
Points[infl] = 0;
}
/// <summary>
/// (0,0)が左下で(x,y)が右上の四角形を追加
/// </summary>
void add(ll x, ll y) {
auto ite = Points.lower_bound(x);
if (y <= ite->second) return;
while (true) {
auto pre = *prev(Points.lower_bound(x));
if (y < pre.second) break;
Points.erase(pre.first);
ll dx = pre.first - prev(Points.lower_bound(pre.first))->first;
ll dy = pre.second - Points.lower_bound(pre.first)->second;
area -= dx * dy;
}
area += (x - prev(Points.lower_bound(x))->first) * (y - Points.lower_bound(x)->second);
Points[x] = y;
}
};
int N;
MergedRect MR[4];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
ll pre = 0;
rep(i, 0, N) {
int X1, Y1, X2, Y2;
cin >> X1 >> Y1 >> X2 >> Y2;
MR[0].add(-X1, -Y1);
MR[1].add(-X1, Y2);
MR[2].add(X2, -Y1);
MR[3].add(X2, Y2);
ll tot = MR[0].area + MR[1].area + MR[2].area + MR[3].area;
printf("%lld\n", tot - pre);
pre = tot;
}
}
はまやんはまやん