Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int C, B[110], to[110];
- char mp[11000][110];
- void Solve(){
- memset(mp, '.', sizeof(mp));
- scanf("%d", &C);
- for(int i = 0 ; i < C ; i++)
- scanf("%d", &B[i]);
- if(B[0] == 0 || B[C - 1] == 0){
- printf("IMPOSSIBLE\n");
- return;
- }
- int now = 0, l = 0;
- for(int i = 0 ; i < C ; i++){
- while(B[now] == 0) now++;
- while(B[now] > 0 && l <= i){
- to[l] = now;
- l++;
- B[now]--;
- }
- }
- //for(int i = 0 ; i < C ; i++)
- //printf("%d ", to[i]);
- //puts("");
- int rows = 1;
- for(int i = 0 ; i < C ; i++){
- if(to[i] != i){
- int st = (to[i] - i) / abs(to[i] - i);
- for(int j = i ; j != to[i] ; j += st){
- mp[rows++][j] = st == 1 ? '\\' : '/';
- }
- }
- }
- printf("%d\n", rows);
- for(int i = 0 ; i < rows ; i++) {
- for(int j = 0 ; j < C ; j++) {
- printf("%c", mp[i][j]);
- }
- printf("\n");
- }
- }
- int main(){
- int T;
- scanf("%d", &T);
- for(int i = 1 ; i <= T ; i++){
- printf("Case #%d: ", i);
- Solve();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment