QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#753473#5577. Alchemyanyan26WA 0ms3836kbC++171.2kb2024-11-16 13:03:242024-11-16 13:03:25

Judging History

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

  • [2024-11-16 13:03:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-11-16 13:03:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main(){
    /*
    * ABBA -> dp[0] = 0, dp[1] = 0
    * ABCA -> dp[0] = 1, dp[1] = 1
    * ABCD -> dp[0] = 1, dp[1] = 2
    * ABBC -> dp[0] = 0, dp[1] = 2
    */
   /*
   * ABA -> dp[0] = 0, dp[1] = 0
   * ABC -> dp[0] = 0, dp[1] = 1
   * AAB -> dp[0] = 0, dp[1] = 1
   * AAA -> dp[-] = 0, dp[1] =0 0
   */
   string s; cin >> s;
   if(s.size()==2){
    cout << !(s[0]==s[1]) << "\n";
   }
   int center = s.size()/2;
   int dp[(s.size()+1)/2];
   for(auto & i : dp)i = 0;
   int lp = center-3, rp=center+2;
   if(s.size()%2==0){
    if(s[center]==s[center-1])dp[0] = 0;
    if(s[center-2]!=s[center+1])dp[1] =2;
    else dp[1] = dp[0];
   }else if(s.size()%2==1){
    dp[0] = 0;
    if(s[center-1]==s[center+1])dp[1]=0;
    else dp[1] = 1;
    lp=center-2;
    rp=center+2;
   }
   while(lp>=0){
    if(s[lp]==s[rp]){
        dp[center-lp]=dp[center-lp-1];
    }else{
        if(s[lp+1] != s[rp-1]){
            dp[rp-center]=dp[rp-center-2]+1;
        }else{
            dp[rp-center]=dp[rp-center-2]+2;
        }
    }
    lp--; rp++;
   }
   cout << dp[center-(s.size()%2==0)] << "\n";
}

详细

Test #1:

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

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

0

result:

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