Submission #204071

#TimeUsernameProblemLanguageResultExecution timeMemory
204071ics0503Lamps (JOI19_lamps)C++17
100 / 100
68 ms16120 KiB
#include<stdio.h> int D[1212121][3]; char a[1212121], b[1212121]; int min(int a, int b) { if (a < b)return a; return b; } int get(char a, int tp) { if (tp == 0)return '0'; if (tp == 1)return '1'; return a; } int main() { int n; scanf("%d%s%s", &n, a + 1, b + 1); int i, j, k; D[0][0] = D[0][1] = 1e9; D[0][2] = 0; for (i = 1; i <= n; i++) { for (j = 0; j < 3; j++) { D[i][j] = 1e9; for (k = 0; k < 3; k++) { D[i][j] = min(D[i][j], D[i - 1][k] + (j != 2 && j != k) + ((i==1 || get(a[i - 1], k) == b[i - 1]) && get(a[i], j) != b[i])); } } } int ans = 1e9; for (i = 0; i < 3; i++)ans = min(ans, D[n][i]); printf("%d", ans); return 0; }

Compilation message (stderr)

lamp.cpp: In function 'int main()':
lamp.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d%s%s", &n, a + 1, b + 1);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...