blob: c2179b72280089521afb76e49d459a742ca8e15c (
plain) (
blame)
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
40
41
|
#include <iostream>
#include <fstream>
#include <vector>
std::vector<std::string> parse(const char* file)
{
std::vector<std::string> v;
if (std::ifstream input{ file }; input.is_open())
{
std::string line;
while (not std::getline(input,line).eof())
{
v.push_back(std::move(line));
}
}
return v;
}
int main(int argc, char* argv[])
{
int answer{};
auto v = parse(argv[1]);
for (int c = 0; c < v.size(); ++c)
{
int floor = v.size();
for (int r = 0; r < v.size(); ++r)
{
switch (v[r][c])
{
case '#':
floor = v.size() - r - 1;
break;
case 'O':
answer += floor--;
}
}
}
std::cout << answer << std::endl;
return 0;
}
|