- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_File_Name.cpp
More file actions
Latest commit
39 lines (35 loc) · 613 Bytes
/
Copy pathB_File_Name.cpp
File metadata and controls
39 lines (35 loc) · 613 Bytes
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
#include<bits/stdc++.h>
usingnamespacestd;
intmain()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < n;)
{
if (s[i] == 'x')
{
int j = i;
while (j < n && s[j] == 'x')
{
j++;
}
int len = j - i;
if (len >= 3)
{
ans += (len - 2);
}
i = j;
}
else
{
i++;
}
}
cout << ans << "\n";
return0;
}