QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#731398#5577. Alchemyjkliao#WA 0ms3732kbC++17627b2024-11-10 03:15:132024-11-10 03:15:13

Judging History

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

  • [2024-11-10 03:15:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2024-11-10 03:15:13]
  • 提交

answer

#include <iostream>
#include <vector>

using namespace std;

int main() {
	string t; cin >> t;
	int n = t.length();
	vector<char> s(n+2);
	for (int i = 1; i <= n; i++) {
		s[i] = t[i-1];
	}
	vector<int> dp(n+2, 1e9);
	dp[0] = 0;
	for (int i = 1; i <= n/2 + 1; i++) {
		if (s[i] == s[n-i+1]) {
			dp[i] = min(dp[i], dp[i-1]);
		}
		if (i >= 2) {
			if ((s[i] != s[n-i+1] && s[i-1] != s[n-i+2]) || i == n/2 + 1) {
				dp[i] = min(dp[i], 1 + dp[i-2]);
			}
			else {
				dp[i] = min(dp[i], 2 + dp[i-2]);
			}
		}
	}
	/*
	for (int i = 0; i <= n; i++) {
		cout << dp[i] << ' ';
	}
	cout << endl;
	*/
	cout << dp[n/2 + 1] << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

14

result:

wrong answer 1st lines differ - expected: '12', found: '14'