Submission #204056

#TimeUsernameProblemLanguageResultExecution timeMemory
204056ics0503Lamps (JOI19_lamps)C++17
4 / 100
36 ms27860 KiB
#include<stdio.h> char a[1212121], b[1212121]; int D[1212121][6]; int min(int a, int b) { if (a < b)return a; return b; } int main() { int n, i, j; scanf("%d%s%s", &n,a+1,b+1); D[0][0] = D[0][1] = D[0][2] = D[0][3] = D[0][4] = 1e9; for (i = 1; i <= n; i++) { if (b[i] != '0')D[i][0] = 1e9; else D[i][0] = min(min(D[i - 1][0], D[i - 1][1] + 1), D[i - 1][5] + 1); if (b[i] != '1')D[i][1] = 1e9; else D[i][1] = min(min(D[i - 1][1], D[i - 1][0] + 1), D[i - 1][5] + 1); if (b[i] != '0')D[i][2] = 1e9; else D[i][2] = min(min(D[i - 1][2], D[i - 1][3] + 1), D[i - 1][4] + 1); if (b[i] != '1')D[i][3] = 1e9; else D[i][3] = min(min(D[i - 1][3], D[i - 1][2] + 1), D[i - 1][4] + 1); if (a[i] == b[i]) D[i][4] = 1e9; else D[i][4] = min(min(min(min(min(D[i - 1][4], D[i - 1][0] + 1), D[i - 1][1] + 1), D[i - 1][2]), D[i - 1][3]), D[i - 1][5] + 1); if (a[i] != b[i])D[i][5] = 1e9; else D[i][5] = min(min(min(min(min(D[i - 1][0], D[i - 1][1]), D[i - 1][2]), D[i - 1][3]), D[i - 1][4]), D[i - 1][5]); } printf("%d", min(min(min(min(min(D[n][0], D[n][1]), D[n][2]), D[n][3]),D[n][4]),D[n][5])); return 0; }

Compilation message (stderr)

lamp.cpp: In function 'int main()':
lamp.cpp:7:12: warning: unused variable 'j' [-Wunused-variable]
  int n, i, j; scanf("%d%s%s", &n,a+1,b+1);
            ^
lamp.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, i, j; 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...