# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
118253 | songc | Lamps (JOI19_lamps) | C++14 | 280 ms | 29728 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N;
int A[1010101];
int B[1010101];
int D[1010101][5], ans=1234567890;
int C[5][5] ={
{0, 1, 1, 2, 2},
{0, 0, 1, 1, 2},
{0, 1, 0, 2, 1},
{0, 0, 1, 0, 2},
{0, 1, 0, 2, 0}
};
int tog(int p, int o){
int x = A[p];
if (o == 1 || o == 4) x = 0;
else if (o == 2 || o == 3) x = 1;
return (x != B[p]) ? 1 : 0;
}
int main(){
scanf("%d", &N);
for (int i=1; i<=N; i++) scanf("%1d", &A[i]);
for (int i=1; i<=N; i++) scanf("%1d", &B[i]);
memset(D, 1, sizeof D);
D[0][0] = 0;
for (int i=1; i<=N; i++) for (int j=0; j<5; j++) for (int k=0; k<5; k++) {
D[i][k] = min(D[i][k], D[i-1][j] + C[j][k] + max(0, tog(i, k)-tog(i-1, j)));
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |