版本比较
题解:P15629 [2019 KAIST RUN Spring] Rainbow Beads
正文
增加 16 行删除 3 行
15 行未改动1617181920212223242526272829303115 行未改动typedef char ch;typedef string str;typedef double db;typedef __int128 i128;const ll inf=9e18;const i128 Inf=1e35;int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}```:::15 行未改动161718192021222324252627282930313233343536373839404142434415 行未改动typedef char ch;typedef string str;typedef double db;typedef __int128 i128;const ll inf=9e18,maxn=2.5e5+1;const i128 Inf=1e35;ll n,ans[maxn],Ans;str s;int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin>>n>>s;s=" "+s;for(int i=1;i<=n;i++){if(s[i]==s[i-1]) ans[i]=1;else if(s[i]=='R'&&s[i-1]=='V') ans[i]=1;else if(s[i]=='V'&&s[i-1]=='R') ans[i]=1;else if(s[i]=='B'&&s[i-1]=='V') ans[i]=1;else if(s[i]=='V'&&s[i-1]=='B') ans[i]=1;else ans[i]=ans[i-1]+1;Ans=max(Ans,ans[i]);}cout<<Ans;}```:::