feat(DP): new problem formated

This commit is contained in:
2025-11-06 12:10:53 -03:00
parent e4a9cd474f
commit b8431dffe4
226 changed files with 6912 additions and 0 deletions

97
analise-de-dados/Makefile Normal file
View File

@@ -0,0 +1,97 @@
# Normal directories
SRC_DIR := src
BIN_DIR := bin
DBG_DIR := bin/debug
# Grader directories
GRADER := $(wildcard $(SRC_DIR)/grader.cpp)
GRADER_DIR := $(SRC_DIR)/grader
HANDLER_DIR := $(SRC_DIR)/handler
GRADER_SRC := $(wildcard $(GRADER_DIR)/*.cpp)
GRADER_BIN := $(patsubst $(GRADER_DIR)/%.cpp, $(BIN_DIR)/%, $(GRADER_SRC))
GRADER_DBG := $(patsubst $(GRADER_DIR)/%.cpp, $(DBG_DIR)/%, $(GRADER_SRC))
# Change CPP source directories if grader is defined
ifdef GRADER
SRC := $(wildcard $(HANDLER_DIR)/*.cpp)
BIN := $(patsubst $(HANDLER_DIR)/%.cpp, $(BIN_DIR)/%, $(SRC))
DBG := $(patsubst $(HANDLER_DIR)/%.cpp, $(DBG_DIR)/%, $(SRC))
else
SRC := $(wildcard $(SRC_DIR)/*.cpp)
BIN := $(patsubst $(SRC_DIR)/%.cpp, $(BIN_DIR)/%, $(SRC))
DBG := $(patsubst $(SRC_DIR)/%.cpp, $(DBG_DIR)/%, $(SRC))
endif
SRC_C := $(wildcard $(SRC_DIR)/*.c)
BIN_C := $(patsubst $(SRC_DIR)/%.c, $(BIN_DIR)/%, $(SRC_C))
DBG_C := $(patsubst $(SRC_DIR)/%.c, $(DBG_DIR)/%, $(SRC_C))
SRC_JAVA := $(wildcard $(SRC_DIR)/*.java)
BIN_JAVA := $(patsubst $(SRC_DIR)/%.java, $(BIN_DIR)/%.class, $(SRC_JAVA))
DBG_JAVA := $(patsubst $(SRC_DIR)/%.java, $(DBG_DIR)/%.class, $(SRC_JAVA))
CHECKER := $(wildcard $(SRC_DIR)/checker.cpp)
C := gcc
CPP := g++
CXX_FLAGS := -Wall -O2
DEBUG_FLAGS := -Wall -g
BOCA_FLAGS := -static -DBOCA_SUPPORT
JV = javac
JV_DEBUG = -g
JV_DIR = -d bin
JV_DBG_DIR = -d bin/debug
.PHONY: all debug release checker clean
all: debug release checker
debug: $(DBG) $(DBG_C) $(DBG_JAVA) $(GRADER_DBG)
release: $(BIN) $(BIN_C) $(BIN_JAVA) $(GRADER_BIN)
ifdef CHECKER
checker: $(DBG_DIR)/checker-boca $(BIN_DIR)/checker-boca
endif
$(BIN): $(BIN_DIR)/% : $(SRC_DIR)/%.cpp | $(BIN_DIR)
$(CPP) $(CXX_FLAGS) $^ -o $@
$(DBG): $(DBG_DIR)/% : $(SRC_DIR)/%.cpp | $(DBG_DIR)
$(CPP) $(DEBUG_FLAGS) $^ -o $@
$(BIN_C): $(BIN_DIR)/% : $(SRC_DIR)/%.c | $(BIN_DIR)
$(C) $(CXX_FLAGS) $^ -o $@
$(DBG_C): $(DBG_DIR)/% : $(SRC_DIR)/%.c | $(DBG_DIR)
$(C) $(DEBUG_FLAGS) $^ -o $@
$(BIN_JAVA): $(BIN_DIR)/%.class : $(SRC_DIR)/%.java | $(BIN_DIR)
$(JV) $(JV_DIR) $^
$(DBG_JAVA): $(DBG_DIR)/%.class : $(SRC_DIR)/%.java | $(DBG_DIR)
$(JV) $(JV_DEBUG) $(JV_DBG_DIR) $^
$(GRADER_BIN): $(BIN_DIR)/% : $(GRADER_DIR)/%.cpp $(GRADER) $(GRADER_DIR)/*.h
$(CPP) $(CXX_FLAGS) $^ -o $@
$(GRADER_DBG): $(DBG_DIR)/% : $(GRADER_DIR)/%.cpp $(GRADER) $(GRADER_DIR)/*.h
$(CPP) $(DEBUG_FLAGS) $^ -o $@
$(BIN_DIR):
mkdir -p $@
$(DBG_DIR):
mkdir -p $@
$(BIN_DIR)/checker-boca: $(SRC_DIR)/checker.cpp
$(CPP) $(CXX_FLAGS) $(BOCA_FLAGS) $^ -o $@
$(DBG_DIR)/checker-boca: $(SRC_DIR)/checker.cpp
$(CPP) $(DEBUG_FLAGS) $(BOCA_FLAGS) $^ -o $@
clean:
@echo Cleaning problem files
rm -rf bin

View File

@@ -0,0 +1,53 @@
\documentclass{maratona}
\begin{document}
\begin{ProblemaAutor}{}{Análise de Dados}{1}{256}{Leetcode 1223}
É o seu primeiro dia no \textbf{Departamento de Controle de Qualidade}.
Você esperava analisar planilhas, gráficos e talvez alguns modelos estatísticos... mas o laboratório te surpreende.
Logo ao entrar, seu gerente te conduz até uma máquina barulhenta, repleta de cabos coloridos e um enorme botão vermelho no topo.
--- “Aqui nós fazemos \textbf{análise de dados}.”, ele diz, com um sorriso confiante.
Você concorda, achando que entendeu, até perceber que a máquina está literalmente lançando um dado de seis faces a cada segundo.
Sim, você vai analisar \textbf{dados de verdade}.
Mas há um problema: os dados do laboratório sofrem de \textit{fadiga de repetição}.
Se uma mesma face aparecer muitas vezes seguidas, o mecanismo emperra e a máquina trava, o que, segundo o manual, “não é recomendável”.
Cada face $i$ ($1 \le i \le 6$) possui um limite $d_i$: o número máximo de vezes que ela pode aparecer consecutivamente antes de causar uma falha.
Sua tarefa é determinar quantas sequências de lançamentos de comprimento $n$ podem ser geradas sem que a máquina quebre.
Como o número de sequências válidas pode ser gigantesco, o gerente exige que o resultado seja dado módulo $10^9 + 7$.
\Entrada
A entrada contém um inteiro \(n\) que representa o número de lançamentos do dado, onde \(1 \leq n \leq 5000\).
Em seguida, são dados seis inteiros \(d_1, d_2, d_3, d_4, d_5, d_6\), cada um representando o número máximo de vezes consecutivas que a face correspondente pode aparecer, com \(1 \leq d_i \leq 15\).
\Saida
A saída consiste em um único inteiro representando o número total de sequências válidas de lançamentos, considerando o resultado módulo \(10^9 + 7\).
\ExemploEntrada
\begin{Exemplo}
\texttt{2} & \texttt{34}\\
\texttt{1~1~2~2~2~3} & \\
\rowcolor{gray!20}\texttt{2} & \texttt{30}\\
\rowcolor{gray!20}\texttt{1~1~1~1~1~1} & \\
\end{Exemplo}
\Notas
No primeiro caso de teste, \(n = 2\) e os valores \(d\) são \((1, 1, 2, 2, 2, 3)\).
As faces \(1\) e \(2\) não podem aparecer repetidas consecutivamente, enquanto as demais possuem limites mais altos, resultando em \(34\) sequências válidas.
Como há \(2\) lançamentos de dado e \(6\) faces, sem restrições haveria \(6 \times 6 = 36\) combinações possíveis.
Entretanto, as sequências \((1, 1)\) e \((2, 2)\) são inválidas devido às restrições de \(d_1 = 1\) e \(d_2 = 1\).
Logo, o total de combinações válidas é \(36 - 2 = 34\). \end{ProblemaAutor}
\end{document}

2
analise-de-dados/input/1 Normal file
View File

@@ -0,0 +1,2 @@
2
1 1 2 2 2 3

View File

@@ -0,0 +1,2 @@
5
15 3 6 15 7 3

View File

@@ -0,0 +1,2 @@
2766
3 9 13 2 8 13

View File

@@ -0,0 +1,2 @@
4710
15 10 4 15 15 12

View File

@@ -0,0 +1,2 @@
2638
6 6 2 14 2 8

View File

@@ -0,0 +1,2 @@
4326
6 14 5 1 15 10

View File

@@ -0,0 +1,2 @@
4755
14 8 11 6 14 12

View File

@@ -0,0 +1,2 @@
5000
15 15 15 15 15 15

View File

@@ -0,0 +1,2 @@
4
13 6 5 6 10 7

View File

@@ -0,0 +1,2 @@
5
6 12 2 4 6 4

View File

@@ -0,0 +1,2 @@
5
4 5 15 6 5 6

View File

@@ -0,0 +1,2 @@
2
10 1 2 8 11 7

View File

@@ -0,0 +1,2 @@
4
9 7 1 2 2 13

View File

@@ -0,0 +1,2 @@
3
15 12 14 10 4 8

View File

@@ -0,0 +1,2 @@
4
2 9 15 3 11 11

View File

@@ -0,0 +1,2 @@
2
15 2 12 5 7 12

View File

@@ -0,0 +1,2 @@
3
15 11 14 3 10 6

2
analise-de-dados/input/2 Normal file
View File

@@ -0,0 +1,2 @@
2
1 1 1 1 1 1

View File

@@ -0,0 +1,2 @@
1
3 14 3 7 14 2

View File

@@ -0,0 +1,2 @@
5
5 4 9 12 9 2

View File

@@ -0,0 +1,2 @@
5
15 10 3 14 7 10

View File

@@ -0,0 +1,2 @@
2
14 13 11 5 1 3

View File

@@ -0,0 +1,2 @@
4
5 1 10 15 3 8

View File

@@ -0,0 +1,2 @@
2
15 13 2 15 1 4

View File

@@ -0,0 +1,2 @@
3
14 4 8 9 15 6

View File

@@ -0,0 +1,2 @@
4
2 7 1 3 13 7

View File

@@ -0,0 +1,2 @@
2
5 1 6 10 13 10

View File

@@ -0,0 +1,2 @@
5
14 5 7 12 8 10

2
analise-de-dados/input/3 Normal file
View File

@@ -0,0 +1,2 @@
3
1 1 1 2 2 3

View File

@@ -0,0 +1,2 @@
3
9 10 6 13 2 10

View File

@@ -0,0 +1,2 @@
4
2 8 14 6 1 15

View File

@@ -0,0 +1,2 @@
2
15 8 2 15 7 14

View File

@@ -0,0 +1,2 @@
4
1 15 11 3 14 2

View File

@@ -0,0 +1,2 @@
5
13 3 15 2 13 3

View File

@@ -0,0 +1,2 @@
3
2 12 11 3 7 13

View File

@@ -0,0 +1,2 @@
4
12 11 6 14 14 6

View File

@@ -0,0 +1,2 @@
3
13 8 10 8 5 13

View File

@@ -0,0 +1,2 @@
11
11 7 14 15 5 9

View File

@@ -0,0 +1,2 @@
11
14 15 14 7 4 14

2
analise-de-dados/input/4 Normal file
View File

@@ -0,0 +1,2 @@
2
2 2 2 2 2 2

View File

@@ -0,0 +1,2 @@
7
11 2 12 9 6 10

View File

@@ -0,0 +1,2 @@
11
7 7 14 14 6 9

View File

@@ -0,0 +1,2 @@
18
9 2 9 2 8 15

View File

@@ -0,0 +1,2 @@
17
10 7 3 6 3 5

View File

@@ -0,0 +1,2 @@
20
6 5 3 11 11 13

View File

@@ -0,0 +1,2 @@
11
9 6 4 14 11 9

View File

@@ -0,0 +1,2 @@
11
9 11 5 13 4 7

View File

@@ -0,0 +1,2 @@
14
3 11 9 4 2 4

View File

@@ -0,0 +1,2 @@
3
11 2 15 6 9 9

View File

@@ -0,0 +1,2 @@
19
11 9 13 9 5 9

2
analise-de-dados/input/5 Normal file
View File

@@ -0,0 +1,2 @@
2
5 6 10 7 6 7

View File

@@ -0,0 +1,2 @@
7
5 7 13 4 14 4

View File

@@ -0,0 +1,2 @@
10
2 5 11 15 6 3

View File

@@ -0,0 +1,2 @@
5
10 13 1 13 9 14

View File

@@ -0,0 +1,2 @@
17
10 6 4 15 12 10

View File

@@ -0,0 +1,2 @@
5
14 8 6 15 9 12

View File

@@ -0,0 +1,2 @@
1231
4 13 6 12 7 3

View File

@@ -0,0 +1,2 @@
3081
8 13 8 3 6 6

View File

@@ -0,0 +1,2 @@
1095
14 12 11 3 8 14

View File

@@ -0,0 +1,2 @@
1304
7 3 12 4 5 6

View File

@@ -0,0 +1,2 @@
3399
2 3 10 1 12 7

2
analise-de-dados/input/6 Normal file
View File

@@ -0,0 +1,2 @@
4
7 7 10 10 7 9

View File

@@ -0,0 +1,2 @@
237
4 6 6 14 3 11

View File

@@ -0,0 +1,2 @@
4944
12 8 14 5 6 9

View File

@@ -0,0 +1,2 @@
1946
11 1 15 4 9 7

View File

@@ -0,0 +1,2 @@
4850
8 2 1 6 1 1

View File

@@ -0,0 +1,2 @@
4661
7 1 13 3 11 3

View File

@@ -0,0 +1,2 @@
4772
6 14 14 1 6 4

View File

@@ -0,0 +1,2 @@
4018
5 5 14 5 11 15

View File

@@ -0,0 +1,2 @@
1378
1 3 14 15 4 15

View File

@@ -0,0 +1,2 @@
3345
8 7 6 5 12 15

View File

@@ -0,0 +1,2 @@
1675
2 10 6 10 6 11

2
analise-de-dados/input/7 Normal file
View File

@@ -0,0 +1,2 @@
2
11 12 7 13 12 12

View File

@@ -0,0 +1,2 @@
4857
14 13 7 5 6 9

View File

@@ -0,0 +1,2 @@
3082
13 13 9 6 14 8

View File

@@ -0,0 +1,2 @@
3717
3 9 13 11 5 1

View File

@@ -0,0 +1,2 @@
1083
8 1 9 7 1 3

View File

@@ -0,0 +1,2 @@
2238
9 6 8 15 12 14

View File

@@ -0,0 +1,2 @@
1632
15 10 8 5 6 9

View File

@@ -0,0 +1,2 @@
1954
15 9 13 10 5 10

View File

@@ -0,0 +1,2 @@
3212
12 5 6 12 8 14

View File

@@ -0,0 +1,2 @@
3668
8 11 10 2 3 13

View File

@@ -0,0 +1,2 @@
4328
8 11 11 11 6 5

2
analise-de-dados/input/8 Normal file
View File

@@ -0,0 +1,2 @@
4
8 1 14 6 5 3

View File

@@ -0,0 +1,2 @@
4964
9 15 9 11 9 10

View File

@@ -0,0 +1,2 @@
3429
6 6 1 5 4 9

View File

@@ -0,0 +1,2 @@
4513
6 2 3 4 5 7

View File

@@ -0,0 +1,2 @@
1122
3 9 6 12 8 3

View File

@@ -0,0 +1,2 @@
3172
6 13 11 7 11 12

View File

@@ -0,0 +1,2 @@
3343
11 10 13 13 9 14

View File

@@ -0,0 +1,2 @@
2903
1 7 5 12 5 1

View File

@@ -0,0 +1,2 @@
2177
9 1 12 8 2 12

View File

@@ -0,0 +1,2 @@
3237
13 6 6 4 10 1

View File

@@ -0,0 +1,2 @@
4743
3 2 12 10 5 2

2
analise-de-dados/input/9 Normal file
View File

@@ -0,0 +1,2 @@
3
1 5 8 8 9 1

View File

@@ -0,0 +1,2 @@
3324
1 9 14 13 3 1

View File

@@ -0,0 +1,2 @@
3389
1 9 4 3 12 9

View File

@@ -0,0 +1,2 @@
4025
8 9 10 14 10 2

Some files were not shown because too many files have changed in this diff Show More