Submission #105854

#TimeUsernameProblemLanguageResultExecution timeMemory
105854Alexa2001Lamps (JOI19_lamps)C++17
4 / 100
27 ms19404 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e6 + 5; int a[Nmax], b[Nmax], a0[Nmax], b0[Nmax]; int i, n; int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin >> n; string A, B; cin >> A >> B; for(i=1; i<=n; ++i) a0[i] = A[i-1] - '0', b0[i] = B[i-1] - '0'; for(i=1; i<=n+1; ++i) a[i] = a0[i-1] ^ a0[i], b[i] = b0[i-1] ^ b0[i]; int cnt = 0, j; for(i=1; i<=n+1; ++i) if(a[i] ^ b[i]) { cnt ++; for(j=i+1; j<=n+1; ++j) if(a[j] == 0 && b[j] == 1) break; if(j == n+2) --cnt; i = j; } cout << cnt << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...