https://ac.nowcoder.com/acm/contest/7614/C

```10
oo
.o
.x
x.
..
oo
.o
x.
..
x.```

`12`

```..
oo
ox
x.
..
..
..
x.
oo
xo```

## 思路

1. 某一行两个都是墙
2. 行左边的是墙， 行右边的是墙
3. 行右边的是墙， 行左边的是墙

## 代码

```#include<cstdio>
#include<iostream>

using namespace std;

int n, ans, have[300001][3], pla[300001], high;
char c[300001][3];

int main() {
scanf("%d", &n);

for (int i = 1; i <= n; i++) {
c[i][1] = getchar();
while (c[i][1] != 'o' && c[i][1] != '.' && c[i][1] != 'x') c[i][1] = getchar();
c[i][2] = getchar();
while (c[i][2] != 'o' && c[i][2] != '.' && c[i][2] != 'x') c[i][2] = getchar();
}

pla[0] = 0;
high = 1;
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= 2; j++) {
if (c[i][j] == 'o') {
if(pla[high] > i && pla[0] >= high) {//球能向下走
ans += pla[high] - i;
high++;
pla[++pla[0]] = i;
}
}
else if (c[i][j] == '.') pla[++pla[0]] = i;//有能放的位置
}
if ((c[i][1] == 'x' && c[i][2] == 'x') || (c[i][1] == 'x' && c[i - 1][2] == 'x') || (c[i - 1][1] == 'x' && c[i][2] == 'x')) {
pla[0] = 0;
high = 1;
}//被分割到新的区域
}

printf("%d", ans);

return 0;
}```

01-11 20:08

2022-12-14 23:54

2022-12-20 11:39

2022-12-15 15:13

2022-12-30 15:34

2022-12-27 18:33

2022-12-09 20:28

01-06 21:26

2022-12-31 23:19

2022-12-13 21:48