| Task: | Alitaulukot |
| Sender: | anton7r |
| Submission time: | 2020-10-11 10:27:22 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | RUNTIME ERROR | 0.08 s | 1, 2, 3 | details |
| #2 | RUNTIME ERROR | 0.08 s | 1, 2, 3 | details |
| #3 | RUNTIME ERROR | 0.08 s | 1, 2, 3 | details |
| #4 | RUNTIME ERROR | 0.08 s | 1, 2, 3 | details |
| #5 | RUNTIME ERROR | 0.08 s | 1, 2, 3 | details |
| #6 | RUNTIME ERROR | 0.08 s | 2, 3 | details |
| #7 | RUNTIME ERROR | 0.08 s | 2, 3 | details |
| #8 | RUNTIME ERROR | 0.08 s | 2, 3 | details |
| #9 | RUNTIME ERROR | 0.08 s | 2, 3 | details |
| #10 | RUNTIME ERROR | 0.08 s | 2, 3 | details |
| #11 | RUNTIME ERROR | 0.08 s | 3 | details |
| #12 | RUNTIME ERROR | 0.08 s | 3 | details |
| #13 | RUNTIME ERROR | 0.08 s | 3 | details |
| #14 | RUNTIME ERROR | 0.08 s | 3 | details |
| #15 | RUNTIME ERROR | 0.08 s | 3 | details |
| #16 | RUNTIME ERROR | 0.08 s | 3 | details |
| #17 | RUNTIME ERROR | 0.08 s | 3 | details |
Code
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {
static class Pos {
public int x;
public int y;
public Pos(int x, int y) {
this.x = x;
this.y = y;
}
public boolean notNull() {
return this.x == -1;
}
public Pos relativePos(int moveX, int moveY) {
Pos newPos = new Pos(x + moveX, y + moveY);
if(newPos.x < 0) {
newPos.x += 5;
} else newPos.x = newPos.x % 5;
if(newPos.y < 0) {
newPos.y += 5;
} else newPos.y = newPos.y % 5;
//System.out.println(newPos.x + " " + newPos.y);
return newPos;
}
}
static class CoordMap {
private final int[][] map;
public CoordMap(String[] syote) {
this.map = new int[5][5];
for (int y = 0; y < 5; y++) {
String[] xPositions = syote[y].split("");
for (int x = 0; x < 5; x++) {
String nyk = xPositions[x];
int nykInt;
if(nyk.equals(".")) {
nykInt = 0;
} else {
nykInt = Integer.parseInt(nyk);
}
map[x][y] = nykInt;
}
}
}
public int etsi(Pos pos){
return this.map[pos.x][pos.y];
}
public int etsi(Pos pos, int moveX, int moveY) {
return etsi(pos.relativePos(moveX, moveY));
}
public Pos getPos(int targetInt) {
Pos pos = null;
for (int x = 0; x < map.length; x++) {
int[] yMap = map[x];
for (int y = 0; y < yMap.length; y++) {
if(yMap[y] == targetInt) {
pos = new Pos(x, y);
}
}
}
return pos != null ? pos : new Pos(-1,-1);
}
}
static class ArpaKuutio {
//TODO: TEE YLÄ, VASEN, ALA, OIKEA taulukko
//TODO: eli YLÄ olisi 0, VASEN olisi 1, ALA olisi 2 ja OIKEA olisi 3
public Pos n1;
public int yla;
public int ala;
public int vasen;
public int oikea;
public ArpaKuutio(String[] syote) {
CoordMap kuutio = new CoordMap(syote);
n1 = kuutio.getPos(1);
Pos ylaPos = n1.relativePos(0, -1);
yla = kuutio.etsi(ylaPos);
ala = kuutio.etsi(n1, 0, 1);
vasen = kuutio.etsi(n1, -1, 0);
oikea = kuutio.etsi(n1, 1, 0);
//if (yla != 0) {
// int numero = yla;
// while (numero != 0) {
//
// }
//}
//TODO: FIX ALGO
if(yla == 0) {
int vaihtoEhto1 = kuutio.etsi(n1, 0, 3);
int vaihtoEhto2 = kuutio.etsi(n1, -2, 1);
int vaihtoEhto3 = kuutio.etsi(n1, 2, 1);
int vaihtoEhto4 = kuutio.etsi(n1, -2, -1);
int vaihtoEhto5 = kuutio.etsi(n1, 2, -1);
if(vaihtoEhto1 != 0) {
yla = vaihtoEhto1;
} else if (vaihtoEhto2 != 0) {
yla = vaihtoEhto2;
} else if (vaihtoEhto3 != 0) {
yla = vaihtoEhto3;
} else if (vaihtoEhto4 != 0) {
yla = vaihtoEhto4;
} else if (vaihtoEhto5 != 0) {
yla = vaihtoEhto5;
}
}
if(ala == 0) {
int vaihtoEhto1 = kuutio.etsi(n1,0, -3);
int vaihtoEhto2 = kuutio.etsi(n1, -2, -1);
int vaihtoEhto3 = kuutio.etsi(n1, 2, -1);
int vaihtoEhto4 = kuutio.etsi(n1, -2, 1);
int vaihtoEhto5 = kuutio.etsi(n1, 2, 1);
if(vaihtoEhto1 != 0) {
ala = vaihtoEhto1;
} else if (vaihtoEhto2 != 0) {
ala = vaihtoEhto2;
} else if (vaihtoEhto3 != 0) {
ala = vaihtoEhto3;
} else if (vaihtoEhto4 != 0) {
ala = vaihtoEhto4;
} else if (vaihtoEhto5 != 0) {
ala = vaihtoEhto5;
}
}
if(oikea == 0) {
int vaihtoEhto1 = kuutio.etsi(n1, 1,-1);
int vaihtoEhto2 = kuutio.etsi(n1, 1, 1);
int vaihtoEhto3 = kuutio.etsi(n1, 1,-2);
int vaihtoEhto4 = kuutio.etsi(n1, 1, 2);
int vaihtoEhto5 = kuutio.etsi(n1, 2, 0);
if(vaihtoEhto1 != 0) {
oikea = vaihtoEhto1;
} else if (vaihtoEhto2 != 0) {
oikea = vaihtoEhto2;
} else if (vaihtoEhto3 != 0) {
oikea = vaihtoEhto3;
} else if (vaihtoEhto4 != 0) {
oikea = vaihtoEhto4;
} else if (vaihtoEhto5 != 0) {
oikea = vaihtoEhto5;
}
}
if(vasen == 0) {
int vaihtoEhto1 = kuutio.etsi(n1, -1,-1);
int vaihtoEhto2 = kuutio.etsi(n1, -1, 1);
int vaihtoEhto3 = kuutio.etsi(n1, -1,-2);
int vaihtoEhto4 = kuutio.etsi(n1, -1, 2);
int vaihtoEhto5 = kuutio.etsi(n1, -2, 0);
if(vaihtoEhto1 != 0) {
vasen = vaihtoEhto1;
} else if (vaihtoEhto2 != 0) {
vasen = vaihtoEhto2;
} else if (vaihtoEhto3 != 0) {
vasen = vaihtoEhto3;
} else if (vaihtoEhto4 != 0) {
vasen = vaihtoEhto4;
} else if (vaihtoEhto5 != 0) {
vasen = vaihtoEhto5;
}
}
//this.print();
}
public void print() {
System.out.println(". " + yla + " .");
System.out.println(vasen + " " + 1 + " " + oikea);
System.out.println(". " + ala + " .");
System.out.println("");
}
public boolean compare(ArpaKuutio tKuutio) {
int summa = this.summa();
int tSumma = tKuutio.summa();
if(summa == tSumma) {
Integer[] lista = this.lista();
Integer[] tLista = tKuutio.lista();
int eka = lista[0];
int ero = -1;
for (int i = 0; i < tLista.length ; i++) {
if(tLista[i] == eka) {
ero = i;
break;
}
}
if(ero == -1) {
return false;
} else if (ero != 0) {
Integer[] tListaJarjestetty = new Integer[4];
for (int i = 0; i < 4; i++) {
int eronTasaus = (i + ero) % 4;
tListaJarjestetty[i] = tLista[eronTasaus];
}
return Arrays.equals(tListaJarjestetty, lista);
}
return true;
}
return false;
}
private int summa() {
return this.yla + this.ala + this.vasen + this.oikea;
}
private Integer[] lista() {
Integer[] lista = new Integer[4];
lista[0] = this.yla;
lista[1] = this.vasen;
lista[2] = this.ala;
lista[3] = this.oikea;
return lista;
}
}
// n1 on aina yksi, sillä se on ensimmäinen numero
// ja meidän tarvitsee tietää vain 5 nopan puolta, jotta pystytään vertaamaan noppia keskenään
//kuutiota ensin voisi verrata siten, että niiden summa on sama
// yla
// vasen n1 oikea
// ala
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int kuutioidenMaara = Integer.parseInt(br.readLine().trim());
ArpaKuutio[] kuutiot = new ArpaKuutio[kuutioidenMaara];
for (int i = 0; i < kuutioidenMaara; i++) {
String[] kuutio = new String[5];
for (int j = 0; j < 5; j++) {
kuutio[j] = br.readLine().trim();
}
if(i != kuutioidenMaara - 1) {
br.readLine();
}
kuutiot[i] = new ArpaKuutio(kuutio);
}
for (int i = 0; i < kuutioidenMaara; i++) {
ArpaKuutio kuutio = kuutiot[i];
ArrayList<Integer> samatKuutiot = new ArrayList<>();
for (int j = 0; j < kuutioidenMaara; j++) {
if(i!=j) {
ArpaKuutio vertaus = kuutiot[j];
if(kuutio.compare(vertaus)) {
samatKuutiot.add(j+1);
}
}
}
if(samatKuutiot.isEmpty()) {
System.out.println("-");
} else {
for (int j = 0; j < samatKuutiot.size(); j++) {
if(j != 0) {
System.out.print(" ");
}
System.out.print(samatKuutiot.get(j));
}
System.out.println();
}
}
}
}
Test details
Test 1
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 5050 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100 0" at...
Test 2
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 2 5 5 2 4 3 5 3 4 3 2 3 4 5 4 4 ... |
| correct output |
|---|
| 317 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100 2" at...
Test 3
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 10 71 60 61 96 25 10 10 9 84 85 1... |
| correct output |
|---|
| 119 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100 10" at...
Test 4
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 990000000 111122929 961821360 578238211 ... |
| correct output |
|---|
| 4006 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100 9900000...
Test 5
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100 1000000000 553190572 453407680 667300705 ... |
| correct output |
|---|
| 5050 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100 1000000...
Test 6
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2000 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 2001000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2000 0" at...
Test 7
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2000 2 4 4 1 4 2 3 1 2 1 3 5 2 2 4 4 ... |
| correct output |
|---|
| 6340 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2000 2" at...
Test 8
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2000 10 65 88 33 88 41 10 17 38 22 3 8... |
| correct output |
|---|
| 2413 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2000 10" a...
Test 9
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2000 999000000 746120950 772769620 721488968 ... |
| correct output |
|---|
| 1287776 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2000 999000...
Test 10
Group: 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 2000 1000000000 621947980 510355354 756705418 ... |
| correct output |
|---|
| 2001000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2000 100000...
Test 11
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 5000050000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 0"...
Test 12
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 2 3 3 1 3 3 1 1 5 1 2 5 4 1 3 1 ... |
| correct output |
|---|
| 317066 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 2"...
Test 13
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 10 10 3 6 3 43 60 5 48 15 27 86 4... |
| correct output |
|---|
| 123292 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 10"...
Test 14
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 999990000 460235639 963048588 47270983 3... |
| correct output |
|---|
| 4946886742 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 9999...
Test 15
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 1000000000 885457070 18257718 927615960 3... |
| correct output |
|---|
| 5000050000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 1000...
Test 16
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 50000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 3750075000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 5000...
Test 17
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 100000 50000 100000 99999 99998 99997 99996... |
| correct output |
|---|
| 3750075000 |
| user output |
|---|
| (empty) |
Error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "100000 5000...
