Rezultati

Up. imeNalogaJezikRezultatČas oddaje
veseleveverce-2018 Zaletavanje Java 0/100Napaka med izvajanjem / ob izhodu (RTE) 19. apr '18 @ 19:42

Test Točke Porabljen spomin Porabljen čas Status
#1 0/14 35,980 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#2 0/14 37,148 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#3 0/14 35,859 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#4 0/14 31,566 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#5 0/14 37,785 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#6 0/15 31,301 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)
#7 0/15 37,395 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at arejPointerjeu.main(arejPointerjeu.java:16)

Ocenjevani program (arejPointerjeu.java):
import java.util.*;

/**
 * Created by veseleveverce-2018 on 4/19/18.
 */
public class arejPointerjeu {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int h = sc.nextInt();
        List<Avto> vsi = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String[] x = sc.nextLine().split(" ");
            boolean gor = x[0].equals("G");
            int a = Integer.parseInt(x[1]);
            int b = Integer.parseInt(x[2]);
            vsi.add(new Avto(gor, a, b, w, h));
        }
        Map<String, Integer> ares = new HashMap<>();
        while (vsi.size() > 0) {
            for (Avto a : vsi) {
                a.premik();
            }
            for (Avto a : vsi) {
                for (Avto b : vsi) {
                    if (a.equals(b))
                        continue;
                    if (!(ares.containsKey(a.toString() + b.toString()) || ares.containsKey(b.toString() + a.toString())))
                        if (a.zaletel(b)) {
                            a.setGor();
                            b.setGor();
                            ares.put(a.toString() + b.toString(), 0);
                        }

                }
            }
            ares.clear();
            List<Avto> burek = vsi;
            for (Avto a : burek) {
                if(a.stena())
                    vsi.remove(a);
            }
        }
    }
}

class Avto {
    int x, y, w, h;
    boolean gor;//gor = true, desno = false

    public Avto(boolean gor, int x, int y, int w, int h) {
        this.gor = gor;
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }

    public boolean zaletel(Avto a) {
        return this.x == a.x && this.y == a.y;
    }

    public void setGor() {
        gor = !gor;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void premik() {
        if (gor)
            setY(this.y + 1);
        else
            setX(this.x + 1);
    }

    public boolean stena() {
        if (this.x >= this.w && !this.gor || this.y >= this.h && this.gor) {
            System.out.println(this.x + " " + this.y);
            return true;
        }
        return false;
    }
}