QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#443782 | #8521. Pattern Search II | ucup-team1338# | WA | 0ms | 3864kb | C++20 | 1.2kb | 2024-06-15 16:30:29 | 2024-06-15 16:30:31 |
Judging History
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;c.b=-c.b;
long long x=0,y=0;
if(c.a!=0) x=c.a/abs(c.a)*c.a*c.a;
if(c.b!=0) y=c.b/abs(c.b)*c.b*c.b*5;
return x<y;
}
};
void solve(){
string s;
cin>>s;
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();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
aabbaab
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
a
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
b
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
aa
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
bb
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
ab
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
ba
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
bbba
output:
7
result:
ok 1 number(s): "7"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
abbbbbbbab
output:
20
result:
ok 1 number(s): "20"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
abbbbabbbabbbabbabaabbabb
output:
43
result:
ok 1 number(s): "43"
Test #11:
score: -100
Wrong Answer
time: 0ms
memory: 3652kb
input:
bbbaabaabbbaabababbbabaaabaaabbbaaaabaabaaaaabbabbbababbabaaba
output:
96
result:
wrong answer 1st numbers differ - expected: '94', found: '96'