QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443400#8521. Pattern Search IIucup-team1338#WA 0ms3808kbC++20783b2024-06-15 15:27:182024-06-15 15:27:19

Judging History

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

  • [2024-06-15 15:27:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-06-15 15:27:18]
  • 提交

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(-(sqrtl(5)-1)/2,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(-(sqrtl(5)-1)/2,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: 0ms
memory: 3540kb

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

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

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

bb

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

ab

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

ba

output:

2

result:

ok 1 number(s): "2"

Test #8:

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

input:

bbba

output:

6

result:

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