結果

問題 No.1074 増殖
ユーザー Shun_PIShun_PI
提出日時 2020-06-05 22:31:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,884 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 181,240 KB
実行使用メモリ 14,016 KB
最終ジャッジ日時 2024-05-09 22:06:38
合計ジャッジ時間 5,892 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,652 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 21 ms
5,376 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
  }

}
0