結果

問題 No.1074 増殖
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2018-11-26 22:32:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 2,722 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 91,868 KB
実行使用メモリ 5,996 KB
最終ジャッジ日時 2023-09-02 09:17:35
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,772 KB
testcase_01 AC 2 ms
4,860 KB
testcase_02 AC 2 ms
4,800 KB
testcase_03 AC 3 ms
4,856 KB
testcase_04 AC 3 ms
4,764 KB
testcase_05 AC 3 ms
4,856 KB
testcase_06 AC 185 ms
5,992 KB
testcase_07 AC 141 ms
5,848 KB
testcase_08 AC 131 ms
5,872 KB
testcase_09 AC 167 ms
5,896 KB
testcase_10 AC 193 ms
5,852 KB
testcase_11 AC 153 ms
5,996 KB
testcase_12 AC 155 ms
5,856 KB
testcase_13 AC 164 ms
5,916 KB
testcase_14 AC 165 ms
5,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define N 150

ll flag[N];
ll d1[N];
ll d2[N*N];
ll area[N];

ll ans[40010][4];

void f(ll n, vector<ll> &vx, vector<ll> &vy, ll c){
  clr(flag,0);
  clr(d1,0);
  clr(d2,0);
  clr(area,0);
  ll now = 0;
  rep(i,0,n){
    ll x = vx[i];
    ll y = vy[i];
    x--;
    rep(j,0,N){
      ll l = j*N;
      ll r = (j+1)*N-1;
      ll a = 0;
      if(l<=x&&x<=r){
        if(flag[j]==0){
          rep(k,l,x+1){
            if(d2[k]<y){
              a+=y-d2[k];
              d2[k] = y;
            }
          }
        }
        else{
          rep(k,l,x+1){
            if(d1[j]<y){
              a+=y-d1[j];
              d2[k] = y;
            }
            else{
              d2[k] = d1[j];
            }
          }
          rep(k,x+1,r+1){
            d2[k] = d1[j];
          }
          flag[j] = 0;
        }
        area[j]+=a;
        break;
      }
      else if(flag[j]==0){
        if(d2[l]<=y&&d2[r]<=y){
          flag[j]=1;
          d1[j] = y;
          a += N*y - area[j];
        }
        else if(d2[l]>=y&&d2[r]>=y){
        }
        else{
          rep(k,l,r+1){
            if(d2[k]<y){
              a+=y-d2[k];
              d2[k] = y;
            }
          }
        }
        area[j]+=a;
      }
      else if(flag[j]==1){
        if(d1[j]<y){
          d1[j] = y;
          a += N*y - area[j];          
        }
        area[j]+=a;
      }
    }
    ll nex = 0;
    rep(j,0,N){
      nex += area[j];
    }
    ans[i][c] = nex-now;
    now = nex;
  }
}

int main(){
  ll n;
  cin>>n;
  vector<vector<ll> > vx(2,vector<ll>());
  vector<vector<ll> > vy(2,vector<ll>());
  rep(i,0,n){
    ll xa,ya,xb,yb;
    cin>>xa>>ya>>xb>>yb;
    xa*=-1;
    ya*=-1;
    vx[0].pb(xa);
    vx[1].pb(xb);
    vy[0].pb(ya);
    vy[1].pb(yb);
  }
  clr(ans,0);
  rep(i,0,2){
    rep(j,0,2){
      f(n,vx[i],vy[j],2*i+j);
    }
  }
  rep(i,0,n){
    ll ans1 = 0;
    rep(j,0,4){
      ans1 += ans[i][j];
    }
    cout << ans1 << endl;
  }
  return 0;
}
0