QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601390#6128. Flippy Sequence122WA 0ms3588kbC++14922b2024-09-29 22:50:042024-09-29 22:50:05

Judging History

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

  • [2024-09-29 22:50:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-09-29 22:50:04]
  • 提交

answer

#include <bits/stdc++.h>
#define endl "\n"
#define int long long
#define PII std::pair<int, int>
#define PSS std::pair<string, string>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define inf 0x3f3f3f3f
//#define lc p<<1
//#define rc p<<1|1
#define PIS pair<int,string>
using namespace std;

const int N=1e5+10;

void solve() {
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	s1="!"+s1;
	s2="!"+s2;
	int cnt=0;
	int a=0;
	for(int i=1;i<=n;i++)
	{
		if(s1[i]==s2[i]) continue;
		cnt++;int now=i;
		while(s1[i]!=s2[i]&&i<=n) i++;
		a=i-now;
//		cout<<a<<endl;
	}
//	cout<<a<<endl;
	if(cnt>2)
	{
		cout<<0<<endl;
	}
	else if(cnt==1)
	{
		int len=n-a;
		int res=2*len;
		res+=2*(a-1);
	}
	else if(cnt==2)
	{
		cout<<6<<endl;
	}
	else if(cnt==0)
	{
		cout<<n*(n-1)/2<<endl;
	}
 }

signed main() {
	IOS; cout.tie(0);
	int t=1;
    cin>>t;
	while(t--) solve();
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3588kb

input:

3
1
1
0
2
00
11
5
01010
00111

output:

6

result:

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