QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690252#6128. Flippy SequenceDanRan02Compile Error//C++201011b2024-10-30 21:16:002024-10-30 21:16:01

Judging History

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

  • [2024-10-30 21:16:01]
  • 评测
  • [2024-10-30 21:16:00]
  • 提交

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 += ;
		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;
}

Details

answer.code: In function ‘void solve()’:
answer.code:40:44: error: expected primary-expression before ‘;’ token
   40 |                 else if (cnt1 == 1) res += ;
      |                                            ^