-
Notifications
You must be signed in to change notification settings - Fork 0
/
800Div2 B
42 lines (34 loc) · 830 Bytes
/
800Div2 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
#define pi 3.141592653589793238462
#define mod 1000000007
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(), v.end()
#define acc(v) accumulate(all(v), 0)
#define pb push_back
#define isort(v) sort(all(v))
#define dsort(v) sort(v.rbegin(), v.rend())
#define in(v) for(auto &i : v) cin >> i
#define out(v) for(auto &i : v) cout << i << ' '
using namespace std;
void solve(){
ll n;
cin >> n;
string s;
cin >> s;
ll ans = 0;
for(ll i = 1; i < n; i++){
if(s[i] == s[i - 1]) ans++;
else ans += (i + 1);
}
cout << ++ans << "\n";
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int t = 1;
cin >> t; // Comment this line if there is only one TC
while(t --> 0) solve();
return 0;
}