Rezultati

Up. imeNalogaJezikRezultatČas oddaje
hl3-2018 Zaletavanje Java 0/100Prekoračen čas (TLE) 19. apr '18 @ 20:14

Test Točke Porabljen spomin Porabljen čas Status
#1 14/14 34,676 MiB 0,000 s OK
#2 14/14 32,711 MiB 0,000 s OK
#3 14/14 34,504 MiB 0,000 s OK
#4 14/14 30,930 MiB 0,000 s OK
#5 14/14 41,082 MiB 0,000 s OK
#6 0/15 36,434 MiB 5,617 s Prekoračen čas
#7 0/15 9,477 MiB 5,690 s Prekoračen čas

Ocenjevani program (Main.java):
//package com.company;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long W = sc.nextLong();
        long H = sc.nextLong();
        sc.nextLine();

        long tempC;
        long [][] carPos = new long[n][3];
        String m;
        for(int i = 0; i < n; i++){
            m = sc.next();
            carPos[i][0] = sc.nextLong();
            carPos[i][1] = sc.nextLong();
            if(m.equals("G")){ //     GOR = G = 1    DESNO = D = 0
                carPos[i][2] = 1;
            }else{
                carPos[i][2] = 0;
            }
        }
        sc.close();

        int stAvtov = n;
        long premiki[][] = new long[n][3];
        int premikiN;
        int tempIdx;
        while(stAvtov > 0){
            premikiN=0;
            for(int i = 0; i < n; i++){
                if(carPos[i][2] == -1){
                    continue;
                }else if(carPos[i][2] == 0){
                    carPos[i][0]++;
                }else if(carPos[i][2] == 1){
                    carPos[i][1]++;
                }
                if(carPos[i][0] > W || carPos[i][1] > H) {
                    carPos[i][0] = Math.min(carPos[i][0], W);
                    carPos[i][1] = Math.min(carPos[i][1], H);
                    carPos[i][2] = -1;
                    stAvtov--;
                    continue;
                }
                for(int itrp = 0; itrp < premikiN;itrp++){
                    if(premiki[itrp][1] == carPos[i][0] && premiki[itrp][2] == carPos[i][1]){
                        tempIdx = (int)premiki[itrp][0];
                        carPos[tempIdx][2] = carPos[i][2];
                        carPos[i][2] = 1 - carPos[i][2];
                    }
                }
                premiki[premikiN][0] = i;
                premiki[premikiN][1] = carPos[i][0];
                premiki[premikiN][2] = carPos[i][1];
                premikiN++;
            }
        }

        for(int i = 0; i < n; i++){
            System.out.printf("%d %d\n", carPos[i][0], carPos[i][1]);
        }
    }
}