제출 #331058

#제출 시각아이디문제언어결과실행 시간메모리
331058lohachoLamps (JOI19_lamps)C++14
100 / 100
265 ms21996 KiB
#include <bits/stdc++.h> using namespace std; using LL = long long; const int MOD = (int)1e9 + 7; const int NS = (int)1e6 + 4; int N; int A[NS], B[NS]; int dp[NS][3]; int cha(int x, int y){ if(y != 2){ return y; } return x; } 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); } for(int i = 0; i < NS; ++i){ for(int j = 0; j < 3; ++j){ dp[i][j] = MOD; } } dp[1][2] = 0; for(int i = 1; i <= N; ++i){ for(int last = 0; last < 3; ++last){ for(int now = 0; now < 3; ++now){ int cost = 0; if(last != now && now != 2){ ++cost; } if((i == 1 || cha(A[i - 1], last) == B[i - 1]) && (cha(A[i], now) != B[i])){ ++cost; } dp[i + 1][now] = min(dp[i + 1][now], cost + dp[i][last]); } } } printf("%d", min({dp[N + 1][0], dp[N + 1][1], dp[N + 1][2]})); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

lamp.cpp: In function 'int main()':
lamp.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
lamp.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%1d", A + i);
      |         ~~~~~^~~~~~~~~~~~~~
lamp.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         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...