Codeforces Round #679 (based on Technocup 2021 Elimination Round 1) DIV1 B問題/DIV2 D問題/Round1 D問題 - Shurikens

Source

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

問題概要

省略

解法

省略

cLayversion 20201115-1)のコード

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

//no-unlocked
int N;
char E[2d5]; int A[2d5];
int lf[1d5], rg[1d5], id[1d5];
int sz, res[1d5];
segtree_Point_Maxval<int> t;
LHeap<int> hp;
{
  int i, j, k;
  rd(N);
  rep(i,2N){
    rd(E[i]);
    if(E[i]=='-') rd(A[i]--);
  }

  t.walloc(N, 1);
  rep(i,2N) if(E[i]=='-'){
    t.change(A[i], i);
    j = if[A[i]==N-1, 0, t.getMaxVal(A[i]+1, N)];
    (lf[A[i]], rg[A[i]], id[A[i]]) = (j, i, A[i]);
  }
  sortA(N, lf, rg, id);

  hp.walloc(N, 1);
  k = 0;
  rep(i,2N){
    while(k < N && lf[k] == i){
      hp.change(k, rg[k]);
      k++;
    }
    if(E[i]=='-') continue;
    if(hp.size==0) wt("NO"), return 0;
    j = hp.pop();
    if(rg[j] < i) wt("NO"), return 0;
    res[sz++] = id[j];
  }
  wt("YES");
  wt(res(N)+1);
}

Current time: 2024年04月24日19時39分49秒
Last modified: 2020年11月15日09時37分53秒 (by laycrs)
Tags: Competitive_Programming_Incomplete Codeforces CF679 CF_DIV1_B CF_DIV2_D
トップページに戻る

Logged in as: unknown user (not login)

ログイン: