結果

問題 No.1183 コイン遊び
ユーザー HaarHaar
提出日時 2020-08-22 13:06:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 952 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 201,000 KB
実行使用メモリ 27,772 KB
最終ジャッジ日時 2024-04-23 07:22:16
合計ジャッジ時間 6,271 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 AC 85 ms
17,388 KB
testcase_13 AC 77 ms
16,572 KB
testcase_14 AC 117 ms
19,524 KB
testcase_15 AC 130 ms
20,376 KB
testcase_16 AC 129 ms
20,172 KB
testcase_17 AC 131 ms
20,532 KB
testcase_18 AC 130 ms
21,212 KB
testcase_19 AC 131 ms
19,576 KB
testcase_20 AC 126 ms
19,924 KB
testcase_21 AC 105 ms
11,016 KB
testcase_22 AC 101 ms
11,192 KB
testcase_23 AC 105 ms
11,116 KB
testcase_24 AC 109 ms
11,056 KB
testcase_25 AC 125 ms
19,580 KB
testcase_26 AC 132 ms
21,020 KB
testcase_27 AC 127 ms
19,572 KB
testcase_28 AC 129 ms
20,352 KB
testcase_29 AC 104 ms
11,140 KB
testcase_30 AC 114 ms
27,772 KB
testcase_31 AC 127 ms
19,664 KB
testcase_32 AC 124 ms
20,028 KB
testcase_33 AC 127 ms
20,580 KB
testcase_34 AC 127 ms
20,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

/**
 * @title Run length encoding
 * @docs run_length_encoding.md
 */
template <typename Container, typename T = typename Container::value_type>
auto run_length_encoding(const Container &v){
  std::vector<std::pair<T,int64_t>> ret;

  for(auto &x : v){
    if(ret.empty()) ret.emplace_back(x, 1);
    else if(ret.back().first == x) ++ret.back().second;
    else ret.emplace_back(x, 1);
  }

  return ret;
}


namespace solver{
  void solve(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    int N; std::cin >> N;
    std::vector<int> A(N), B(N);
    for(int i = 0; i < N; ++i) std::cin >> A[i];
    for(int i = 0; i < N; ++i) std::cin >> B[i];

    for(int i = 0; i < N; ++i){
      A[i] = A[i] ^ B[i];
    }

    auto r = run_length_encoding(A);

    int ans = 0;

    for(auto [x, i] : r){
      if(x == 1) ++ans;
    }

    
    std::cout << ans << "\n";
  }
}

int main(){
  solver::solve();
  return 0;
}
0