Task: | Brexit |
Sender: | Viljamin opetuslapset |
Submission time: | 2017-10-03 18:23:19 +0300 |
Language: | Java |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.12 s | details |
#2 | ACCEPTED | 0.13 s | details |
#3 | ACCEPTED | 0.12 s | details |
#4 | ACCEPTED | 0.11 s | details |
#5 | ACCEPTED | 0.11 s | details |
#6 | ACCEPTED | 0.11 s | details |
#7 | ACCEPTED | 0.12 s | details |
#8 | ACCEPTED | 0.12 s | details |
#9 | ACCEPTED | 0.13 s | details |
#10 | ACCEPTED | 0.10 s | details |
#11 | ACCEPTED | 0.12 s | details |
#12 | ACCEPTED | 0.11 s | details |
#13 | ACCEPTED | 0.11 s | details |
#14 | ACCEPTED | 0.12 s | details |
#15 | ACCEPTED | 0.19 s | details |
#16 | ACCEPTED | 0.13 s | details |
#17 | RUNTIME ERROR | 0.78 s | details |
#18 | RUNTIME ERROR | 0.79 s | details |
#19 | RUNTIME ERROR | 0.54 s | details |
#20 | RUNTIME ERROR | 0.52 s | details |
#21 | RUNTIME ERROR | 0.70 s | details |
#22 | RUNTIME ERROR | 0.55 s | details |
#23 | ACCEPTED | 0.23 s | details |
#24 | ACCEPTED | 0.48 s | details |
#25 | RUNTIME ERROR | 0.52 s | details |
#26 | RUNTIME ERROR | 0.55 s | details |
#27 | RUNTIME ERROR | 0.52 s | details |
#28 | RUNTIME ERROR | 0.54 s | details |
#29 | RUNTIME ERROR | 0.56 s | details |
#30 | RUNTIME ERROR | 0.53 s | details |
#31 | RUNTIME ERROR | 0.54 s | details |
#32 | RUNTIME ERROR | 0.54 s | details |
#33 | RUNTIME ERROR | 0.53 s | details |
#34 | RUNTIME ERROR | 0.51 s | details |
#35 | RUNTIME ERROR | 0.68 s | details |
Code
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Stack; /** * * @author juliuuus */ public class Main { static int valtioita; static int yhteyksia; static int koti; static int lahtija; static int[] alkupNaapuriMaara; static int[] naapureita; static boolean[] poistunut; static int[][] yhteydet; /** * @param args the command line arguments */ public static void main(String[] args) { // IO io = new IO(); // int solmujenMaara = io.nextInt(); // int yhteyksienMaara = io.nextInt(); // int kotimaa = io.nextInt(); // int lahtija = io.nextInt(); // HashMap<Integer, Solmu> solmut = new HashMap<>(); // // for (int i = 1; i <= solmujenMaara; i++) { // solmut.put(i, new Solmu(i)); // } // // for (int i = 0; i < yhteyksienMaara; i++) { // Solmu solmu1 = solmut.get(io.nextInt()); // Solmu solmu2 = solmut.get(io.nextInt()); // // solmu1.addNeighbor(solmu2); // solmu2.addNeighbor(solmu1); // // } // // solmut.get(kotimaa).setLahtija(true); // solmut.get(lahtija).poistu(); // // System.out.println(solmut.get(kotimaa).poistettu ? "leave" : "stay"); // // io.close(); IO io = new IO(); valtioita = io.nextInt(); yhteyksia = io.nextInt(); koti = io.nextInt(); lahtija = io.nextInt(); alkupNaapuriMaara = new int[valtioita + 1]; naapureita = new int[valtioita + 1]; poistunut = new boolean[valtioita + 1]; yhteydet = new int[valtioita + 1][valtioita + 1]; for (int i = 0; i < yhteyksia; i++) { int a = io.nextInt(); int b = io.nextInt(); yhteydet[a][b] = 1; yhteydet[b][a] = 1; alkupNaapuriMaara[a]++; alkupNaapuriMaara[b]++; naapureita[a]++; naapureita[b]++; } poistu(lahtija); if(poistunut[koti]) { io.println("leave"); } else { io.println("stay"); } io.close(); } public static void poistu(int lahtija) { poistunut[lahtija] = true; for (int i = 1; i <= valtioita; i++) { if (yhteydet[lahtija][i] == 1) { yhteydet[lahtija][i] = 0; naapureita[i]--; if ((1.0 * naapureita[i] / alkupNaapuriMaara[i]) <= 0.5) { if(i == koti) { poistunut[koti] = true; break; } poistu(i); } } } } } class Solmu { int origneighbours; List<Solmu> neighbours; boolean poistettu; int name; boolean target; // private int neigbours; public Solmu(int name) { this.name = name; neighbours = new ArrayList<>(); origneighbours = 0; poistettu = false; target = false; } public void addNeighbor(Solmu n) { neighbours.add(n); origneighbours++; } public boolean poistunko() { return (1.0 * neighbours.size() / origneighbours) <= 0.5; } public void poistu() { poistettu = true; if (target) { return; } for (Solmu s : neighbours) { if (s.poistettu) { continue; } // neighbours.remove(s); s.deleteNeighbor(this); } neighbours.clear(); } public void deleteNeighbor(Solmu n) { if (neighbours.contains(n)) { neighbours.remove(n); } if (poistunko()) { poistu(); } } public void setLahtija(boolean l) { target = l; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
4 4 4 1 1 2 1 3 2 3 3 4 |
correct output |
---|
leave |
user output |
---|
leave |
Test 2
Verdict: ACCEPTED
input |
---|
8 11 4 7 1 4 1 6 4 6 1 8 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 3
Verdict: ACCEPTED
input |
---|
8 8 8 1 1 2 1 3 2 4 3 5 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 4
Verdict: ACCEPTED
input |
---|
7 8 7 1 1 2 1 3 1 7 2 4 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 5
Verdict: ACCEPTED
input |
---|
8 10 5 1 1 2 1 3 1 7 2 4 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 6
Verdict: ACCEPTED
input |
---|
14 36 11 1 1 2 1 3 1 4 1 5 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 7
Verdict: ACCEPTED
input |
---|
14 35 11 1 1 2 1 3 1 4 1 5 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 8
Verdict: ACCEPTED
input |
---|
17 30 8 11 1 2 2 3 3 4 4 5 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 9
Verdict: ACCEPTED
input |
---|
4 2 3 1 1 3 2 4 |
correct output |
---|
leave |
user output |
---|
leave |
Test 10
Verdict: ACCEPTED
input |
---|
4 2 2 4 1 4 2 3 |
correct output |
---|
stay |
user output |
---|
stay |
Test 11
Verdict: ACCEPTED
input |
---|
20 19 6 17 1 19 8 9 16 18 4 5 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 12
Verdict: ACCEPTED
input |
---|
2 1 2 1 1 2 |
correct output |
---|
leave |
user output |
---|
leave |
Test 13
Verdict: ACCEPTED
input |
---|
2 1 1 1 1 2 |
correct output |
---|
leave |
user output |
---|
leave |
Test 14
Verdict: ACCEPTED
input |
---|
8 9 8 1 1 2 1 3 1 4 2 5 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 15
Verdict: ACCEPTED
input |
---|
2297 2679 1051 742 617 742 694 1379 156 742 36 531 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 16
Verdict: ACCEPTED
input |
---|
9 36 3 3 1 2 1 3 1 4 1 5 ... |
correct output |
---|
leave |
user output |
---|
leave |
Test 17
Verdict: RUNTIME ERROR
input |
---|
150670 300000 64138 127023 50117 131948 138058 140437 80088 113710 1091 149845 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 18
Verdict: RUNTIME ERROR
input |
---|
75351 299756 67121 54519 13237 54519 21423 29557 45590 57906 27901 54519 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 19
Verdict: RUNTIME ERROR
input |
---|
75351 299755 66319 71133 70626 71133 9534 30979 52767 59421 3512 62528 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 20
Verdict: RUNTIME ERROR
input |
---|
100000 100000 1 100000 1 2 2 3 3 4 4 5 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 21
Verdict: RUNTIME ERROR
input |
---|
100000 99999 1 100000 1 2 1 3 1 4 1 5 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 22
Verdict: RUNTIME ERROR
input |
---|
100000 99999 100000 1 1 2 1 3 1 4 1 5 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 23
Verdict: ACCEPTED
input |
---|
623 100000 201 369 1 2 2 3 1 3 2 4 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 24
Verdict: ACCEPTED
input |
---|
10007 100000 8980 3955 1 2 2 3 3 4 4 5 ... |
correct output |
---|
stay |
user output |
---|
stay |
Test 25
Verdict: RUNTIME ERROR
input |
---|
200000 300000 98405 200000 91091 107131 187868 200000 169168 200000 107283 200000 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 26
Verdict: RUNTIME ERROR
input |
---|
200000 200003 36335 152343 118063 160421 103074 184863 39554 133784 111165 151835 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 27
Verdict: RUNTIME ERROR
input |
---|
200000 200003 36335 152343 118063 160421 103074 184863 39554 133784 111165 151835 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 28
Verdict: RUNTIME ERROR
input |
---|
200000 199995 48807 188921 125668 137213 58484 92270 149853 172371 147281 183987 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 29
Verdict: RUNTIME ERROR
input |
---|
150003 300000 5769 81807 1701 81807 67930 81807 95197 101956 8464 95197 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 30
Verdict: RUNTIME ERROR
input |
---|
150003 300000 113708 52542 20542 140674 113708 118110 53131 140674 106124 140674 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 31
Verdict: RUNTIME ERROR
input |
---|
150002 299998 108658 134482 7967 120234 7967 69327 4545 7967 48480 134482 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 32
Verdict: RUNTIME ERROR
input |
---|
150002 299998 111144 48353 29987 48353 48353 80095 75893 89146 88333 111144 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 33
Verdict: RUNTIME ERROR
input |
---|
199999 299996 111739 12359 173419 189883 35930 189883 72825 189883 175798 189883 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 34
Verdict: RUNTIME ERROR
input |
---|
200000 299997 24068 147603 15273 189931 57932 189931 147603 188966 36101 147603 ... |
correct output |
---|
stay |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)
Test 35
Verdict: RUNTIME ERROR
input |
---|
200000 199999 182498 116219 59555 62379 33156 181870 103953 174756 101778 110925 ... |
correct output |
---|
leave |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Main.main(Main.java:67)