library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub beet-aizu/library

:heavy_check_mark: test/yukicoder/4872.test.cpp

Depends on

Code

// verification-helper: PROBLEM https://yukicoder.me/problems/4872

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#include "../../io/single.cpp"
#include "../../vector/runlength.cpp"
#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  auto as=read(n);
  auto bs=read(n);

  vector<int> cs(n);
  for(int i=0;i<n;i++) cs[i]=as[i]^bs[i];

  int ans=0;
  for(auto[v,_]:runlength(cs)) ans+=v;

  cout<<ans<<endl;
  return 0;
}
#line 1 "test/yukicoder/4872.test.cpp"
// verification-helper: PROBLEM https://yukicoder.me/problems/4872

#include<bits/stdc++.h>
using namespace std;

#define call_from_test
#line 1 "io/single.cpp"

#line 3 "io/single.cpp"
using namespace std;
#endif

//BEGIN CUT HERE
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}
//END CUT HERE
#ifndef call_from_test
signed main(){
  return 0;
}
#endif
#line 1 "vector/runlength.cpp"

#line 3 "vector/runlength.cpp"
using namespace std;
#endif

//BEGIN CUT HERE
template<typename T>
decltype(auto) runlength(vector<T> vs){
  vector<pair<T, int>> es;
  for(auto v:vs){
    if(es.empty() or es.back().first!=v)
      es.emplace_back(v,0);
    es.back().second++;
  }
  return es;
}
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  return 0;
}
#endif
#line 9 "test/yukicoder/4872.test.cpp"
#undef call_from_test

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  auto as=read(n);
  auto bs=read(n);

  vector<int> cs(n);
  for(int i=0;i<n;i++) cs[i]=as[i]^bs[i];

  int ans=0;
  for(auto[v,_]:runlength(cs)) ans+=v;

  cout<<ans<<endl;
  return 0;
}
Back to top page