blob: 79a2c3427f3e816b7d0c93a4ba187c753185f594 (
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
|
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int
main()
{
vector<string> d;
for (string l; getline(cin, l); )
d.push_back(l);
int y = 0;
int x = d[y].find('|');
string p1;
int p2 = 0;
for (int dx = 0, dy = 1; d[y][x] != ' '; x += dx, y += dy, p2++) {
if (isupper(d[y][x]))
p1.push_back(d[y][x]);
if (d[y][x] == '+') {
if (dx) {
dx = 0;
dy = (d[y+1][x] != ' ') ? 1 : -1;
} else {
dx = (d[y][x+1] != ' ') ? 1 : -1;
dy = 0;
}
}
}
cout << p1 << endl << p2 << endl;
}
|