結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 22:35:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,562 bytes |
| コンパイル時間 | 1,939 ms |
| コンパイル使用メモリ | 177,716 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-17 16:29:51 |
| 合計ジャッジ時間 | 3,836 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 3 RE * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char newl = '\n';
ll solve(ll x, ll y, map<ll, ll>& d, ll& sum) {
auto itr = d.upper_bound(x);
ll ng = 0, ok = 1e9;
while (ok - ng > 1) {
ll mid = (ok + ng) / 2;
(d.lower_bound(mid)->second <= y ? ok : ng) = mid;
}
ll diff = 0;
if (ok <= x) {
for (auto it = d.lower_bound(ok); it != itr; ++it) {
diff -= it->second * (it->first - prev(it)->first);
}
auto itl = d.lower_bound(ok);
d.erase(itl, itr);
}
{
d[x] = y;
auto it = d.find(x);
if (prev(it)->second > y && y > next(it)->second) {
diff += (y - next(it)->second) * (x - prev(it)->first);
} else {
d.erase(x);
}
}
assert(diff >= 0);
sum += diff;
return diff;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
map<ll, ll> d1, d2, d3, d4;
d1[0] = 1e9;
d1[1e9] = 0;
d2[0] = 1e9;
d2[1e9] = 0;
d3[0] = 1e9;
d3[1e9] = 0;
d4[0] = 1e9;
d4[1e9] = 0;
ll sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
for (int i = 0; i < n; i++) {
ll xa, ya, xb, yb;
cin >> xa >> ya >> xb >> yb;
xa = abs(xa);
ya = abs(ya);
ll ans = 0;
ans += solve(xa, ya, d1, sum1);
ans += solve(xb, ya, d2, sum2);
ans += solve(xa, yb, d3, sum3);
ans += solve(xb, yb, d4, sum4);
cout << ans << newl;
}
return 0;
}