Codeforces Round #578 DIV2 D問題 - White Lines

Source

Codeforces Round #578 DIV2 D問題 (2000pt)
Problem description

問題概要

省略

解法

省略

cLayversion 20190820-1)のコード

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

//no-unlocked
int N, K;
char S[2000][2002];
{
  int i, j, k;
  int mn, mx;
  int res = 0;
  Grid2d<int> g;

  rd(N,K,S(N));
  g.malloc(N+1,N+1);
  rep(i,N+1) rep(j,N+1) g[i][j] = 0;

  rep(i,N){
    mn = int_inf;
    mx = -int_inf;
    rep(j,N) if(S[i][j]=='B'){
      mn <?= j;
      mx >?= j;
    }
    if(mn > mx){
      g[0][0]++;
    } else if(mx - mn + 1 <= K) {
      j = K - (mx-mn+1);
      k = K - 1;
      g[i+1][mn+1]++;
      g[max(0,i-k)][mn+1]--;
      g[i+1][max(0,mn-j)]--;
      g[max(0,i-k)][max(0,mn-j)]++;
    }
  }
  
  rep(i,N){
    mn = int_inf;
    mx = -int_inf;
    rep(j,N) if(S[j][i]=='B'){
      mn <?= j;
      mx >?= j;
    }
    if(mn > mx){
      g[0][0]++;
    } else if(mx - mn + 1 <= K) {
      j = K - (mx-mn+1);
      k = K - 1;
      g[mn+1][i+1]++;
      g[mn+1][max(0,i-k)]--;
      g[max(0,mn-j)][i+1]--;
      g[max(0,mn-j)][max(0,i-k)]++;
    }
  }

  g.setSum();
  rep(i,N+1) rep(j,N+1) res >?= g.d_s[i][j];
  wt(res);
}

Current time: 2021年09月27日21時42分32秒
Last modified: 2019年08月22日00時39分33秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF578 CF_Div2_D
トップページに戻る

Logged in as: unknown user (not login)

ログイン: