QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181355#5577. AlchemyFr1nGeLoveWA 1ms3544kbC++20659b2023-09-16 18:01:302023-09-16 18:01:32

Judging History

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

  • [2023-09-16 18:01:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3544kb
  • [2023-09-16 18:01:30]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

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'