結果
| 問題 |
No.1074 増殖
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2020-06-05 22:49:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 60 ms / 2,000 ms |
| コード長 | 1,167 bytes |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 168,232 KB |
| 実行使用メモリ | 8,320 KB |
| 最終ジャッジ日時 | 2024-12-17 17:00:19 |
| 合計ジャッジ時間 | 2,622 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1 << 30;
struct Solver {
set<pair<int, int> > st;
Solver() {
st.emplace(INF, 0);
st.emplace(0, -INF);
}
int query(int x, int y) {
int res = 0;
auto ptr = st.lower_bound({x, -INF});
if (-(*ptr).second < y) {
while (true) {
--ptr;
if (-(*ptr).second <= y) {
--ptr;
int x1 = (*ptr).first;
++ptr;
int x2 = (*ptr).first;
int y1 = -(*ptr).second;
++ptr;
int y2 = -(*ptr).second;
res -= (x2 - x1) * (y1 - y2);
--ptr;
ptr = st.erase(ptr);
} else {
break;
}
}
{
int x1 = (*ptr).first;
++ptr;
int y2 = -(*ptr).second;
res += (x - x1) * (y - y2);
st.emplace(make_pair(x, -y));
}
}
return res;
}
};
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
int X[2];
int Y[2];
Solver solver[4];
for (int i = 0; i < N; i++) {
cin >> X[0] >> Y[0] >> X[1] >> Y[1];
int res = 0;
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
res += solver[j * 2 + k].query(abs(X[j]), abs(Y[k]));
}
}
cout << res << "\n";
}
return 0;
}
ats5515