제출 #376140

#제출 시각아이디문제언어결과실행 시간메모리
376140daniel920712Lamps (JOI19_lamps)C++14
0 / 100
1091 ms81772 KiB
#include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; char a[1000005]; char b[1000005]; bool have[1000005]={0}; int DP[1000005],N; int F(int here) { int i,tt; if(here==N) return 0; if(have[here]) return DP[here]; have[here]=1; if(a[here]==b[here]) DP[here]=F(here+1); else DP[here]=F(here+1)+1; tt=0; for(i=here;i<N;i++) { if(b[i]=='1'&&(i==here||b[i-1]=='0')) tt++; DP[here]=min(DP[here],F(i+1)+tt+1); } tt=0; for(i=here;i<N;i++) { if(b[i]=='0'&&(i==here||b[i-1]=='1')) tt++; DP[here]=min(DP[here],F(i+1)+tt+1); } tt=0; for(i=here;i<N;i++) { if(a[i]==b[i]&&(i==here||a[i-1]!=b[i-1])) tt++; DP[here]=min(DP[here],F(i+1)+tt+1); } return DP[here]; } int main() { int M,ans=0,i; scanf("%d",&N); scanf("%s %s",a,b); printf("%d\n",F(0)); return 0; }

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

lamp.cpp: In function 'int main()':
lamp.cpp:42:9: warning: unused variable 'M' [-Wunused-variable]
   42 |     int M,ans=0,i;
      |         ^
lamp.cpp:42:11: warning: unused variable 'ans' [-Wunused-variable]
   42 |     int M,ans=0,i;
      |           ^~~
lamp.cpp:42:17: warning: unused variable 'i' [-Wunused-variable]
   42 |     int M,ans=0,i;
      |                 ^
lamp.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
lamp.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   44 |     scanf("%s %s",a,b);
      |     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...