QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#753481#5577. Alchemyanyan26WA 0ms3840kbC++171.2kb2024-11-16 13:04:292024-11-16 13:04:30

Judging History

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

  • [2024-11-16 13:04:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-11-16 13:04:29]
  • 提交

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;
    else dp[0]=1;
    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: 3640kb

input:

ioi

output:

0

result:

ok single line: '0'

Test #2:

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

input:

noi

output:

1

result:

ok single line: '1'

Test #3:

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

input:

ctsc

output:

1

result:

ok single line: '1'

Test #4:

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

input:

fool

output:

2

result:

ok single line: '2'

Test #5:

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

input:

vetted

output:

2

result:

ok single line: '2'

Test #6:

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

input:

aa

output:

0
0

result:

wrong output format Extra information in the output file