Atcoder Beginner Content 143 C - Slimes
Table of contents
# Problem
https://atcoder.jp/contests/abc143/tasks/abc143_c
# Explanation
Initialize a counter with 1.
Pick up a character one by one from the head of the string.
Increment the counter as you encounter a different character from the previous one.
# Time complexity
# Solution
#define MAX_N 100001
Int N;
char S[MAX_N];
Int solve() {
Int count = 1;
loop(n,1,N) {
if (S[n] != S[n-1]) count++;
}
return count;
}
int main() {
cin >> N;
loop(n,0,N) cin >> S[n];
cout << solve() << endl;
}
Shun
Remote freelancer. A web and mobile application enginner.
Traveling around the world based on East Asia.
I'm looking forward to your job offers from all over the world!