QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#181355 | #5577. Alchemy | Fr1nGeLove | WA | 1ms | 3544kb | C++20 | 659b | 2023-09-16 18:01:30 | 2023-09-16 18:01:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
if (s.length() & 1) {
s.erase(s.begin() + s.length() / 2, s.begin() + s.length() / 2 + 1);
}
int i = 0, j = s.length() - 1;
int ans = 0;
while (i < j) {
if (s[i] != s[j]) {
ans++;
if (s[i + 1] != s[j - 1]) {
s[i + 1] = s[j - 1] = 'a';
} else if (i + 2 < j) {
s[i + 1] = s[j - 1] = 'a';
s[i + 2] = s[j - 2] = 'a';
ans++;
}
s[i] = s[j] = 'a';
i += 2, j -= 2;
} else {
i++, j--;
}
}
cout << ans << '\n';
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
input:
ioi
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
noi
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
ctsc
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3400kb
input:
fool
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
vetted
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
aa
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3444kb
input:
ic
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa
output:
12
result:
ok single line: '12'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
qrgld
output:
1
result:
ok single line: '1'
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3444kb
input:
ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy
output:
34
result:
wrong answer 1st lines differ - expected: '26', found: '34'