Submission #588674

#TimeUsernameProblemLanguageResultExecution timeMemory
588674jeroenodbLamps (JOI19_lamps)C++14
4 / 100
56 ms6124 KiB
#include "bits/stdc++.h" using namespace std; #define all(x) begin(x),end(x) template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int mxN = 1e5+1, oo = 1e9; int main() { int n; cin >> n; string a,b; cin >> a >> b; for(auto& i : a) i-='0'; for(auto& i : b) i-='0'; for(int i=n-1;i>0;--i) { a[i] ^= a[i-1]; b[i] ^= b[i-1]; } ll dp=0,dp2=oo; for(int i=0;i<n;++i) { tie(dp,dp2) = make_pair(min(dp+(a[i]!=b[i]), dp2+1), min(dp+2,dp2+b[i])); } cout << (min(dp,dp2)+1)/2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...