QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#690252 | #6128. Flippy Sequence | DanRan02 | Compile Error | / | / | C++20 | 1011b | 2024-10-30 21:16:00 | 2024-10-30 21:16:01 |
Judging History
This is the latest submission verdict.
- [2024-10-30 21:16:01]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-30 21:16:00]
- Submitted
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;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:40:44: error: expected primary-expression before ‘;’ token 40 | else if (cnt1 == 1) res += ; | ^