AtCoder Beginner Contest #130 F問題 - Minimum Bounding Box

Source

AtCoder Beginner Contest #130
問題文

問題概要

省略

解法

省略

cLayversion 20190706-1)のコード

C++に変換後のコードはこちら

int N;
int x1a, x1b, x2a, x2b, x3a, x3b;
int y1a, y1b, y2a, y2b, y3a, y3b;
char buf[10];

double evl(double t){
  double xa, xb, ya, yb;

  if(t < 0) return double_inf;

  xa = ya = 1e300;
  xb = yb = -1e300;

  if(x1a != int_inf) xa <?= x1a - t, xb >?= x1b - t;
  if(x2a != int_inf) xa <?= x2a,     xb >?= x2b;
  if(x3a != int_inf) xa <?= x3a + t, xb >?= x3b + t;
  if(y1a != int_inf) ya <?= y1a - t, yb >?= y1b - t;
  if(y2a != int_inf) ya <?= y2a,     yb >?= y2b;
  if(y3a != int_inf) ya <?= y3a + t, yb >?= y3b + t;

  return (xb-xa) * (yb-ya);
}

{
  int i, j, k;
  double res;

  x1a = x2a = x3a = y1a = y2a = y3a = int_inf;
  x1b = x2b = x3b = y1b = y2b = y3b = -int_inf;

  rd(N);
  rep(N){
    rd(i,j,buf);
    if(buf[0]=='R') x3a <?= i, x3b >?= i, y2a <?= j, y2b >?= j;
    if(buf[0]=='L') x1a <?= i, x1b >?= i, y2a <?= j, y2b >?= j;
    if(buf[0]=='U') x2a <?= i, x2b >?= i, y3a <?= j, y3b >?= j;
    if(buf[0]=='D') x2a <?= i, x2b >?= i, y1a <?= j, y1b >?= j;
  }
  res = evl(0);

  if(x1a!=int_inf && x2a!=int_inf){
    res <?= evl(x1a-x2a);
    res <?= evl(x1b-x2b);
  }
  if(x2a!=int_inf && x3a!=int_inf){
    res <?= evl(x2a-x3a);
    res <?= evl(x2b-x3b);
  }
  if(x1a!=int_inf && x3a!=int_inf){
    res <?= evl( (x1a-x3a) / 2.0 );
    res <?= evl( (x1a-x3b) / 2.0 );
    res <?= evl( (x1b-x3a) / 2.0 );
    res <?= evl( (x1b-x3b) / 2.0 );
  }
  if(y1a!=int_inf && y2a!=int_inf){
    res <?= evl(y1a-y2a);
    res <?= evl(y1b-y2b);
  }
  if(y2a!=int_inf && y3a!=int_inf){
    res <?= evl(y2a-y3a);
    res <?= evl(y2b-y3b);
  }
  if(y1a!=int_inf && y3a!=int_inf){
    res <?= evl( (y1a-y3a) / 2.0 );
    res <?= evl( (y1a-y3b) / 2.0 );
    res <?= evl( (y1b-y3a) / 2.0 );
    res <?= evl( (y1b-y3b) / 2.0 );
  }

  wt(res);
}

Current time: 2021年09月19日19時04分19秒
Last modified: 2019年07月06日22時06分01秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder AtCoder_Beginner_Contest ABC130 ABC_F
トップページに戻る

Logged in as: unknown user (not login)

ログイン: