QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443397#8521. Pattern Search IIucup-team1338#WA 1ms3764kbC++20765b2024-06-15 15:26:332024-06-15 15:26:33

Judging History

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

  • [2024-06-15 15:26:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3764kb
  • [2024-06-15 15:26:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1000013;
typedef long double ld;
const ld eps=1e-12;
void solve(){
    string s;
    cin>>s;
    ld l=-(sqrtl(5)-1)/2,r=1;
    vector<int>v;
    int cnt=0;
    int ans=0;
    for(auto c:s){
        if(c=='a'){
            if(r<0)l+=1,r+=1,ans++;
            l-=(sqrtl(5)-1)/2,r-=(sqrtl(5)-1)/2;
            r=min(1.0l,r),l=max(-1+eps,l);
        }else{
            if(l>=0)ans++,l-=(sqrtl(5)-1)/2,r-=(sqrtl(5)-1)/2;
            l+=1,r+=1;
            r=min(1.0l,r),l=max(-1+eps,l);
        }
    }
    cout<<ans+s.size()<<'\n';
}


int main(){
    ios::sync_with_stdio(false);
    int T=1;
   // cin>>T;

    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

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

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

bb

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

ab

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

ba

output:

2

result:

ok 1 number(s): "2"

Test #8:

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

input:

bbba

output:

6

result:

wrong answer 1st numbers differ - expected: '7', found: '6'