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
flowers/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

36
flowers/flowers.tex Normal file
View File

@@ -0,0 +1,36 @@
\documentclass{maratona}
\begin{document}
\begin{ProblemaAutor}{}{O problema das Flores}{1}{256}{}
O problema consiste em determinar o número total de sequências de flores vermelhas e brancas de comprimento \(n\) tais que nunca existam mais de \(m\) flores consecutivas do mesmo tipo.
Cada posição da sequência contém exatamente uma flor, que pode ser vermelha ou branca.
O objetivo é contar quantas sequências distintas satisfazem a restrição de que o comprimento de qualquer bloco consecutivo de flores da mesma cor seja no máximo \(m\).
\Entrada
A entrada contém dois inteiros separados por espaço: \(n\) e \(m\).
\(n\) (\(1 \leq n \leq 10^4\)) é o comprimento da sequência de flores.
\(m\) (\(1 \leq m \leq 1000\)) é o número máximo permitido de flores iguais consecutivas.
\Saida
A saída deve conter um único inteiro, que representa o número total de sequências válidas de comprimento \(n\) sobre o alfabeto {vermelha, branca} que satisfazem a restrição de máximo \(m\) flores consecutivas do mesmo tipo.
\ExemploEntrada
\begin{Exemplo}
\texttt{1~1} & \texttt{2}\\
\rowcolor{gray!20}\texttt{2~2} & \texttt{4}\\
\texttt{2~3} & \texttt{4}\\
\end{Exemplo}
\Notas
Caso de teste 1: \(n=1, m=1\).
Para uma sequência de comprimento 1 existem duas opções: {vermelha} ou {branca}. Portanto, o número de sequências válidas é 2.
Caso de teste 2: \(n=2, m=2\).
Como \(m \ge 2\), não há restrição efetiva para \(n=2\) além de que cada posição pode ser vermelha ou branca. Assim todas as \(2^2 = 4\) sequências são válidas.\end{ProblemaAutor}
\end{document}

1
flowers/input/1 Normal file
View File

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

1
flowers/input/10 Normal file
View File

@@ -0,0 +1 @@
1497 202

1
flowers/input/100 Normal file
View File

@@ -0,0 +1 @@
7455 217

1
flowers/input/101 Normal file
View File

@@ -0,0 +1 @@
3590 343

1
flowers/input/102 Normal file
View File

@@ -0,0 +1 @@
4427 220

1
flowers/input/103 Normal file
View File

@@ -0,0 +1 @@
1342 584

1
flowers/input/104 Normal file
View File

@@ -0,0 +1 @@
4239 496

1
flowers/input/105 Normal file
View File

@@ -0,0 +1 @@
5875 601

1
flowers/input/106 Normal file
View File

@@ -0,0 +1 @@
10000 1

1
flowers/input/107 Normal file
View File

@@ -0,0 +1 @@
10000 1000

1
flowers/input/108 Normal file
View File

@@ -0,0 +1 @@
1 1000

1
flowers/input/109 Normal file
View File

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

1
flowers/input/11 Normal file
View File

@@ -0,0 +1 @@
1775 325

1
flowers/input/12 Normal file
View File

@@ -0,0 +1 @@
1982 784

1
flowers/input/13 Normal file
View File

@@ -0,0 +1 @@
417 156

1
flowers/input/14 Normal file
View File

@@ -0,0 +1 @@
1932 902

1
flowers/input/15 Normal file
View File

@@ -0,0 +1 @@
1728 537

1
flowers/input/16 Normal file
View File

@@ -0,0 +1 @@
1857 739

1
flowers/input/17 Normal file
View File

@@ -0,0 +1 @@
918 211

1
flowers/input/18 Normal file
View File

@@ -0,0 +1 @@
1679 506

1
flowers/input/19 Normal file
View File

@@ -0,0 +1 @@
1340 568

1
flowers/input/2 Normal file
View File

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

1
flowers/input/20 Normal file
View File

@@ -0,0 +1 @@
1868 16

1
flowers/input/21 Normal file
View File

@@ -0,0 +1 @@
1940 263

1
flowers/input/22 Normal file
View File

@@ -0,0 +1 @@
593 449

1
flowers/input/23 Normal file
View File

@@ -0,0 +1 @@
991 310

1
flowers/input/24 Normal file
View File

@@ -0,0 +1 @@
1355 68

1
flowers/input/25 Normal file
View File

@@ -0,0 +1 @@
1431 580

1
flowers/input/26 Normal file
View File

@@ -0,0 +1 @@
1757 218

1
flowers/input/27 Normal file
View File

@@ -0,0 +1 @@
934 328

1
flowers/input/28 Normal file
View File

@@ -0,0 +1 @@
1676 355

1
flowers/input/29 Normal file
View File

@@ -0,0 +1 @@
221 80

1
flowers/input/3 Normal file
View File

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

1
flowers/input/30 Normal file
View File

@@ -0,0 +1 @@
1922 545

1
flowers/input/31 Normal file
View File

@@ -0,0 +1 @@
511 67

1
flowers/input/32 Normal file
View File

@@ -0,0 +1 @@
1467 674

1
flowers/input/33 Normal file
View File

@@ -0,0 +1 @@
691 504

1
flowers/input/34 Normal file
View File

@@ -0,0 +1 @@
1835 34

1
flowers/input/35 Normal file
View File

@@ -0,0 +1 @@
965 980

1
flowers/input/36 Normal file
View File

@@ -0,0 +1 @@
1221 895

1
flowers/input/37 Normal file
View File

@@ -0,0 +1 @@
501 152

1
flowers/input/38 Normal file
View File

@@ -0,0 +1 @@
325 731

1
flowers/input/39 Normal file
View File

@@ -0,0 +1 @@
4302 153

1
flowers/input/4 Normal file
View File

@@ -0,0 +1 @@
100 20

1
flowers/input/40 Normal file
View File

@@ -0,0 +1 @@
4896 22

1
flowers/input/41 Normal file
View File

@@ -0,0 +1 @@
2489 399

1
flowers/input/42 Normal file
View File

@@ -0,0 +1 @@
607 466

1
flowers/input/43 Normal file
View File

@@ -0,0 +1 @@
4432 502

1
flowers/input/44 Normal file
View File

@@ -0,0 +1 @@
3968 333

1
flowers/input/45 Normal file
View File

@@ -0,0 +1 @@
2475 792

1
flowers/input/46 Normal file
View File

@@ -0,0 +1 @@
84 10

1
flowers/input/47 Normal file
View File

@@ -0,0 +1 @@
4694 328

1
flowers/input/48 Normal file
View File

@@ -0,0 +1 @@
2354 712

1
flowers/input/49 Normal file
View File

@@ -0,0 +1 @@
3409 480

1
flowers/input/5 Normal file
View File

@@ -0,0 +1 @@
4 100

1
flowers/input/50 Normal file
View File

@@ -0,0 +1 @@
2643 121

1
flowers/input/51 Normal file
View File

@@ -0,0 +1 @@
1951 492

1
flowers/input/52 Normal file
View File

@@ -0,0 +1 @@
4420 197

1
flowers/input/53 Normal file
View File

@@ -0,0 +1 @@
3607 925

1
flowers/input/54 Normal file
View File

@@ -0,0 +1 @@
2167 717

1
flowers/input/55 Normal file
View File

@@ -0,0 +1 @@
3438 200

1
flowers/input/56 Normal file
View File

@@ -0,0 +1 @@
6986 104

1
flowers/input/57 Normal file
View File

@@ -0,0 +1 @@
6483 620

1
flowers/input/58 Normal file
View File

@@ -0,0 +1 @@
9806 881

1
flowers/input/59 Normal file
View File

@@ -0,0 +1 @@
6858 559

1
flowers/input/6 Normal file
View File

@@ -0,0 +1 @@
522 575

1
flowers/input/60 Normal file
View File

@@ -0,0 +1 @@
6553 502

1
flowers/input/61 Normal file
View File

@@ -0,0 +1 @@
3554 962

1
flowers/input/62 Normal file
View File

@@ -0,0 +1 @@
2325 435

1
flowers/input/63 Normal file
View File

@@ -0,0 +1 @@
9279 464

1
flowers/input/64 Normal file
View File

@@ -0,0 +1 @@
7327 549

1
flowers/input/65 Normal file
View File

@@ -0,0 +1 @@
9832 595

1
flowers/input/66 Normal file
View File

@@ -0,0 +1 @@
8200 720

1
flowers/input/67 Normal file
View File

@@ -0,0 +1 @@
7658 639

1
flowers/input/68 Normal file
View File

@@ -0,0 +1 @@
9992 130

1
flowers/input/69 Normal file
View File

@@ -0,0 +1 @@
6467 989

1
flowers/input/7 Normal file
View File

@@ -0,0 +1 @@
426 445

1
flowers/input/70 Normal file
View File

@@ -0,0 +1 @@
7958 581

1
flowers/input/71 Normal file
View File

@@ -0,0 +1 @@
6600 466

1
flowers/input/72 Normal file
View File

@@ -0,0 +1 @@
1473 929

1
flowers/input/73 Normal file
View File

@@ -0,0 +1 @@
9775 581

1
flowers/input/74 Normal file
View File

@@ -0,0 +1 @@
9770 455

1
flowers/input/75 Normal file
View File

@@ -0,0 +1 @@
3718 628

1
flowers/input/76 Normal file
View File

@@ -0,0 +1 @@
6807 335

1
flowers/input/77 Normal file
View File

@@ -0,0 +1 @@
1898 552

1
flowers/input/78 Normal file
View File

@@ -0,0 +1 @@
6530 811

1
flowers/input/79 Normal file
View File

@@ -0,0 +1 @@
9569 148

1
flowers/input/8 Normal file
View File

@@ -0,0 +1 @@
772 81

1
flowers/input/80 Normal file
View File

@@ -0,0 +1 @@
3384 954

1
flowers/input/81 Normal file
View File

@@ -0,0 +1 @@
8913 114

1
flowers/input/82 Normal file
View File

@@ -0,0 +1 @@
6315 686

1
flowers/input/83 Normal file
View File

@@ -0,0 +1 @@
9334 382

1
flowers/input/84 Normal file
View File

@@ -0,0 +1 @@
1392 326

1
flowers/input/85 Normal file
View File

@@ -0,0 +1 @@
1008 553

1
flowers/input/86 Normal file
View File

@@ -0,0 +1 @@
962 957

1
flowers/input/87 Normal file
View File

@@ -0,0 +1 @@
4850 231

1
flowers/input/88 Normal file
View File

@@ -0,0 +1 @@
2061 185

1
flowers/input/89 Normal file
View File

@@ -0,0 +1 @@
1588 305

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