Codeforces Round #692 (based on Technocup 2021 Elimination Round 3) DIV1 B問題/DIV2 D問題/Round3 D問題 - Grime Zoo

Source

Codeforces Round #692 (based on Technocup 2021 Elimination Round 3) DIV1 B問題 (1000pt)
Codeforces Round #692 (based on Technocup 2021 Elimination Round 3) DIV2 D問題 (2000pt)
Technocup 2021 - Elimination Round 3 D問題 (2000pt)
Problem description

問題概要

省略

解法

省略

cLayversion 20201229-1)のコード

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

//no-unlocked
int N; char S[1d5+2]; ll X, Y;

struct segval{ int zero, one; ll cost;};
segval segtree_ph_func(segval a, segval b){
  return {a.zero+b.zero, a.one+b.one, a.cost+b.cost+X*a.zero*b.one+Y*a.one*b.zero};
}

segtree_ph<segval> t;
{
  ll res;
  rd(S@N,X,Y);
  t.walloc(N);
  t.setN(N);
  rep(i,N) t[i] = if[S[i]=='1', {0,1,0}, {1,0,0}];
  t.build();
  res = t.get(0, N).cost;

  rep(i,N){
    if(S[i] == '?') t.change(i, {0, 1, 0});
    res <?= t.get(0, N).cost;
  }
  rep(i,N){
    if(S[i] == '?') t.change(i, {1, 0, 0});
    res <?= t.get(0, N).cost;
  }
  wt(res);
}

Current time: 2024年04月25日20時29分39秒
Last modified: 2020年12月30日09時47分42秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF692 CF_DIV1_B CF_DIV2_D
トップページに戻る

Logged in as: unknown user (not login)

ログイン: