Introduction to Programming Introduction to Algorithms and Data Structures Library of Data Structures Library of Graph Algorithms Library of Computational Geometry Library of Dynamic Programming Library of Number Theory
左の点を に変えて,他を空白に変える. に変えた場所の上を見ていき,空白ならば に変える.
Code
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std ;
typedef long long ll ;
typedef pair < int , int > P ;
int n ;
vector < string > v ;
int main () {
while ( cin >> n ) {
v . resize ( n );
rep ( i , n ) cin >> v [ i ];
rep ( i , n ) {
bool flag = true ;
for ( int j = v [ i ]. size () - 1 ; j >= 0 ; j -- ) {
if ( v [ i ][ j ] == '.' ) {
if ( flag ) {
v [ i ][ j ] = '+' ;
flag = false ;
} else {
v [ i ][ j ] = ' ' ;
}
}
}
}
for ( int i = n - 1 ; i >= 0 ; i -- ) {
for ( int j = v [ i ]. size () - 1 ; j >= 0 ; j -- ) {
if ( v [ i ][ j ] == '+' ) {
int k = i ;
while ( k - 1 >= 0 && v [ k - 1 ][ j ] == ' ' ) {
v [ k - 1 ][ j ] = '|' ;
k -- ;
}
}
}
}
rep ( i , n ) {
cout << v [ i ] << endl ;
}
}
return 0 ;
}