QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443583#8521. Pattern Search IIucup-team1338#WA 0ms3844kbC++201.4kb2024-06-15 16:01:042024-06-15 16:01:05

Judging History

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

  • [2024-06-15 16:01:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-06-15 16:01:04]
  • 提交

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;
struct num{
    long long a,b;//a/2+bsqrt(5)/2
    num operator +(const num& z)const{return {a+z.a,b+z.b};}
    num operator -(const num& z)const{return {a-z.a,b-z.b};}
    bool operator ==(const num& z)const{return a==z.a&&b==z.b;}
    bool operator <(const num& z)const{
        num c=(*this)-z;
        if(c.a==0&&c.b==0)return false;
        if(c.a<=0&&c.b<=0)return true;
        if(c.a>0&&c.b>0)return false;
        if(c.a==0&&c.b>0||c.a>0&&c.b==0)return false;
        if(c.a>0&&c.b<0){
            return c.a*c.a<c.b*c.b*5;
        }
        if(c.a<0&&c.b>0){
            return c.a*c.a>c.b*c.b*5;
        }
    }
};
void solve(){
    string s;
    cin>>s;
    //ld l=-(sqrtl(5)-1)/2,r=1;
    num l={1,-1};
    num r={2,0};
    num o={0,0};
    num d={-1,1};
    num e={2,0};
    int ans=0;
    for(auto c:s){
        if(c=='a'){
            if(r<o) l=l+e,r=r+e,ans++;
            l=l-d,r=r-d;
            r=min(e,r);
            l=max(o-d,l);
        }else{
            while(!(l<o)) ans++,l=l-d,r=r-d;
            l=l+e,r=r+e;
            r=min(e,r),l=max(o-d,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: 3508kb

input:

aabbaab

output:

8

result:

ok 1 number(s): "8"

Test #2:

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

input:

a

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

b

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

aa

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

bb

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

ab

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

ba

output:

2

result:

ok 1 number(s): "2"

Test #8:

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

input:

bbba

output:

7

result:

ok 1 number(s): "7"

Test #9:

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

input:

abbbbbbbab

output:

20

result:

ok 1 number(s): "20"

Test #10:

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

input:

abbbbabbbabbbabbabaabbabb

output:

43

result:

ok 1 number(s): "43"

Test #11:

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

input:

bbbaabaabbbaabababbbabaaabaaabbbaaaabaabaaaaabbabbbababbabaaba

output:

96

result:

wrong answer 1st numbers differ - expected: '94', found: '96'