fork download
  1. import java.io.*;
  2. import java.util.*;
  3. import java.math.*;
  4. import java.lang.*;
  5.  
  6. import static java.lang.Math.*;
  7.  
  8. public class Solution implements Runnable {
  9. static class InputReader {
  10. private InputStream stream;
  11. private byte[] buf = new byte[1024];
  12. private int curChar;
  13. private int numChars;
  14. private SpaceCharFilter filter;
  15.  
  16. public InputReader(InputStream stream) {
  17. this.stream = stream;
  18. }
  19.  
  20. public int read() {
  21. if (numChars==-1)
  22. throw new InputMismatchException();
  23.  
  24. if (curChar >= numChars) {
  25. curChar = 0;
  26. try {
  27. numChars = stream.read(buf);
  28. }
  29. catch (IOException e) {
  30. throw new InputMismatchException();
  31. }
  32.  
  33. if(numChars <= 0)
  34. return -1;
  35. }
  36. return buf[curChar++];
  37. }
  38.  
  39. public String nextLine() {
  40. String str = "";
  41. try {
  42. str = br.readLine();
  43. }
  44. catch (IOException e) {
  45. e.printStackTrace();
  46. }
  47. return str;
  48. }
  49. public int nextInt() {
  50. int c = read();
  51.  
  52. while(isSpaceChar(c))
  53. c = read();
  54.  
  55. int sgn = 1;
  56.  
  57. if (c == '-') {
  58. sgn = -1;
  59. c = read();
  60. }
  61.  
  62. int res = 0;
  63. do {
  64. if(c<'0'||c>'9')
  65. throw new InputMismatchException();
  66. res *= 10;
  67. res += c - '0';
  68. c = read();
  69. }
  70. while (!isSpaceChar(c));
  71.  
  72. return res * sgn;
  73. }
  74.  
  75. public long nextLong() {
  76. int c = read();
  77. while (isSpaceChar(c))
  78. c = read();
  79. int sgn = 1;
  80. if (c == '-') {
  81. sgn = -1;
  82. c = read();
  83. }
  84. long res = 0;
  85.  
  86. do {
  87. if (c < '0' || c > '9')
  88. throw new InputMismatchException();
  89. res *= 10;
  90. res += c - '0';
  91. c = read();
  92. }
  93. while (!isSpaceChar(c));
  94. return res * sgn;
  95. }
  96.  
  97. public double nextDouble() {
  98. int c = read();
  99. while (isSpaceChar(c))
  100. c = read();
  101. int sgn = 1;
  102. if (c == '-') {
  103. sgn = -1;
  104. c = read();
  105. }
  106. double res = 0;
  107. while (!isSpaceChar(c) && c != '.') {
  108. if (c == 'e' || c == 'E')
  109. return res * Math.pow(10, nextInt());
  110. if (c < '0' || c > '9')
  111. throw new InputMismatchException();
  112. res *= 10;
  113. res += c - '0';
  114. c = read();
  115. }
  116. if (c == '.') {
  117. c = read();
  118. double m = 1;
  119. while (!isSpaceChar(c)) {
  120. if (c == 'e' || c == 'E')
  121. return res * Math.pow(10, nextInt());
  122. if (c < '0' || c > '9')
  123. throw new InputMismatchException();
  124. m /= 10;
  125. res += (c - '0') * m;
  126. c = read();
  127. }
  128. }
  129. return res * sgn;
  130. }
  131.  
  132. public String readString() {
  133. int c = read();
  134. while (isSpaceChar(c))
  135. c = read();
  136. StringBuilder res = new StringBuilder();
  137. do {
  138. res.appendCodePoint(c);
  139. c = read();
  140. }
  141. while (!isSpaceChar(c));
  142.  
  143. return res.toString();
  144. }
  145.  
  146. public boolean isSpaceChar(int c) {
  147. if (filter != null)
  148. return filter.isSpaceChar(c);
  149. return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  150. }
  151.  
  152. public String next() {
  153. return readString();
  154. }
  155.  
  156. public interface SpaceCharFilter {
  157. public boolean isSpaceChar(int ch);
  158. }
  159. }
  160. public static void main(String args[]) throws Exception {
  161. new Thread(null, new Solution(),"Main",1<<26).start();
  162. }
  163. public void run() {
  164. InputReader sc = new InputReader(System.in);
  165.  
  166. int t = sc.nextInt();
  167.  
  168. for(int p = 1; p <= t; ++p) {
  169. int n = sc.nextInt();
  170. int a[] = new int[n];
  171. int ptr = 0;
  172. int r = 1;
  173. int flag = 0;
  174. for(int i = 0; i < n; ++i) {
  175. a[i] = sc.nextInt();
  176. int cnt = 0, cntL = 0, cntR = 0;
  177. while(ptr < i && cnt != a[i]) {
  178. ptr++;
  179. cnt++;
  180. cntL++;
  181. }
  182. if(ptr == i && cnt != a[i]) {
  183. ptr++;
  184. cnt++;
  185. }
  186. while(cnt != a[i]) {
  187. ptr++;
  188. cntR++;
  189. cnt++;
  190. }
  191. r = max(r, max(cntL + 1, cntR + 1));
  192. }
  193. if(a[0] == 0 || a[n - 1] == 0) {
  194. w.println("Case #" + p + ": IMPOSSIBLE");
  195. continue;
  196. }
  197. char mat[][] = new char[r][n];
  198. for(int i = 0; i < r; ++i)
  199. for(int j = 0; j < n; ++j)
  200. mat[i][j] = '.';
  201. ptr = 0;
  202. for(int i = 0; i < n; ++i) {
  203. while(a[i] > 0) {
  204. if(ptr > i) {
  205. mat[r - 1 - ptr + i][ptr] = '/';
  206. }
  207. else if(ptr < i) {
  208. mat[r - 1 - i + ptr][ptr] = '\\';
  209. }
  210. a[i]--;
  211. ptr++;
  212. }
  213. }
  214. w.println("Case #" + p + ": " + r);
  215. for(int i = 0; i < r; ++i) {
  216. w.println(mat[i]);
  217. }
  218. }
  219.  
  220. w.close();
  221. }
  222. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: class Solution is public, should be declared in a file named Solution.java
public class Solution implements Runnable {
       ^
1 error
stdout
Standard output is empty