답안 #1116213

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116213 2024-11-21T10:55:44 Z firewater Lamps (JOI19_lamps) C++14
4 / 100
24 ms 31820 KB
#include<bits/stdc++.h>
#define N 1001000
using namespace std;
int n,ans,a[N],b[N],f[N][5];
char s1[N],s2[N];
int main()
{
	scanf("%d%s%s",&n,s1+1,s2+1);
	for(int i=1;i<=n;++i)
		a[i]=s2[i]-'0'+1,b[i]=(s1[i]!=s2[i]);
	memset(f,127/3,sizeof(f));
	f[0][0]=0;
	b[0]=-1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=2;++j){
			f[i][0]=min(f[i][0],f[i-1][j]+(b[i]&&b[i]!=b[i-1]));
			if(j)f[i][j]=min(f[i][j],f[i-1][j]+(a[i]!=j&&a[i]!=a[i-1]));
			f[i][a[i]]=min(f[i][a[i]],f[i-1][j]+1);
		}
	ans=f[0][1];	
//	for(int i=1;i<=n;++i){
//		for(int j=0;j<=2;++j)
//			printf("%d ",f[i][j]);
//		printf("%d",b[i]);
//		putchar(10);
//	}
	for(int j=0;j<=2;++j)
		ans=min(ans,f[n][j]);
	printf("%d\n",ans);
	return 0;
}

Compilation message

lamp.cpp: In function 'int main()':
lamp.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d%s%s",&n,s1+1,s2+1);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 24912 KB Output is correct
2 Correct 4 ms 24928 KB Output is correct
3 Correct 4 ms 24912 KB Output is correct
4 Correct 4 ms 24912 KB Output is correct
5 Correct 4 ms 25084 KB Output is correct
6 Correct 4 ms 24912 KB Output is correct
7 Correct 4 ms 24912 KB Output is correct
8 Correct 4 ms 24912 KB Output is correct
9 Correct 4 ms 24912 KB Output is correct
10 Correct 4 ms 25024 KB Output is correct
11 Correct 4 ms 24912 KB Output is correct
12 Correct 3 ms 24912 KB Output is correct
13 Incorrect 4 ms 24912 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 24912 KB Output is correct
2 Correct 4 ms 24928 KB Output is correct
3 Correct 4 ms 24912 KB Output is correct
4 Correct 4 ms 24912 KB Output is correct
5 Correct 4 ms 25084 KB Output is correct
6 Correct 4 ms 24912 KB Output is correct
7 Correct 4 ms 24912 KB Output is correct
8 Correct 4 ms 24912 KB Output is correct
9 Correct 4 ms 24912 KB Output is correct
10 Correct 4 ms 25024 KB Output is correct
11 Correct 4 ms 24912 KB Output is correct
12 Correct 3 ms 24912 KB Output is correct
13 Incorrect 4 ms 24912 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 24912 KB Output is correct
2 Correct 4 ms 24912 KB Output is correct
3 Correct 4 ms 24912 KB Output is correct
4 Correct 4 ms 24912 KB Output is correct
5 Correct 4 ms 24912 KB Output is correct
6 Correct 3 ms 24912 KB Output is correct
7 Correct 24 ms 31568 KB Output is correct
8 Correct 21 ms 31820 KB Output is correct
9 Correct 22 ms 31568 KB Output is correct
10 Correct 21 ms 31568 KB Output is correct
11 Correct 20 ms 31568 KB Output is correct
12 Correct 21 ms 31540 KB Output is correct
13 Correct 22 ms 31568 KB Output is correct
14 Correct 20 ms 31568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 24912 KB Output is correct
2 Correct 4 ms 24928 KB Output is correct
3 Correct 4 ms 24912 KB Output is correct
4 Correct 4 ms 24912 KB Output is correct
5 Correct 4 ms 25084 KB Output is correct
6 Correct 4 ms 24912 KB Output is correct
7 Correct 4 ms 24912 KB Output is correct
8 Correct 4 ms 24912 KB Output is correct
9 Correct 4 ms 24912 KB Output is correct
10 Correct 4 ms 25024 KB Output is correct
11 Correct 4 ms 24912 KB Output is correct
12 Correct 3 ms 24912 KB Output is correct
13 Incorrect 4 ms 24912 KB Output isn't correct
14 Halted 0 ms 0 KB -