QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#690254 | #6128. Flippy Sequence | DanRan02 | WA | 0ms | 3588kb | C++20 | 1012b | 2024-10-30 21:16:31 | 2024-10-30 21:16:32 |
Judging History
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;
}
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:
1 2 6
result:
wrong answer 1st numbers differ - expected: '0', found: '1'