結果

問題 No.1074 増殖
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2018-11-26 20:59:09
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,615 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 91,060 KB
実行使用メモリ 6,248 KB
最終ジャッジ日時 2023-09-02 09:17:28
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,972 KB
testcase_01 AC 3 ms
4,984 KB
testcase_02 AC 3 ms
4,784 KB
testcase_03 AC 2 ms
4,836 KB
testcase_04 AC 3 ms
4,768 KB
testcase_05 AC 3 ms
5,072 KB
testcase_06 AC 192 ms
5,860 KB
testcase_07 AC 148 ms
5,840 KB
testcase_08 AC 137 ms
5,864 KB
testcase_09 WA -
testcase_10 AC 199 ms
5,892 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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