QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507375#69. LampsreverSilly0 9ms3872kbC++23954b2024-08-06 16:55:022024-08-06 16:55:04

Judging History

你现在查看的是最新测评结果

  • [2024-08-06 16:55:04]
  • 评测
  • 测评结果:0
  • 用时:9ms
  • 内存:3872kb
  • [2024-08-06 16:55:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int mxn{1000005};
int T,dp[mxn][3];
int get(bitset<mxn>const&S,bitset<mxn>const&T)
{
	int res=0;
	for(int i=0;i<mxn;++i)
		if(S[i]^T[i])
			res=i+1;
	return res;
}
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin>>T;
	while(T--)
	{
		bitset<mxn>S,T;
		cin>>S>>T;
		int const n=get(S,T);
		dp[0][T[0]]=1;
		dp[0][!T[0]]=2;
		dp[0][2]=S[0]^T[0];
		for(int i=1;i<n;++i)
		{
			dp[i][T[i]]=min({dp[i-1][T[i-1]]+T[i]^T[i-1],dp[i-1][!T[i-1]]+T[i]^!T[i-1],dp[i-1][2]+1});//no xor
			dp[i][!T[i]]=min({dp[i-1][T[i-1]]+1+T[i-1]^!T[i],dp[i-1][!T[i-1]]+T[i]^T[i-1],dp[i-1][2]+1+(S[i-1]==T[i-1])});//yes xor
			if(S[i]^T[i])
				dp[i][2]=min({dp[i-1][T[i-1]]+1,dp[i-1][!T[i-1]],dp[i-1][2]+(S[i-1]==T[i-1])});
			else
				dp[i][2]=min({dp[i-1][T[i-1]],dp[i-1][!T[i-1]],dp[i-1][2]});
		}
		cout<<min({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 6
Accepted
time: 7ms
memory: 3856kb

input:

1
1
0

output:

1

result:

ok single line: '1'

Test #2:

score: 6
Accepted
time: 7ms
memory: 3768kb

input:

1
1
1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Wrong Answer
time: 8ms
memory: 3772kb

input:

2
10
01

output:

0
0

result:

wrong answer 1st lines differ - expected: '1', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #59:

score: 4
Accepted
time: 7ms
memory: 3796kb

input:

1
0
0

output:

0

result:

ok single line: '0'

Test #60:

score: 4
Accepted
time: 7ms
memory: 3872kb

input:

1
0
1

output:

1

result:

ok single line: '1'

Test #61:

score: 0
Wrong Answer
time: 9ms
memory: 3728kb

input:

2
00
00

output:

0
0

result:

wrong output format Extra information in the output file

Subtask #4:

score: 0
Skipped

Dependency #1:

0%