#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(Task".inp", "r", stdin);
//freopen(Task".out", "w", stdout);
int ans=0, n;
cin >> n;
char tr='a';
rep(i, 1, n) {
char c;
cin >> c;
if(c!=tr&&i!=1) ++ans;
tr=c;
}
ans+=2;
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
632 KB |
Output is correct |
3 |
Correct |
2 ms |
740 KB |
Output is correct |
4 |
Correct |
2 ms |
828 KB |
Output is correct |
5 |
Correct |
2 ms |
828 KB |
Output is correct |
6 |
Correct |
2 ms |
828 KB |
Output is correct |
7 |
Correct |
3 ms |
828 KB |
Output is correct |
8 |
Correct |
2 ms |
828 KB |
Output is correct |
9 |
Correct |
2 ms |
828 KB |
Output is correct |
10 |
Correct |
2 ms |
828 KB |
Output is correct |