[STARTER] UVa program template JAVA

[java]
import java.io.IOException;

class Main implements Runnable {

public static void main(String[] args) {
Main main = new Main();
main.run();

}

@Override
public void run() {

ExecutorTemplate exe = new ExecutorTemplate();
exe.run();

}

}

class ExecutorTemplate implements Runnable {

@Override
public void run() {
//YOUR CODE HERE
}

private String readLine() {

byte line[] = new byte[255];
int length = 0;
int input = -1;
try {
while (length < 255) {// Read until maxlength
input = System.in.read();
if ((input < 0) || (input == '\n')) {
break; // or until end of line ninput
}
line[length++] += input;
}

if ((input < 0) && (length == 0)) {
return null; // eof
}
return new String(line, 0, length);
} catch (IOException e) {
return null;
}
}

}

[/java]

Advertisements

[SOLVED] UVa online 101 The Blocks Problem – WA

If you’re getting WA (Wrong Answer) for the problem 101 – The Blocks Problem. It means you need to have one more newline at the end of the output.

Wrong:
=======================
0:
1: 1
2: 2
3: 3
4:
5: 5 22 0
6: 6 14 13
7: 7
8:
9:
10: 10 15 12 4
11: 11
12:
13:
14:
15:
16:
17: 17
18: 18
19: 19
20: 20 8
21: 21 9 16
22:
23: 23
=======================
Right:
=======================
0:
1: 1
2: 2
3: 3
4:
5: 5 22 0
6: 6 14 13
7: 7
8:
9:
10: 10 15 12 4
11: 11
12:
13:
14:
15:
16:
17: 17
18: 18
19: 19
20: 20 8
21: 21 9 16
22:
23: 23

=======================