Submission #534463

#TimeUsernameProblemLanguageResultExecution timeMemory
53446379brueLamps (JOI19_lamps)C++14
4 / 100
133 ms8156 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; bool a[1000002]; bool b[1000002]; int DP[1000002]; 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]); int zero = 0, one = 0, rev = 0; for(int i=1; i<=n; i++){ DP[i] = 1e9; if(a[i] == b[i]) DP[i] = DP[i-1]; if(b[i] == 0){ DP[i] = min(DP[i], DP[zero] + 1); } else zero = i; if(b[i] == 1){ DP[i] = min(DP[i], DP[one] + 1); } else one = i; if(a[i] != b[i]){ DP[i] = min(DP[i], DP[rev] + 1); } else rev = i; } printf("%d", DP[n]); }

Compilation message (stderr)

lamp.cpp: In function 'int main()':
lamp.cpp:14:38: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'bool*' [-Wformat=]
   14 |     for(int i=1; i<=n; i++) scanf("%1d", &a[i]);
      |                                    ~~^   ~~~~~
      |                                      |   |
      |                                      |   bool*
      |                                      int*
lamp.cpp:15:38: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'bool*' [-Wformat=]
   15 |     for(int i=1; i<=n; i++) scanf("%1d", &b[i]);
      |                                    ~~^   ~~~~~
      |                                      |   |
      |                                      |   bool*
      |                                      int*
lamp.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
lamp.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%1d", &a[i]);
      |                             ~~~~~^~~~~~~~~~~~~~
lamp.cpp:15:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for(int i=1; i<=n; i++) scanf("%1d", &b[i]);
      |                             ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...