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

2020年11月15日01時24分57秒

AtCoder Grand Contest 049 B問題 - Flip Digits

Source

AtCoder Grand Contest 049
問題文

問題概要

省略

解法

省略

cLayversion 20201115-1)のコード

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

int N;
char S[5d5+2], T[5d5+2];
{
  int x, y;
  ll res = 0;
  set<int> ss, tt;
  rd(N,S,T);
  rep(i,N) if(S[i]=='1') ss.insert(i);
  rep(i,N) if(T[i]=='1') tt.insert(i);
  while(ss.size() || tt.size()){
    if(ss.size()==0) wt(-1), return 0;
    if(tt.size()==0 || getFirst(ss) < getFirst(tt)){
      if(ss.size()==1) wt(-1), return 0;
      x = popFirst(ss);
      y = popFirst(ss);
      res += y - x;
      continue;
    } else {
      x = popFirst(ss);
      y = popFirst(tt);
      res += x - y;
    }
  }
  wt(res);
}

Current time: 2024年04月20日03時13分32秒
Last modified: 2020年11月15日01時24分57秒 (by laycrs)
Tags: Competitive_Programming_Incomplete AtCoder AtCoder_Grand_Contest AGC049 AGC_B
トップページに戻る

Logged in as: unknown user (not login)

ログイン: