Task: | Ruudukko |
Sender: | |
Submission time: | 2015-09-12 01:41:34 +0300 |
Language: | Java |
Status: | READY |
Result: | 12 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | WRONG ANSWER | 0 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.21 s | 1 | details |
#2 | ACCEPTED | 0.21 s | 1 | details |
#3 | ACCEPTED | 0.20 s | 1 | details |
#4 | ACCEPTED | 0.22 s | 1 | details |
#5 | ACCEPTED | 0.21 s | 1 | details |
#6 | ACCEPTED | 0.20 s | 2 | details |
#7 | ACCEPTED | 0.20 s | 2 | details |
#8 | WRONG ANSWER | 0.20 s | 2 | details |
#9 | WRONG ANSWER | 0.20 s | 2 | details |
#10 | ACCEPTED | 0.21 s | 2 | details |
#11 | RUNTIME ERROR | 0.20 s | 3 | details |
#12 | RUNTIME ERROR | 0.20 s | 3 | details |
#13 | RUNTIME ERROR | 0.21 s | 3 | details |
#14 | RUNTIME ERROR | 0.19 s | 3 | details |
#15 | RUNTIME ERROR | 0.19 s | 3 | details |
Code
//package putka3.pkg2; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.PriorityQueue; import java.util.Scanner; /** * * @author Adreno */ public class Putka32 { public static boolean[][] r; public static void main(String[] args) { Scanner input = new Scanner(System.in); int goal = input.nextInt(); r = new boolean[20][20]; for (int x=0; x<20; x++) r[0][x] = true; for (int y=0; y<20; y++) r[y][19] = true; int nextEmptyLine = 1; while (calc() < goal) { for (int x=10; x<20; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } if (calc() > goal) { nextEmptyLine--; for (int x=10; x<19; x++) { r[nextEmptyLine][x] = false; } } for (int x=0; x<20; x++) r[19][x] = true; for (int y=0; y<20; y++) r[y][0] = true; nextEmptyLine += 2; if (calc() < goal) { for (int x=0; x<19; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } while (calc() < goal) { for (int x=14; x<20; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } if (calc() > goal) { nextEmptyLine--; for (int x=14; x<19; x++) { r[nextEmptyLine][x] = false; } } nextEmptyLine += 2; if (calc() < goal) { for (int x=0; x<19; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } while (calc() < goal) { for (int x=16; x<20; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } if (calc() > goal) { nextEmptyLine--; for (int x=16; x<19; x++) { r[nextEmptyLine][x] = false; } } nextEmptyLine += 2; if (calc() < goal) { for (int x=0; x<19; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } while (calc() < goal) { for (int x=17; x<20; x++) { r[nextEmptyLine][x] = true; } nextEmptyLine++; } if (calc() > goal) { nextEmptyLine--; for (int x=17; x<19; x++) { r[nextEmptyLine][x] = false; } } //System.out.println("reached k=" + calc()); for (int y=0; y<20; y++) { for (int x=0; x<20; x++) { System.out.print((r[y][x] ? "." : "#")); } System.out.println(""); } } public static int calc() { ArrayDeque<Loc> jono = new ArrayDeque<>(); jono.add(new Loc(0,0)); boolean[][] kayty = new boolean[20][20]; int[][] ways = new int[20][20]; ways[0][0] = 1; while (!jono.isEmpty()) { Loc nyk = jono.poll(); if (kayty[nyk.y][nyk.x]) continue; kayty[nyk.y][nyk.x] = true; //System.out.println("kaytiin y=" + nyk.y + ", x=" + nyk.x); if (nyk.y < 19 && r[nyk.y+1][nyk.x]) { ways[nyk.y+1][nyk.x] += ways[nyk.y][nyk.x]; jono.add(new Loc(nyk.y+1, nyk.x)); } if (nyk.x < 19 && r[nyk.y][nyk.x+1]) { ways[nyk.y][nyk.x+1] += ways[nyk.y][nyk.x]; jono.add(new Loc(nyk.y, nyk.x+1)); } } return ways[19][19]; } } class Loc { public int x; public int y; public Loc(int y, int x) { this.x = x; this.y = y; } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
2 |
correct output |
---|
.................... .################### .################### .################### .################### ... |
user output |
---|
.................... .##################. .##################. .##################. .##################. ... |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
.................... .################..# .#################.. .#################.. .##################. ... |
user output |
---|
.................... .##################. .##################. .................... .##################. ... |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
.................... .################..# .#################.. .#################.. .##################. ... |
user output |
---|
.................... .##################. .##################. .................... .##################. ... |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
8 |
correct output |
---|
.................... .################### .################### .################### .################### ... |
user output |
---|
.................... .##################. .##################. .................... .#############...... ... |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
9 |
correct output |
---|
.................... .################### .################### .################### .################### ... |
user output |
---|
.................... .##################. .##################. .................... .#############...... ... |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
19 |
correct output |
---|
.................... .############..##### .#############..#### .#############...### .##############...## ... |
user output |
---|
.................... .#########.......... .##################. .##################. .................... ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
32 |
correct output |
---|
.................... .################### .################### .################### .################### ... |
user output |
---|
.................... .#########.......... .##################. .##################. .................... ... |
Test 8
Group: 2
Verdict: WRONG ANSWER
input |
---|
44 |
correct output |
---|
.................... .################..# .#################.. .#################.. .##################. ... |
user output |
---|
.................... .#########.......... .##################. .##################. .................... ... |
Test 9
Group: 2
Verdict: WRONG ANSWER
input |
---|
76 |
correct output |
---|
.................... .########..######..# .#########..######.. .#########...#####.. .##########...#####. ... |
user output |
---|
.................... .#########.......... .#########.......... .##################. .##################. ... |
Test 10
Group: 2
Verdict: ACCEPTED
input |
---|
93 |
correct output |
---|
.................... .########..##..##..# .#########..##..##.. .#########...#...#.. .##########...#...#. ... |
user output |
---|
.................... .#########.......... .#########.......... .##################. .##################. ... |
Test 11
Group: 3
Verdict: RUNTIME ERROR
input |
---|
141 |
correct output |
---|
.................... .################..# .#################.. .#################.. .##################. ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20 at Putka32.main(Putka32.java:92)
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
422 |
correct output |
---|
.................... .####..##########..# .#####..##########.. .#####...#########.. .######...#########. ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20 at Putka32.main(Putka32.java:86)
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
671 |
correct output |
---|
.................... .#.##########..##..# ....##########..##.. .#...#########...#.. .##...#########...#. ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20 at Putka32.main(Putka32.java:72)
Test 14
Group: 3
Verdict: RUNTIME ERROR
input |
---|
895 |
correct output |
---|
.................... .#.##..##..##..##..# ....##..##..##..##.. .#...#...#...#...#.. .##...#...#...#...#. ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20 at Putka32.main(Putka32.java:86)
Test 15
Group: 3
Verdict: RUNTIME ERROR
input |
---|
956 |
correct output |
---|
.................... .#.##..######..##..# ....##..######..##.. .#...#...#####...#.. .##...#...#####...#. ... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 20 at Putka32.main(Putka32.java:72)