Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define s second
- #define f first
- const int N = 100;
- using pi = pair <int, int>;
- vector <pi> fall;
- char Ball[N+10][N+10];
- bool block[N+10];
- int n, m, ball;
- void Setting();
- void Print();
- void Left(int s, int e){ /// s < e
- for(int i=1,j=e;j>=s;j--,i++){
- Ball[i][j] = '\\';
- n = max(n, i);
- }
- }
- void Right(int s, int e){ /// s < e
- for(int i=1,j=s;j<=e;j++,i++){
- Ball[i][j] = '/';
- n = max(n, i);
- }
- }
- bool f(){
- scanf("%d", &m);
- int sum = 0;
- bool sted = false;
- for(int i=1;i<=m;i++) {
- int x; scanf("%d", &x);
- if(x > 0) fall.push_back({x, i});
- if((i == 1 or i == m) and x == 0) sted = true;
- sum += x;
- }
- if(sted) return false;
- int sz = fall.size();
- ball = 1;
- for(int i=0;i<sz;i++){
- int d = fall[i].f;
- int s = ball;
- int e = ball + d - 1;
- if(s < fall[i].s) Left(s, fall[i].s - 1);
- if(fall[i].s < e) Right(fall[i].s + 1, e);
- ball = e + 1;
- }
- return true;
- }
- int main(){
- int Q;
- scanf("%d", &Q);
- for(int q=1;q<=Q;q++){
- Setting();
- bool ans = f();
- printf("Case #%d: ", q);
- if(!ans) printf("IMPOSSIBLE\n");
- else Print();
- }
- return 0;
- }
- void Print(){
- printf("%d\n", n+1);
- for(int i=n;i>=0;i--){ // 0 = bottom
- for(int j=1;j<=m;j++){
- printf("%c", Ball[i][j]);
- }
- printf("\n");
- }
- }
- void Setting(){
- for(int i=0;i<=N;i++){
- for(int j=1;j<=N;j++){
- Ball[i][j] = '.';
- }
- }
- if(!fall.empty()) fall.clear();
- n = 0;
- }
- /*
- 1
- 8
- 7 0 0 0 0 0 0 1
- Case #1: 7
- ....../.
- ...../..
- ..../...
- .../....
- ../.....
- ./......
- ........
- 1
- 10
- 1 2 3 3 0 0 0 0 0 1
- Case #1: 6
- ......../.
- ......./..
- .....//...
- ....//....
- ..///.....
- ..........
- 1
- 10
- 1 0 0 5 0 0 3 0 0 1
- 1
- 8
- 3 0 3 1 0 0 0 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement