Rezultati

Up. imeNalogaJezikRezultatČas oddaje
javanskivaljar-2018 Nič nas ne sme presenetiti! Java 0/100Napaka med izvajanjem / ob izhodu (RTE) 19. apr '18 @ 17:26

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 35,602 MiB 0,000 s OK
#2 12/12 83,488 MiB 1,306 s OK
#3 12/12 39,926 MiB 0,000 s OK
#4 0/12 160,180 MiB 0,000 s Prekoračen spomin
Stderr:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at NicNasNeSmePresenetiti.main(NicNasNeSmePresenetiti.java:14)
#5 13/13 39,668 MiB 0,000 s OK
#6 0/13 159,305 MiB 0,000 s Prekoračen spomin
Stderr:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at NicNasNeSmePresenetiti.main(NicNasNeSmePresenetiti.java:14)
#7 0/13 158,891 MiB 0,000 s Prekoračen spomin
Stderr:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at NicNasNeSmePresenetiti.main(NicNasNeSmePresenetiti.java:14)
#8 0/13 161,500 MiB 0,000 s Prekoračen spomin
Stderr:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at NicNasNeSmePresenetiti.main(NicNasNeSmePresenetiti.java:14)

Ocenjevani program (NicNasNeSmePresenetiti.java):
/**
 * Created by javanskivaljar-2018 on 4/19/18.
 */
import java.util.Scanner;
public class NicNasNeSmePresenetiti {
    public static int[][] Matrika;
    public static boolean[] VeljavnostiObiskov;
    public static boolean[] Obiskan;
    public static int Stevec;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        Matrika = new int[n][n];
        VeljavnostiObiskov = new boolean[n];
        Obiskan = new boolean[n];
        for(int i = 0; i<n - 1;i++){
            int a = sc.nextInt() -1;
            int b = sc.nextInt() - 1;
            Matrika[a][b] = 1;
            Matrika[b][a] = 1;
        }
        for(int i = 0; i<q;i++){
            int St = sc.nextInt();
            Stevec = St;
            int[] Mesta = new int[St];
            for(int k = 0; k<St;k++){
                Mesta[k] = sc.nextInt() - 1;
                VeljavnostiObiskov[Mesta[k]] = true;
            }
            boolean v = Rekurzija(Mesta[0], n);
            if(!v){
                System.out.println("ALAAAARHM");
            }
            else{
                System.out.println("NASLEDNJI");
            }

            for(int k =0; k<n;k++){
                VeljavnostiObiskov[k] = false;
            }
            for(int k =0; k<n;k++){
                Obiskan[k] = false;
            }

        }
    }
    public static boolean Rekurzija(int n, int stMest){
        Obiskan[n] = true;
        Stevec--;
        if(Stevec == 0){
            return false;
        }
        for(int i = 0; i<stMest;i++){
            if(Matrika[n][i] == 1 && VeljavnostiObiskov[i] == true && Obiskan[i] == false){
                if(!Rekurzija(i, stMest)){
                    return false;
                }
            }
        }
        return true;
    }
}