結果
問題 | No.1074 増殖 |
ユーザー |
![]() |
提出日時 | 2020-06-05 21:55:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 1,835 ms |
コンパイル使用メモリ | 174,016 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-17 14:31:51 |
合計ジャッジ時間 | 2,465 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 8 |
ソースコード
#include <bits/stdc++.h>int ri() {int n;scanf("%d", &n);return n;}struct Stairs {std::set<std::pair<int, int> > all;Stairs () {all.insert({-1000000000, 1000000000});all.insert({1000000000, -1000000000});}int add(int x, int y) {auto tmp = all.insert({x, y});if (!tmp.second) return 0;auto itr = tmp.first;if (std::next(itr)->second >= y) {all.erase(itr);return 0;}int res = x * y;while (std::prev(itr)->second <= y) {res -= std::prev(itr)->first * std::prev(itr)->second;if (std::prev(itr, 2)->first > 0) res += std::prev(itr, 2)->first * std::prev(itr)->second;all.erase(std::prev(itr));}if (std::prev(itr)->first > 0) res -= std::prev(itr)->first * y;if (std::next(itr)->second > 0) res -= std::next(itr)->second * x;if (std::prev(itr)->first > 0 && std::next(itr)->second > 0) res += std::prev(itr)->first * std::next(itr)->second;return res;}};int main() {int n = ri();Stairs all[4] = { Stairs() };for (int i = 0; i < n; i++) {int x0 = ri(), y0 = ri();int x1 = ri(), y1 = ri();int res = all[0].add(x1, y1) + all[1].add(-x0, y1) + all[2].add(x1, -y0) + all[3].add(-x0, -y0);printf("%d\n", res);}return 0;}