保存されている過去のバージョンの一覧

2020年11月15日16時15分04秒

第四回 アルゴリズム実技検定 L問題 - マンションの改築

Source

第四回 アルゴリズム実技検定
問題文

問題概要

省略

解法

省略

cLayversion 20201115-2)のコード

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

int N, Q; ll H[2d5];
int T, U, V;

ll sa[2d5], tar;
map<ll,int> mp;
{
  int res;
  rd(N,Q,H(N));
  rep(i,N-1){
    if(i%2==0) sa[i] = H[i+1] - H[i];
    if(i%2==1) sa[i] = H[i] - H[i+1];
  }
  rep(i,N-1) mp[sa[i]]++;

  rep(Q){
    rd(T, U);
    if(T==1) tar += U;
    if(T==2) tar -= U;
    if(T==3){
      U--;
      rd(V);
      H[U] += V;
      rep(i,max(0,U-1),min(U+1,N-1)){
        mp[sa[i]]--;
        if(i%2==0) sa[i] = H[i+1] - H[i];
        if(i%2==1) sa[i] = H[i] - H[i+1];
        mp[sa[i]]++;
      }
    }
    res = 0;
    if(mp.count(tar)) res = mp[tar];
    wt(res);
  }
}

Current time: 2024年04月19日11時05分02秒
Last modified: 2020年11月15日16時15分04秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder
トップページに戻る

Logged in as: unknown user (not login)

ログイン: