New Judge Online: Acepta el reto!

Post about everything you want - even if it is not related to programming or this site.

Moderator: Board moderators

Post Reply
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

Hi everybody!
There's a new web where find easy problems to solve: http://www.aceptaelreto.com.
It's a spanish web for FP and university students.
I have problems like TLE and MLE in problems 146, 179, 183 and 209. Someone could help me?
Thanks in advance. :wink:
Last edited by MPC1984 on Sat Aug 13, 2016 3:15 pm, edited 5 times in total.
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

PROBLEM 146 Lucky Numbers

Code: Select all

AC
Last edited by MPC1984 on Sat Aug 13, 2016 3:15 pm, edited 6 times in total.
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

PROBLEM 179 Windmills

Code: Select all

AC
Last edited by MPC1984 on Sat Aug 13, 2016 3:15 pm, edited 6 times in total.
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

PROBLEM 183 Annelids

Code: Select all

AC
Last edited by MPC1984 on Sat Aug 13, 2016 3:15 pm, edited 6 times in total.
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

PROBLEM 209 Daylight

Code: Select all

AC
Last edited by MPC1984 on Sat Aug 13, 2016 3:16 pm, edited 5 times in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: www.aceptaelreto.com

Post by brianfry713 »

Try using BufferedWriter
Check input and AC output for thousands of problems on uDebug!
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

Thanks for your answer brianfry713, but I've tried PROBLEM 146 with BufferedOutputStream and still TLE.

The changes are there:

Code: Select all

AC
Last edited by MPC1984 on Sat Aug 13, 2016 3:16 pm, edited 5 times in total.
googol
New poster
Posts: 2
Joined: Wed Jun 25, 2014 10:56 pm

Re: www.aceptaelreto.com

Post by googol »

What about Stack.remove()? You are continuosly removing intermediate elements in a vector and that is not particularly efficient because all the elements in the right side of the removed element must be moved.

This seems a Josephus problem variant, and they are usually solved using a queue where add/remove operations are supposed to be fast enough.
MPC1984
New poster
Posts: 40
Joined: Mon Jul 01, 2013 9:24 pm
Location: Valladolid, Spain

New Judge Online: Acepta el reto!

Post by MPC1984 »

Hi again everybody!!!
I have seen that people from that online judge try to solve problems from Acepta el reto!.
Could anyone of you help me with the following problems?

PROBLEM 230: TLE

Code: Select all

#include <stdio.h>

int i, j, numHabitantes, contador;
long diasVividos [100000];

int main(void) {
	scanf("%d", &numHabitantes);
	while(numHabitantes > 0) {
		contador = 0;
		for(i = 0; i < numHabitantes; i++) {
			scanf("%d", &diasVividos[i]);
		}
		for(i = 0; i < numHabitantes - 1; i++) {
			for(j = i + 1; j < numHabitantes; j++) {
				if(diasVividos[i] > diasVividos[j]) {
					contador++;
				}
			}
		}
		printf("%d\n", contador);
		scanf("%d", &numHabitantes);
	} 
	return 0;
}
PROBLEM 257: WA

Code: Select all

#include <stdio.h>
#include <stdlib.h>

int i, j, numCasosPrueba, numPuntosControl, x, y, x1, y1, x2, y2, tiempo, parcial1, parcial2;

int main(void) {
	scanf("%d", &numCasosPrueba);
	for(i = 0; i < numCasosPrueba; i++) {
		scanf("%d", &numPuntosControl);
		scanf("%d", &x1);
		scanf("%d", &y1);
		tiempo = x1 + y1;
		x2 = 0;
		y2 = 0;
		for(j = 0; j < numPuntosControl - 1; j++) {
			scanf("%d", &x);
			scanf("%d", &y);
			parcial1 = abs(x - x1) + abs(y - y1);
			parcial2 = abs(x - x2) + abs(y - y2);
			if(parcial1 < parcial2) {
				tiempo = tiempo + parcial1;
				x1 = x;
				y1 = y;
			} else {
				tiempo = tiempo + parcial2;
				x2 = x;
				y2 = y;
			}
		}
		printf("%d\n", tiempo);
	}
	return 0;
}
PROBLEM 261: WA

Code: Select all

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader entrada = new BufferedReader(new InputStreamReader(System.in));
        BufferedOutputStream salida = new BufferedOutputStream(System.out);
        int i, suma, caraDado;
        String[] datos;
        int numCasosPrueba = Integer.parseInt(entrada.readLine());
        for (i = 0; i < numCasosPrueba; i++) {
            datos = entrada.readLine().split(" ");
            suma = Integer.parseInt(datos[0]);
            caraDado = Integer.parseInt(datos[1]);
            if (suma == 1000) {
                salida.write("PIERDE\n".getBytes());
            } else if (suma == 999) {
                salida.write("GANA\n".getBytes());
            } else if (suma == 998) {
                if (caraDado == 1 || caraDado == 6) {
                    salida.write("GANA\n".getBytes());
                } else {
                    salida.write("PIERDE\n".getBytes());
                }
            } else if (suma == 997) {
                salida.write("PIERDE\n".getBytes());
            } else {
                if (suma % 9 == 0) {
                    if (caraDado == 3 || caraDado == 4) {
                        salida.write("GANA\n".getBytes());
                    } else {
                        salida.write("PIERDE\n".getBytes());
                    }
                } else if (suma % 9 == 1) {
                    if (caraDado == 3 || caraDado == 4) {
                        salida.write("GANA\n".getBytes());
                    } else {
                        salida.write("PIERDE\n".getBytes());
                    }
                } else if (suma % 9 == 2) {
                    salida.write("PIERDE\n".getBytes());
                } else if (suma % 9 == 3) {
                    salida.write("PIERDE\n".getBytes());
                } else if (suma % 9 == 4) {
                    salida.write("GANA\n".getBytes());
                } else if (suma % 9 == 5) {
                    if (caraDado == 3 || caraDado == 4) {
                        salida.write("GANA\n".getBytes());
                    } else {
                        salida.write("PIERDE\n".getBytes());
                    }
                } else if (suma % 9 == 6) {
                    salida.write("PIERDE\n".getBytes());
                } else if (suma % 9 == 7) {
                    salida.write("PIERDE\n".getBytes());
                } else if (suma % 9 == 8) {
                    if (caraDado == 2 || caraDado == 5) {
                        salida.write("GANA\n".getBytes());
                    } else {
                        salida.write("PIERDE\n".getBytes());
                    }
                }

            }
        }
        salida.flush();
        salida.close();
    }
}
PROBLEM 343: TLE

Code: Select all

#include <stdio.h>
#include <string.h>

int i, j, k, l, tamanhoHorizontalMesa, tamanhoVerticalMesa, tamanhoHorizontalMatamoscas, tamanhoVerticalMatamoscas, moscasMuertas;
char moscasMesa [1000][1000];
int posiciones [8];

int main(void) {
	scanf("%d", &tamanhoHorizontalMesa);
	scanf("%d", &tamanhoVerticalMesa);
	scanf("%d", &tamanhoHorizontalMatamoscas);
	scanf("%d", &tamanhoVerticalMatamoscas);
	while (tamanhoHorizontalMesa != 0 || tamanhoVerticalMesa != 0 || tamanhoHorizontalMatamoscas != 0 || tamanhoVerticalMatamoscas != 0) {
		for (i = 0; i < tamanhoVerticalMesa; i++) {
			scanf("%s", moscasMesa[i]);
		}
		for (i = 0; i <= tamanhoVerticalMesa - tamanhoVerticalMatamoscas; i++) {
			for (j = 0; j <= tamanhoHorizontalMesa - tamanhoHorizontalMatamoscas; j++) {
				moscasMuertas = 0;
				for (k = 0; k < tamanhoVerticalMatamoscas; k++) {
					for (l = 0; l < tamanhoHorizontalMatamoscas; l++) {
						if(moscasMesa[i + k][j + l] == 'X') {
							moscasMuertas++;
							if (moscasMuertas > 7) {
								break;
							}
						}
					}
				}
				posiciones[moscasMuertas]++;
			}
		}
		printf("%d", posiciones[0]);
		posiciones[0] = 0;
		for (i = 1; i < 8; i++) {
			printf(" %d", posiciones[i]);
			posiciones[i] = 0;
		}
		printf("\n");
		scanf("%d", &tamanhoHorizontalMesa);
		scanf("%d", &tamanhoVerticalMesa);
		scanf("%d", &tamanhoHorizontalMatamoscas);
		scanf("%d", &tamanhoVerticalMatamoscas);
	}
	return 0;
}
Thank you in advance. :wink:
Post Reply

Return to “Off topic (General chit-chat)”