32 lines
559 B
C++
32 lines
559 B
C++
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
|
||
|
int main() {
|
||
|
ios::sync_with_stdio(0);
|
||
|
cin.tie(0);
|
||
|
|
||
|
vector<string> lines;
|
||
|
|
||
|
string line;
|
||
|
while (getline(cin, line) && !line.empty()) {
|
||
|
lines.push_back(line);
|
||
|
}
|
||
|
|
||
|
int ret = 0;
|
||
|
for (unsigned int r = 0; r < lines.size(); r++) {
|
||
|
for (unsigned int c = 0; c < lines[r].size(); c++) {
|
||
|
if (lines[r][c] == 'O') {
|
||
|
lines[r][c] = '.';
|
||
|
int rr = r;
|
||
|
while (rr != 0 && lines[rr - 1][c] == '.') {
|
||
|
rr--;
|
||
|
}
|
||
|
lines[rr][c] = 'O';
|
||
|
ret += lines.size() - rr;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
cout << ret << '\n';
|
||
|
}
|