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
省略
省略
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月27日00時44分16秒
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)