Rezultati

Up. imeNalogaJezikRezultatČas oddaje
kkrsnik Pasavci Java 0/100Napaka med izvajanjem / ob izhodu (RTE) 11. maj '17 @ 18:11

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 36,934 MiB 0,000 s OK
#2 5/5 40,520 MiB 0,000 s OK
#3 5/5 46,762 MiB 0,000 s OK
#4 5/5 73,816 MiB 0,193 s OK
#5 5/5 47,285 MiB 0,101 s OK
#6 5/5 75,648 MiB 0,361 s OK
#7 5/5 72,055 MiB 0,509 s OK
#8 5/5 76,242 MiB 0,469 s OK
#9 6/6 66,602 MiB 0,390 s OK
#10 0/6 164,176 MiB 1,319 s Prekoračen spomin
Stderr:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOfRange(Arrays.java:3664)
	at java.lang.String.<init>(String.java:207)
	at java.lang.StringBuilder.toString(StringBuilder.java:407)
	at Naloga4.gen(Naloga4.java:43)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
	at Naloga4.gen(Naloga4.java:35)
#11 6/6 36,559 MiB 0,000 s OK
#12 6/6 34,703 MiB 0,000 s OK
#13 6/6 31,629 MiB 0,000 s OK
#14 6/6 35,848 MiB 0,000 s OK
#15 6/6 72,625 MiB 0,162 s OK
#16 6/6 37,820 MiB 0,000 s OK
#17 6/6 32,852 MiB 0,000 s OK
#18 6/6 45,496 MiB 0,106 s OK

Ocenjevani program (Naloga4.java):
import java.util.Scanner;

public class Naloga4 {
    static String[] geni;
    static int[][] pari;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String iskano=sc.next();
        String a=sc.next();
        String b=sc.next();
        int n=sc.nextInt();
        geni=new String[2+n];
        pari=new int[2+n][2];
        geni[0]=a;
        geni[1]=b;
        for (int i = 0; i < n; i++) {
            pari[i+2][0]=sc.nextInt()-1;
            pari[i+2][1]=sc.nextInt()-1;
        }
        String konec=gen(pari[n+1][0],pari[n+1][1]);
        int odg=0;
        for (int i = 0; i < konec.length() - iskano.length()+1; i++) {
            if(konec.substring(i,i+iskano.length()).equals(iskano))
                odg++;
        }
        System.out.println(odg);
    }
    static String gen(int a, int b){
        String aS;
        String bS;
        if (geni[a]!=null){
            aS=geni[a];
        }
        else{
            aS=gen(pari[a][0],pari[a][1]);
        }
        if (geni[b]!=null){
            bS=geni[b];
        }
        else{
            bS=gen(pari[b][0],pari[b][1]);
        }
        return aS+bS;
    }
}