QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#690254#6128. Flippy SequenceDanRan02WA 0ms3588kbC++201012b2024-10-30 21:16:312024-10-30 21:16:32

Judging History

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

  • [2024-10-30 21:16:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-10-30 21:16:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;


void solve() {
	LL n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	LL cnt1 = 0, cnt2 = 0, pre = 0, aft = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] != t[i]) {
			int pos = i;
			while (i < n && s[i] != t[i]) i++;
			if (!cnt1) {
				cnt1 = i - pos;
				pre = pos;
				aft = n - i;
			} else if (!cnt2) {
				cnt2 = i - pos;
				aft = n - i;
			} else {
				cout << 0 << '\n';
				return;
			}
		}
//		cout << pre << ' ' << af/t << '\n';
	}
	LL res = 0;
	if (cnt1 < cnt2) swap(cnt1, cnt2);
	if (!cnt1 && !cnt2) {
		res = (n - 1) * n / 2 + n;
		cout << res << '\n';
	} else if (!cnt2) {
		if (pre) res += 2 * pre;
		if (aft) res += 2 * aft;
		if (cnt1 > 1) res += (cnt1 - 1) * 2;
		else if (cnt1 == 1) res += 1;
		cout << res << '\n';
	} else {
		cout << 6 << '\n';
	}
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

input:

3
1
1
0
2
00
11
5
01010
00111

output:

1
2
6

result:

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