feat(DP): new dp problems formated

This commit is contained in:
2025-11-04 21:14:50 -03:00
parent 669c13147b
commit 3b03c32703
925 changed files with 30660 additions and 0 deletions

97
decode-ways/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,38 @@
\documentclass{maratona}
\begin{document}
\begin{ProblemaAutor}{}{Decodificando Mensagens}{1}{256}{}
O problema consiste em determinar o número de maneiras possíveis de decodificar uma sequência numérica, onde cada número ou par de números representa uma letra do alfabeto latino.
A correspondência segue a regra \( 1 \rightarrow A, 2 \rightarrow B, \ldots, 26 \rightarrow Z \).
Cada dígito ou combinação de dois dígitos consecutivos pode ser convertido em uma letra válida, desde que a sequência resultante obedeça às restrições de decodificação.
O objetivo é calcular o total de maneiras diferentes de decodificar a sequência numérica fornecida.
\Entrada
A entrada é composta por duas linhas.
A primeira linha contém um inteiro \( n \) (\( 1 \leq n \leq 100 \)), representando o tamanho da sequência numérica.
A segunda linha contém uma sequência de digitos de \( s \) de comprimento \( n \).
\Saida
A saída deve conter um único inteiro, representando o número total de maneiras possíveis de decodificar a sequência numérica \( s \) de acordo com o mapeamento \( 1 \rightarrow A, 2 \rightarrow B, \ldots, 26 \rightarrow Z \).
\ExemploEntrada
\begin{Exemplo}
\texttt{2} & \texttt{2}\\
\texttt{12} & \\
\rowcolor{gray!20}\texttt{3} & \texttt{3}\\
\rowcolor{gray!20}\texttt{226} & \\
\texttt{2} & \texttt{0}\\
\texttt{06} & \\
\end{Exemplo}
\Notas
Para a sequência \( s = "12" \), existem duas decodificações possíveis: "AB" (1, 2) e "L" (12).
Para a sequência \( s = "226" \), há três decodificações possíveis: "BZ" (2, 26), "VF" (22, 6) e "BBF" (2, 2, 6).
Para a sequência \( s = "06" \), não há nenhuma forma válida de decodificação.\end{ProblemaAutor}
\end{document}

2
decode-ways/input/1 Normal file
View File

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

2
decode-ways/input/10 Normal file
View File

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

2
decode-ways/input/100 Normal file
View File

@@ -0,0 +1,2 @@
48
518576418188343163835239258872334287663796652624

2
decode-ways/input/101 Normal file
View File

@@ -0,0 +1,2 @@
68
52611796735121263614334491834993887664736392163582841633871161326664

2
decode-ways/input/102 Normal file
View File

@@ -0,0 +1,2 @@
53
78918262129187186226632721586627412359187439651896536

2
decode-ways/input/103 Normal file
View File

@@ -0,0 +1,2 @@
82
1472422558528699249214744131191854224759984764314392981892686621213825459276764139

2
decode-ways/input/104 Normal file
View File

@@ -0,0 +1,2 @@
75
337487917337778439116484693776643462673224333737181491845687417121878438442

2
decode-ways/input/105 Normal file
View File

@@ -0,0 +1,2 @@
48
963474156832317453372274752839831748129848526892

2
decode-ways/input/106 Normal file
View File

@@ -0,0 +1,2 @@
100
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

2
decode-ways/input/107 Normal file
View File

@@ -0,0 +1,2 @@
100
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

2
decode-ways/input/11 Normal file
View File

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

2
decode-ways/input/12 Normal file
View File

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

2
decode-ways/input/13 Normal file
View File

@@ -0,0 +1,2 @@
4
2388

2
decode-ways/input/14 Normal file
View File

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

2
decode-ways/input/15 Normal file
View File

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

2
decode-ways/input/16 Normal file
View File

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

2
decode-ways/input/17 Normal file
View File

@@ -0,0 +1,2 @@
5
42142

2
decode-ways/input/18 Normal file
View File

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

2
decode-ways/input/19 Normal file
View File

@@ -0,0 +1,2 @@
5
51865

2
decode-ways/input/2 Normal file
View File

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

2
decode-ways/input/20 Normal file
View File

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

2
decode-ways/input/21 Normal file
View File

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

2
decode-ways/input/22 Normal file
View File

@@ -0,0 +1,2 @@
5
88626

2
decode-ways/input/23 Normal file
View File

@@ -0,0 +1,2 @@
5
55673

2
decode-ways/input/24 Normal file
View File

@@ -0,0 +1,2 @@
4
4647

2
decode-ways/input/25 Normal file
View File

@@ -0,0 +1,2 @@
5
79735

2
decode-ways/input/26 Normal file
View File

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

2
decode-ways/input/27 Normal file
View File

@@ -0,0 +1,2 @@
4
8282

2
decode-ways/input/28 Normal file
View File

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

2
decode-ways/input/29 Normal file
View File

@@ -0,0 +1,2 @@
4
2554

2
decode-ways/input/3 Normal file
View File

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

2
decode-ways/input/30 Normal file
View File

@@ -0,0 +1,2 @@
4
2859

2
decode-ways/input/31 Normal file
View File

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

2
decode-ways/input/32 Normal file
View File

@@ -0,0 +1,2 @@
4
7752

2
decode-ways/input/33 Normal file
View File

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

2
decode-ways/input/34 Normal file
View File

@@ -0,0 +1,2 @@
4
3151

2
decode-ways/input/35 Normal file
View File

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

2
decode-ways/input/36 Normal file
View File

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

2
decode-ways/input/37 Normal file
View File

@@ -0,0 +1,2 @@
5
18499

2
decode-ways/input/38 Normal file
View File

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

2
decode-ways/input/39 Normal file
View File

@@ -0,0 +1,2 @@
14
37196832511826

2
decode-ways/input/4 Normal file
View File

@@ -0,0 +1,2 @@
12
101010101010

2
decode-ways/input/40 Normal file
View File

@@ -0,0 +1,2 @@
14
64484224997944

2
decode-ways/input/41 Normal file
View File

@@ -0,0 +1,2 @@
5
24949

2
decode-ways/input/42 Normal file
View File

@@ -0,0 +1,2 @@
17
37294479837671427

2
decode-ways/input/43 Normal file
View File

@@ -0,0 +1,2 @@
16
8428292392363723

2
decode-ways/input/44 Normal file
View File

@@ -0,0 +1,2 @@
18
273528536665319655

2
decode-ways/input/45 Normal file
View File

@@ -0,0 +1,2 @@
20
24719734762578639371

2
decode-ways/input/46 Normal file
View File

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

2
decode-ways/input/47 Normal file
View File

@@ -0,0 +1,2 @@
8
15247334

2
decode-ways/input/48 Normal file
View File

@@ -0,0 +1,2 @@
12
136113183132

2
decode-ways/input/49 Normal file
View File

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

2
decode-ways/input/5 Normal file
View File

@@ -0,0 +1,2 @@
9
123456789

2
decode-ways/input/50 Normal file
View File

@@ -0,0 +1,2 @@
19
7241653425678432716

2
decode-ways/input/51 Normal file
View File

@@ -0,0 +1,2 @@
20
34126267846874316445

2
decode-ways/input/52 Normal file
View File

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

2
decode-ways/input/53 Normal file
View File

@@ -0,0 +1,2 @@
17
84276873496766337

2
decode-ways/input/54 Normal file
View File

@@ -0,0 +1,2 @@
19
5958182244867784952

2
decode-ways/input/55 Normal file
View File

@@ -0,0 +1,2 @@
13
9589633411419

2
decode-ways/input/56 Normal file
View File

@@ -0,0 +1,2 @@
10
8398213573

2
decode-ways/input/57 Normal file
View File

@@ -0,0 +1,2 @@
26
73663332643446699323268217

2
decode-ways/input/58 Normal file
View File

@@ -0,0 +1,2 @@
51
597752268768498572655986286986334279136111777165378

2
decode-ways/input/59 Normal file
View File

@@ -0,0 +1,2 @@
9
451285328

2
decode-ways/input/6 Normal file
View File

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

2
decode-ways/input/60 Normal file
View File

@@ -0,0 +1,2 @@
25
5179694487483151683559695

2
decode-ways/input/61 Normal file
View File

@@ -0,0 +1,2 @@
100
8316458848752384176499983776724483328624123861532722553258433293959428726775271517961761959111789139

2
decode-ways/input/62 Normal file
View File

@@ -0,0 +1,2 @@
9
143311934

2
decode-ways/input/63 Normal file
View File

@@ -0,0 +1,2 @@
14
56564483689558

2
decode-ways/input/64 Normal file
View File

@@ -0,0 +1,2 @@
9
255811985

2
decode-ways/input/65 Normal file
View File

@@ -0,0 +1,2 @@
50
16741576977262376174576888714481988178418237879751

2
decode-ways/input/66 Normal file
View File

@@ -0,0 +1,2 @@
34
7912496541424572969715221578743582

2
decode-ways/input/67 Normal file
View File

@@ -0,0 +1,2 @@
66
511181583562138544652879939619627143791253131734323199639644813935

2
decode-ways/input/68 Normal file
View File

@@ -0,0 +1,2 @@
23
34741989276975341315688

2
decode-ways/input/69 Normal file
View File

@@ -0,0 +1,2 @@
23
45243179164459651875893

2
decode-ways/input/7 Normal file
View File

@@ -0,0 +1,2 @@
5
37679

2
decode-ways/input/70 Normal file
View File

@@ -0,0 +1,2 @@
18
698195955781719962

2
decode-ways/input/71 Normal file
View File

@@ -0,0 +1,2 @@
55
7582648264398882877454489217294277449711166684383791147

2
decode-ways/input/72 Normal file
View File

@@ -0,0 +1,2 @@
91
3845152233572493744521853897783842761323223652968987664537616595428385811273627127469429381

2
decode-ways/input/73 Normal file
View File

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

2
decode-ways/input/74 Normal file
View File

@@ -0,0 +1,2 @@
35
37685246269847376739186534397615885

2
decode-ways/input/75 Normal file
View File

@@ -0,0 +1,2 @@
33
437232465386456746384257211614427

2
decode-ways/input/76 Normal file
View File

@@ -0,0 +1,2 @@
77
17627517227585432463647443411727297154114579897575441832469788516169223138766

2
decode-ways/input/77 Normal file
View File

@@ -0,0 +1,2 @@
6
236636

2
decode-ways/input/78 Normal file
View File

@@ -0,0 +1,2 @@
89
56785878774135436521917749817518257767277569393487816624138298551327985724282322911471635

2
decode-ways/input/79 Normal file
View File

@@ -0,0 +1,2 @@
22
5368853232981964665459

2
decode-ways/input/8 Normal file
View File

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

2
decode-ways/input/80 Normal file
View File

@@ -0,0 +1,2 @@
28
3661945636959924865895846599

2
decode-ways/input/81 Normal file
View File

@@ -0,0 +1,2 @@
22
9162867281853634311682

2
decode-ways/input/82 Normal file
View File

@@ -0,0 +1,2 @@
54
999497851484629835958949631491319582288263883695162451

2
decode-ways/input/83 Normal file
View File

@@ -0,0 +1,2 @@
36
966175859412534487161999147248815572

2
decode-ways/input/84 Normal file
View File

@@ -0,0 +1,2 @@
42
173184196431757315622639898225196889893963

2
decode-ways/input/85 Normal file
View File

@@ -0,0 +1,2 @@
97
9566988274161314117748561711233529414952989568468244593491147579639921595125316948833947962993645

2
decode-ways/input/86 Normal file
View File

@@ -0,0 +1,2 @@
92
41936458821482611656832918868813157673644393869888125877891312946217957114117772772821737554

2
decode-ways/input/87 Normal file
View File

@@ -0,0 +1,2 @@
60
897695728994154752385672625781113921437631223164657764585738

2
decode-ways/input/88 Normal file
View File

@@ -0,0 +1,2 @@
47
35839563993964564988114497921613189536194214699

2
decode-ways/input/89 Normal file
View File

@@ -0,0 +1,2 @@
28
5919482365125774713895541215

2
decode-ways/input/9 Normal file
View File

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

2
decode-ways/input/90 Normal file
View File

@@ -0,0 +1,2 @@
34
5121266393832816569681656646982897

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