█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 6256

Problema 0x53 - Encontrar ciclos en un grafo dirigido

  • Autor: rpedrazacoello
  • Fecha: 2022-05-28 04:19:47 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#9
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#10
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#11
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#12
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#13
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#14
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#15
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#16
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#17
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#18
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#19
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#20
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#21
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#22
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#23
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#24
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#25
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#26
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#27
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#28
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#29
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#30
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#31
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#32
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#33
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#34
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
#35
Error de compilación
                      main.c:1:1: error: unknown type name 'import'
import java.util.ArrayList;
^
main.c:1:12: error: expected ';' after top level declarator
import java.util.ArrayList;
           ^
           ;
main.c:2:1: error: unknown type name 'import'
import java.util.HashMap;
^
main.c:2:12: error: expected ';' after top level declarator
import java.util.HashMap;
           ^
           ;
main.c:3:1: error: unknown type name 'import'
import java.util.Scanner;
^
main.c:3:12: error: expected ';' after top level declarator
import java.util.Scanner;
           ^
           ;
main.c:5:1: error: unknown type name 'public'
public class Main {
^
main.c:5:13: error: expected ';' after top level declarator
public class Main {
            ^
            ;
8 errors generated.

                    
Puntos totales: 0 / 100

Código

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    private static HashMap<Integer, ArrayList<Integer>> directedRelations = new HashMap<>();
    private static HashMap<Integer, Boolean> unprocessedNodes = new HashMap<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        for(int i=0; i<m; i++){
            int from = scanner.nextInt();
            int to = scanner.nextInt();

            unprocessedNodes.put(from, true);

            if(directedRelations.containsKey(from)){
                directedRelations.get(from).add(to);
            } else {
                ArrayList<Integer> arrayList = new ArrayList<Integer>();
                arrayList.add(to);
                directedRelations.put(from,arrayList);
            }
        }

        while (!unprocessedNodes.isEmpty()){
            int node = (int) unprocessedNodes.keySet().toArray()[0];
            if(findCycle(node, new HashMap<Integer, Boolean>())){
                System.out.println("Yes");
                break;
            }
        }

        if(unprocessedNodes.isEmpty()){
            System.out.println("No");
        }
    }

    /**
     * True if find cycle, false otherwise
     * @param node
     * @param recursionNode
     * @return
     */
    private static boolean findCycle (int node, HashMap<Integer, Boolean> recursionNode){
        if(directedRelations.containsKey(node)) {
            if(!recursionNode.containsKey(node)) {
                recursionNode.put(node, true);
            } else {
                return true;
            }

            if(!unprocessedNodes.containsKey(node)){
                return false;
            }

            for (int relation : directedRelations.get(node)) {
                if (findCycle(relation, recursionNode)){
                    return true;
                }
            }


            recursionNode.remove(node);
        }

        if(unprocessedNodes.containsKey(node)){
            unprocessedNodes.remove(node);
        }
        return false;
    }
}