git reimport
This commit is contained in:
72
archive/2018.05/2018.05.19 - unsorted/TaskA.java
Normal file
72
archive/2018.05/2018.05.19 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
char[][] map = new char[n * 2][n];
|
||||
for (int i = 0; i < n * 2; i++) {
|
||||
Arrays.fill(map[i], '.');
|
||||
}
|
||||
|
||||
int maxRowUsed = 0;
|
||||
boolean ok = true;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
int src = i;
|
||||
int dest = 0;
|
||||
|
||||
for (; dest < n; dest++) {
|
||||
if (a[dest] > 0) {
|
||||
a[dest]--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int y = 0;
|
||||
while (src != dest) {
|
||||
if (src == 0 || src == n - 1) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
boolean dir = src < dest;
|
||||
map[y][src] = dir ? '\\' : '/';
|
||||
src += dir ? 1 : -1;
|
||||
|
||||
y++;
|
||||
|
||||
maxRowUsed = Math.max(maxRowUsed, y);
|
||||
}
|
||||
}
|
||||
|
||||
maxRowUsed++;
|
||||
|
||||
if (!ok) {
|
||||
out.println("IMPOSSIBLE");
|
||||
return;
|
||||
}
|
||||
|
||||
out.println(maxRowUsed);
|
||||
for (int i = 0; i < maxRowUsed; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
out.print(map[i][j]);
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user