feat: new problem being formated.

This commit is contained in:
2026-04-28 23:01:57 -03:00
parent 9c0eca4a3f
commit 1045a54db2
15 changed files with 6473 additions and 0 deletions

97
ra-preguicosa/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

188
ra-preguicosa/maratona.cls Normal file
View File

@@ -0,0 +1,188 @@
\ProvidesPackage{maratona}
\LoadClass[11pt]{article}
% remove page numbers
\pagenumbering{gobble}
\RequirePackage{fancyhdr}
\RequirePackage{tabularx,colortbl}
%\RequirePackage{arial}
\RequirePackage{ifpdf}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage[portuguese]{babel}
\RequirePackage{graphics}
\RequirePackage{graphicx}
\RequirePackage{amssymb,amsmath,wrapfig}
\RequirePackage{xcolor,colortbl}
\RequirePackage{xcolor}
\RequirePackage{ifthen}
\oddsidemargin 0cm
\evensidemargin -2cm
\topmargin -1cm
\textwidth 16cm
\textheight 23cm
\ifpdf
\RequirePackage[pdftex]{hyperref}
\else
\RequirePackage[hypertex]{hyperref}
\fi
\newcommand{\var}[1]{\ensuremath{{#1}}}
\hypersetup{
letterpaper,
colorlinks=true,
linkcolor=blue,
urlcolor=blue,
pdfpagemode=none,
pdftitle={IV Maratona de Programação do IFB \today},
pdfauthor={},
pdfsubject={Caderno de problemas da IV Maratona de Programação do IFB },
pdfkeywords={maratona, programação, IFB}
}
\DeclareGraphicsExtensions{png}
\lhead{DS Contest Tools}
\pagestyle{fancy}
% Capa
\newenvironment{Maratona}[3]
{
\begin{titlepage}
\begin{center}
\vspace{1cm}
\Large{\textbf{#1}} \\
\vspace{1cm}
{\textbf{Caderno de Problemas}} \\
\vspace{1cm}
\begin{small}
\textsl{#2}
\end{small} \\
\begin{figure}[htp]
\begin{center}
\includegraphics[scale=1]{logos/logo-maratona.png}
\end{center}
\end{figure}
{(Este caderno contém {#3} problemas)} \\
\vspace{1cm}
}
{
\vfill
\begin{small}
{QNM 40, Área Especial nº 01,
Taguatinga/DF, 72146-000 ,
Brasil } \\
{Telefone (61) 2103-2200 \\http://www.ifb.edu.br/taguatinga} \\
\end{small}
\end{center}
\end{titlepage}
}
\newcommand{\Organizacao}[2]{
{\small \vfill
\begin{center}
\textbf{Comissão Organizadora:} \\
{#1} \\
\bigskip
\textbf{Apoio:}\\
{#2}
\end{center}
}
\vfill
}
% Problema
\newcounter{problem}
\newenvironment{Problema}[4]{
\stepcounter{problem}
\newpage
\begin{center}
\Large{\ifthenelse{\equal{#1}{}}{\textbf{{#2}}}{\textbf{Problema {#1} -- {#2} }}}{\\\footnotesize \textbf{Limite de tempo: {#3}s}}{\\[-0.1cm]\footnotesize \textbf{Limite de memória: {#4}MB}}
\end{center}
}
\newcounter{problemAutor}
\newenvironment{ProblemaAutor}[5]{
\stepcounter{problemAutor}
\newpage
\begin{center}
\Large{\ifthenelse{\equal{#1}{}}{\textbf{{#2}}}{\textbf{Problema {#1} -- {#2} }}}{\\\footnotesize \textbf{Limite de tempo: {#3}s}}{\\[-0.1cm]\footnotesize \textbf{Limite de memória: {#4}MB\\}}{
\footnotesize Autor: {#5}
}
\end{center}
}
% Código-fonte
\newcommand{\codigofonte}[1]{Nome do arquivo fonte: {#1}}
% Entrada
\newcommand{\Entrada}{
\bigskip
\begin{large}
\textbf{Entrada} \\
\end{large}
}
% Saida
\newcommand{\Saida}{
\bigskip
\begin{large}
\textbf{Saída} \\
\end{large}
}
\newcommand{\Interacao}{
\bigskip
\begin{large}
\textbf{Interação} \\
\end{large}
}
\newcommand{\Notas}{
\bigskip
\begin{large}
\textbf{Notas} \\
\end{large}
}
% Exemplo
\newenvironment{Exemplo}
{
\tabularx{\textwidth}{XX}
% {@{\extracolsep{\fill}}|l|l|}
% {|l|l@{\extracolsep{\fill}|}}
\hline
Entrada & Saída \\\hline
}
{
\hline
\endtabularx
}
% Exemplo de Entrada
\newenvironment{ExemploEntrada}
{
\bigskip
\begin{large}
\textbf{Exemplo} \\
\end{large}
}
{
}
% Sample Output

View File

@@ -0,0 +1,64 @@
{
"version": "1.0",
"problem": {
"title": "A rã saltadora preguiçosa",
"event": "",
"time_limit": 1.0,
"memory_limit_mb": 1536,
"input_file": "stdin",
"output_file": "stdout",
"interactive": false,
"grader": false,
"subject": {
"en_us": [
""
],
"pt_br": [
""
],
"es": [
""
]
}
},
"author": {
"name": "SPOJ - RAPREGUI",
"affiliation": "",
"country": "",
"email": ""
},
"build": {
"run_generator": true,
"run_validator": true,
"produce_outputs": true,
"run_checker": true,
"run_all_solutions": true,
"run_specific_solution": "",
"generate_io_only": false,
"generate_pdf_only": false,
"cpu_count": 1,
"build_pdf": true,
"pdf_format": "ds",
"io_samples": 3
},
"solutions": {
"main-ac": "",
"alternative-ac": [],
"wrong-answer": [],
"time-limit": [],
"time-limit-or-ac": [],
"time-limit-or-memory-limit": [],
"memory-limit": [],
"presentation-error": [],
"runtime-error": []
},
"polygon_config": {
"id": ""
},
"boca_config": {
"time_limit": 1,
"number_of_repetitions": 1,
"maximum_memory_mb": 1536,
"maximum_output_size_kb": 24096
}
}

8
ra-preguicosa/src/ac.cpp Normal file
View File

@@ -0,0 +1,8 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
return 0;
}

View File

@@ -0,0 +1,12 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
setName("Set the name of your checker here");
registerTestlibCmd(argc, argv);
return 0;
}

View File

@@ -0,0 +1,83 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
const int MIN_N = 0;
const int MAX_N = 100;
const int rnd_test_n = 100;
template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
dest.insert(dest.end(), orig.begin(), orig.end());
}
string output_tc(int x, int y) {
ostringstream oss;
oss << x << " " << y << endl;
return oss.str();
}
vector<string> generate_sample_tests() {
vector<string> tests;
tests.push_back(output_tc(1, 1));
tests.push_back(output_tc(2, 2));
tests.push_back(output_tc(0, 0));
return tests;
}
vector<string> generate_manual_tests() {
vector<string> tests;
tests.push_back(output_tc(100, 0));
tests.push_back(output_tc(0, 100));
return tests;
}
string rnd_test(int i){
int min_n = MIN_N;
int max_n = MAX_N;
if(i<rnd_test_n / 3){
max_n = 5;
}
else if(i<rnd_test_n / 2){
max_n = 20;
}
int x = rnd.next(min_n, max_n);
int y = rnd.next(min_n, max_n);
return(output_tc(x, y));
}
vector<string> generate_random_tests() {
vector<string> tests;
for (int i = 0; i < rnd_test_n; i++){
tests.push_back(rnd_test(i));
}
return tests;
}
string extreme_test_1(){
return(output_tc(100, 100));
}
vector<string> generate_extreme_tests(){
vector<string> tests;
tests.push_back(extreme_test_1());
return tests;
}
int main(int argc, char *argv[]) {
registerGen(argc, argv, 1);
vector<string> tests;
size_t test = 0;
append(tests, generate_sample_tests());
append(tests, generate_manual_tests());
append(tests, generate_random_tests());
append(tests, generate_extreme_tests());
for (const auto &t : tests) {
startTest(++test);
cout << t;
}
return 0;
}

View File

@@ -0,0 +1 @@
generator

5963
ra-preguicosa/src/testlib.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
registerValidation(argc, argv);
while (true) {
int C = inf.readInt(1, 1000, "C");
inf.readSpace();
int R = inf.readInt(1, 1000, "R");
inf.readEoln();
if (C == 0 && R == 0) break;
int Cf, Rf, Ct, Rt;
Cf = inf.readInt(1, C, "Cf");
inf.readSpace();
Rf = inf.readInt(1, R, "Rf");
inf.readSpace();
Ct = inf.readInt(1, C, "Ct");
inf.readSpace();
Rt = inf.readInt(1, R, "Rt");
inf.readEoln();
int W = inf.readInt(0, 1000, "W");
inf.readEoln();
for (int i = 0; i < W; i++) {
int C1, C2, R1, R2;
C1 = inf.readInt(1, C, "C1");
inf.readSpace();
C2 = inf.readInt(1, C, "C2");
inf.readSpace();
R1 = inf.readInt(1, R, "R1");
inf.readSpace();
R2 = inf.readInt(1, R, "R2");
inf.readEoln();
}
}
inf.readEof();
return 0;
}

View File

@@ -0,0 +1,5 @@
Sr. Rã vive em um pântano em forma de grade retangular, composto de células de mesmo tamanho, algumas delas são secas, outras são somente lugares alagados. Sr. Rã vive em uma célula seca e pode saltar somente de uma célula seca para outra célula seca em seus passeios pelo pântano.
Sr. Rã quer visitar sua namorada, Sra. Sapo, que também vive em uma célula seca no mesmo pântano. Mas Sr. Rã é preguiçoso, e quer gastar a menor quantidade de energia em seu caminho "saltante" até a casa da Sra. Sapo. Sr. Rã sabe quanta energia gasta em qualquer um de seus saltos. Para cada salto simples, Sr. Rã usa a figura a seguir para determinar quais são as possíveis células alvo de sua posição atual (a celula marcada com F), e a quantidade de energia correspondente no salto, em calorias. Qualquer outra célula é inatíngivel da posição atual de Sr. Rã com um salto simples.
Sua tarefa é determinar a quantidade minima de energia que Sr. Rã precisa gastar para ir de sua casa para a casa da Sra. Sapo.

View File

@@ -0,0 +1,6 @@
A entrada contém varios casos de teste.
A primeira linha de um caso de teste contém dois inteiros, $C$ e $R$, indicando respectivamente o numero de colunas e linhas do pântano ($1 \le C, R \le 1000$).
A segunda linha de um caso de teste contem quatro inteiros $C_f$, $R_f$, $C_t$, e $R_t$, onde $(C_f, R_f)$ especifica a localização da casa do Sr. Rã e $(C_t, R_t)$ especifica a localização da casa da Sra. Sapo.
A terceira linha de um caso de teste contém um inteiro $W$ ($0 \le W \le 1000$) indicando o número de lugares alagados no pântano.
Cada uma das próximas $W$ linhas contém quatro inteiros $C_1$, $R_1$, $C_2$, e $R_2$ ($1 \le C_1 \le C_2 \le C$ e $1 \le R_1 \le R_2 \le R$) descrevendo um lugar retangular alagado contendo células cujas coordenadas $(x,y)$ são tais que $C_1 \le x \le C_2$ e $R_1 \le y \le R_2$.
O fim da entrada é indicado por $C=R=0$.

View File

View File

@@ -0,0 +1,2 @@
Para cada caso de teste na entrada, seu programa deve produzir uma linha de saída, contendo o mínimo de calorias consumidas pelo Sr. Rã para ir de sua casa para a casa da Sra. Sapo.
Se não houver como o Sr. Rã chegar até a casa da Sra. Sapo, seu programa deve imprimir 'impossible'.

View File

View File