这题是【BZOJ4318】的减弱版。
拿过来改改就行了。
/* Footprints In The Blood Soaked Snow */
#include <cstdio>
const int maxn = 300005;
typedef double DB;
int n;
char str[maxn];
int main() {
scanf("%d%s", &n, str + 1);
DB E1 = 1.0, EX = 0.0, EX2 = 0.0, ans = 0.0;
for(int i = 1; i <= n; i++) {
DB p;
if(str[i] == 'o') p = 1.0;
else if(str[i] == '?') p = 0.5;
else if(str[i] == 'x') p = 0.0;
ans -= EX2 * p;
EX2 = p * (EX2 + 2 * EX + E1);
EX = p * (EX + E1);
E1 = p * E1 + 1 - p;
ans += EX2;
}
printf("%.4lf\n", ans);
return 0;
}