QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443578#8521. Pattern Search IIucup-team1338#WA 0ms3540kbC++201.4kb2024-06-15 16:00:312024-06-15 16:00:32

Judging History

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

  • [2024-06-15 16:00:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-06-15 16:00:31]
  • 提交

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: 0
Wrong Answer
time: 0ms
memory: 3540kb

input:

aabbaab

output:

7
7
7
8
8
8
8

result:

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