QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#333518 | #5577. Alchemy | joelgun14# | WA | 1ms | 3832kb | C++14 | 1.5kb | 2024-02-20 04:28:37 | 2024-02-20 04:28:38 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define bit(x) (1LL << (x))
#define getbit(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x.begin(), x.end())
using namespace std;
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
const int N = 2e5 + 5;
const int oo = 1e9;
const long long ooo = 1e18;
int main() {
string s;
cin >> s;
if(s.size() == 1) {
cout << 0 << endl;
}
else if(s.size() & 1) {
int res = 0;
for(int i = 0; i < s.size() / 2; ++i) {
if(s[i] != s[s.size() - i - 1])
++res;
}
//cout << s[s.size() / 2 - 1] << " " << s[s.size() - s.size() / 2] << endl;
if(s[s.size() / 2 - 1] != s[s.size() - s.size() / 2]) {
cout << res << endl;
}
else {
if(res & 1) {
++res;
}
cout << res << endl;
}
}
else {
int res = 0;
for(int i = 0; i < s.size() / 2; ++i) {
if(s[i] != s[s.size() - i - 1]) {
++res;
}
}
if(s[s.size() / 2] != s[s.size() / 2 - 1]) {
cout << res << endl;
}
else {
if(res & 1)
++res;
cout << res << endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
ioi
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
noi
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
ctsc
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
fool
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
vetted
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
aa
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
ic
output:
1
result:
ok single line: '1'
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 3640kb
input:
tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa
output:
24
result:
wrong answer 1st lines differ - expected: '12', found: '24'