제출 #1237222

#제출 시각아이디문제언어결과실행 시간메모리
1237222nasjesGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++20
0 / 100
0 ms328 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; const ll dim = 5*1e3+7; //const ll mod = 1e9 + 7; const ll inf = 1e18 + 77; #define endl "\n" #define fi first #define pb push_back #define se second #define vll vector<ll> ll n, m; pll a[dim]; ll b[dim]; int main() { ll k, t, u0, v0; string s; cin>>n; cin>>s; ll ans=0; for(int i=1; i<n; i++){ if(s[i]==s[i-1]){ for(int j=i+1; j<n; j++){ if(s[j]!=s[i]){ ans+=abs(j-i); swap(s[j], s[i]); break; } } } } // cout<<s<<endl; cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...