18,20TLE
2026-10-04 13:04:06
发布于:浙江
18,20TLE
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 9;
char c[N]; int n;
ll sum;
set <char> s;
int main() {
freopen("HoShi.in", "r", stdin);
freopen("HoShi.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> c[i];
s.insert(c[i]);
}
if (s.size() == 1) {
cout << '0';
return 0;
}
for (int i = 1; i <= n; i++) {
if (c[i] == 'o') {
for (int j = i - 1; j >= 1; j--) {
if (c[j] == '*') {
sum += (i - j);
break;
}
}
for (int j = i + 1; j <= n; j++) {
if (c[j] == '*') {
sum += (j - i);
break;
}
}
}
}
cout << sum;
return 0;
}
这里空空如也




















有帮助,赞一个