Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 100;
- int tr[N + 10];
- int main(){
- int Q;
- scanf("%d", &Q);
- for(int q = 1; q <= Q; ++q){
- cout << "Case #" << q << ": ";
- char board[N + 10][N + 10] = {};
- int col;
- scanf("%d", &col);
- for(int i = 1; i <= col; ++i){
- scanf("%d", &tr[i]);
- }
- if(tr[1] == 0 || tr[col] == 0){
- cout << "IMPOSSIBLE\n";
- continue;
- }
- int bIdx = 1;
- int tIdx = 1;
- int currRow = 0;
- while(bIdx < col){
- if(tr[tIdx] == 0){
- ++tIdx;
- continue;
- }
- if(tIdx < bIdx){
- int i = 1;
- for(int j = bIdx; j > tIdx; --j){
- board[i][j] = '/';
- currRow = max(currRow, i);
- ++i;
- }
- } else if(tIdx > bIdx){
- int i = 1;
- for(int j = bIdx; j < tIdx; ++j){
- board[i][j] = '\\';
- currRow = max(currRow, i);
- ++i;
- }
- }
- --tr[tIdx];
- ++bIdx;
- }
- cout << currRow + 1 << '\n';
- for(int i = 1; i <= currRow + 1; ++i){
- for(int j = 1; j <= col; ++j){
- if(board[i][j] == '\0'){
- cout << '.';
- } else {
- cout << board[i][j];
- }
- }
- cout << '\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement