結果
問題 | No.1074 増殖 |
ユーザー |
![]() |
提出日時 | 2020-06-05 22:31:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,884 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 180,824 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2024-12-17 16:20:49 |
合計ジャッジ時間 | 9,732 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 6 TLE * 2 |
ソースコード
#include <bits/stdc++.h>using namespace std;using lint = long long int;using P = pair<lint, lint>;#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)#define REP(i, n) FOR(i,0,n)#define IREP(i, n) IFOR(i,0,n)#define ALL(a) (a).begin(),(a).end()constexpr int MOD = 1000000007;constexpr int INF = 2147483647;void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}vector<map<lint, lint>> mp(4);lint solve(lint x, lint y, map<lint, lint> &m) {lint ret = 0;vector<lint> erasekey;lint l = -1;lint r = m.size();while(r-l > 1) {lint x = (l+r) / 2;if(y > next(m.begin(), x)->second) {r = x;} else {l = x;}}lint lastkey = 0;if(r > 0) lastkey = next(m.begin(), r-1)->first;//cout << r << " " << lastkey << endl;for(auto itr=next(m.begin(), r); ; itr++) {if(itr == m.end()) {if(x > lastkey) {ret += (x - lastkey) * y;m[x] = y;}break;}lint key = itr->first;lint val = itr->second;if(x > key) {if(y > val) {ret += (key-lastkey) * (y-val);erasekey.push_back(key);}} else {if(y > val) {ret += (x - lastkey) * (y-val);m[x] = y;}break;}lastkey = key;}REP(i, erasekey.size()) m.erase(erasekey[i]);return ret;}int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int N;cin >> N;REP(i, N) {lint xa, ya, xb, yb;cin >> xa >> ya >> xb >> yb;lint ans = 0;ans += solve(xb, yb, mp[0]);//cout << ans << "\n";ans += solve(-xa, yb, mp[1]);//cout << ans << "\n";ans += solve(xb, -ya, mp[2]);//cout << ans << "\n";ans += solve(-xa, -ya, mp[3]);cout << ans << "\n";}}