SOLUTION INFO
C++ · main.cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string word;
int red = 0, blue = 0;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> word;
for (int i = 0; i < n; i++) {
if (i == 0) {
if (word[i] == 'B') { blue++; }
if (word[i] == 'R') { red++; }
}
else {
if (word[i] == 'B' && word[i - 1] == 'R') { blue++; }
if (word[i] == 'R' && word[i - 1] == 'B') { red++; }
}
}
cout << min(red, blue) + 1 << "\n";
return 0;
}
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.