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

Envío 5923

Problema 0xca - Contar cuantas veces aparece X en un subarreglo

  • Autor: bryancalisto
  • Fecha: 2022-03-29 01:04:47 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#2
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#3
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#4
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#5
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#6
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#7
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
#8
Error de compilación
                      main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
N = input()
^
main.c:1:5: warning: implicit declaration of function 'input' is invalid in C99 [-Wimplicit-function-declaration]
N = input()
    ^
main.c:1:5: error: initializer element is not a compile-time constant
N = input()
    ^~~~~~~
main.c:1:12: error: expected ';' after top level declarator
N = input()
           ^
           ;
2 warnings and 2 errors generated.

                    
Puntos totales: 0 / 100

Código

N = input()
arr = input().split(' ')
times = int(input())
mem = {}

for i, elem in enumerate(arr):
    if elem not in mem:
        mem[elem] = []
    mem[elem].append(i)

for i in range(times):
    case = input().split(' ')
    l = int(case[0])
    r = int(case[1])
    q = case[2]
    count = 0

    if q not in mem:
        print(0)
        continue

    indexes = mem[q]
    for index in indexes:
        if l <= index and r >= index:
            count += 1
    print(count)