QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323853#5577. Alchemythanhha1210WA 1ms3744kbC++14731b2024-02-10 13:47:422024-02-10 13:47:43

Judging History

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

  • [2024-02-10 13:47:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3744kb
  • [2024-02-10 13:47:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
//while (true) {
    cin >> s;
    int len = s.length();
    int cnt = 0;

    int i = 0, j = len - 1;
    while (i < j) {
        if (s[i] == s[j]) {
            i++;
            j--;
        }

        else {
            if (j == i + 1 || j == i + 2) {
                cnt += 1;
                j--;
                i++;
            }
            else if (s[i + 1] != s[j - 1]) {
                cnt++;
                j-= 2;
                i+= 2;
            }
            else {
                cnt += 2;
                j-= 2;
                i+= 2;
            }

        }
    }
    cout << cnt << endl;
//}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

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

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

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

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

aa

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

ic

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

tlffohemdcncrfrxaqsbzcoyodvbxmhqukvfpahnakexcmacqa

output:

12

result:

ok single line: '12'

Test #9:

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

input:

qrgld

output:

1

result:

ok single line: '1'

Test #10:

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

input:

ejyfprguvwrnrsrykyrotmdjuzroohvlxqhvyeukkvmshtpczyyecpzhsqvkxueqvhlxldhofrzcjdhtotykgrsdnrnvuyrphyjy

output:

34

result:

wrong answer 1st lines differ - expected: '26', found: '34'