# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1089216 | vjudge1 | Growing Vegetable is Fun 3 (JOI19_ho_t3) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//qwerty47924692
using namespace std;
using ll = long long;
#define f first
#define s second
const ll N=3e5+29;
ll dp[65][4000][3],n,a[N],ans=0;
string s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>s;
bool ch=1;
ll k=1000;
while(ch&&k--){
for(ll i=1;i<s.size()-1;i++){
if(s[i]==s[i-1]&&s[i]!=s[i+1]){
ans++;
swap(s[i],s[i+1]);
}
if(s[i]==s[i+1]&&s[i]!=s[i-1]){
ans++;
swap(s[i],s[i-1]);
}
}
ch=0;
for(ll i=1;i<s.size();i++){
if(s[i]==s[i-1])ch=1;
}
}
if(k==-1){
cout<<k;
}
else cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |