-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy patha.cc
58 lines (55 loc) · 1014 Bytes
/
a.cc
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
// https://codejam.withgoogle.com/2018/challenges/0000000000007706/dashboard
#include <bits/stdc++.h>
using namespace std;
int a[101];
int b[101];
char e[101];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
for (int T = 1; T <= t; T++) {
int n;
cin >> n;
int c = 0;
int m = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
c += a[i];
m = max(m, abs(c - (i + 1)));
b[i] = 1;
}
m++;
cout << "Case #" << T << ": ";
if (c != n || a[0] == 0 || a[n - 1] == 0) {
cout << "IMPOSSIBLE\n";
continue;
}
cout << m << endl;
for (int i = 0; i < m; i++) {
c = 0;
int d = 0;
for (int j = 0; j < n; j++) e[j] = '.';
for (int j = 0; j < n; j++) {
c += b[j];
d += a[j];
if (c < d) {
e[j + 1] = '/';
b[j + 1]--;
b[j]++;
c++;
}
else if (c > d) {
e[j] = '\\';
b[j]--;
b[j + 1]++;
c--;
}
}
for (int j = 0; j < n; j++) cout << e[j];
cout << endl;
}
}
}