Merge branch 'main' of https://gitea.danielsaad.com/danielsaad/problemas-para-competicao-pibiti-arthur-dolival
This commit is contained in:
97
ra-preguicosa/Makefile
Normal file
97
ra-preguicosa/Makefile
Normal 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
|
||||
8053
ra-preguicosa/input/1
Normal file
8053
ra-preguicosa/input/1
Normal file
File diff suppressed because it is too large
Load Diff
188
ra-preguicosa/maratona.cls
Normal file
188
ra-preguicosa/maratona.cls
Normal 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
|
||||
|
||||
45
ra-preguicosa/output/1
Normal file
45
ra-preguicosa/output/1
Normal file
@@ -0,0 +1,45 @@
|
||||
0
|
||||
impossible
|
||||
14
|
||||
impossible
|
||||
12
|
||||
14
|
||||
17
|
||||
30
|
||||
impossible
|
||||
27
|
||||
12
|
||||
54
|
||||
57
|
||||
48
|
||||
55
|
||||
56
|
||||
147
|
||||
222
|
||||
208
|
||||
207
|
||||
239
|
||||
impossible
|
||||
242
|
||||
230
|
||||
134
|
||||
226
|
||||
34
|
||||
218
|
||||
99
|
||||
impossible
|
||||
97
|
||||
102
|
||||
impossible
|
||||
102
|
||||
2493
|
||||
165338
|
||||
810
|
||||
impossible
|
||||
662674
|
||||
2997
|
||||
impossible
|
||||
3179
|
||||
3016
|
||||
impossible
|
||||
3296
|
||||
64
ra-preguicosa/problem.json
Normal file
64
ra-preguicosa/problem.json
Normal 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": 0
|
||||
},
|
||||
"solutions": {
|
||||
"main-ac": "ac.cpp",
|
||||
"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
|
||||
}
|
||||
}
|
||||
BIN
ra-preguicosa/ra-preguicosa.pdf
Normal file
BIN
ra-preguicosa/ra-preguicosa.pdf
Normal file
Binary file not shown.
13
ra-preguicosa/ra-preguicosa.tex
Normal file
13
ra-preguicosa/ra-preguicosa.tex
Normal file
@@ -0,0 +1,13 @@
|
||||
\documentclass{maratona}
|
||||
|
||||
\begin{document}
|
||||
\begin{ProblemaAutor}{}{A rã saltadora preguiçosa}{1}{1536}{SPOJ - RAPREGUI}
|
||||
|
||||
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.
|
||||
|
||||
\end{ProblemaAutor}
|
||||
\end{document}
|
||||
128
ra-preguicosa/src/ac.cpp
Normal file
128
ra-preguicosa/src/ac.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
#define endl '\n'
|
||||
#define INF 0x3f
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef pair<int, int> pii;
|
||||
|
||||
const int MAXN = 1e3 + 10;
|
||||
|
||||
int C, L, W;
|
||||
int Cr, Lr, Cs, Ls;
|
||||
int alagado[MAXN][MAXN];
|
||||
const int COSTS[5][5] = {
|
||||
{7, 6, 5, 6, 7},
|
||||
{6, 3, 2, 3, 6},
|
||||
{5, 2, 0, 2, 5},
|
||||
{6, 3, 2, 3, 6},
|
||||
{7, 6, 5, 6, 7},
|
||||
};
|
||||
int vis[MAXN][MAXN];
|
||||
int g[MAXN][MAXN];
|
||||
|
||||
bool valid(int c, int l) {
|
||||
return c > 0 && c <= C && l > 0 && l <= L && alagado[c][l] == 0;
|
||||
}
|
||||
|
||||
int h(int c, int l)
|
||||
{
|
||||
return sqrt(abs(Cs - c)*abs(Cs - c) + abs(Ls - l)*abs(Ls - l));
|
||||
}
|
||||
|
||||
bool reachable()
|
||||
{
|
||||
queue<pii> q;
|
||||
memset(vis, 0, sizeof(vis));
|
||||
|
||||
q.push({Cr, Lr});
|
||||
vis[Cr][Lr] = 1;
|
||||
|
||||
while (!q.empty())
|
||||
{
|
||||
auto [c, l] = q.front();
|
||||
q.pop();
|
||||
|
||||
if (c == Cs && l == Ls) return true;
|
||||
|
||||
for (int i = -2; i <= 2; i++){
|
||||
for (int j = -2; j <= 2; j++){
|
||||
int nc = c + i, nl = l + j;
|
||||
if (!valid(nc, nl) || vis[nc][nl]) continue;
|
||||
vis[nc][nl] = 1;
|
||||
q.push({nc, nl});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void solve()
|
||||
{
|
||||
if (!reachable())
|
||||
{
|
||||
cout << "impossible" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
memset(vis, 0, sizeof(vis));
|
||||
memset(g, INF, sizeof(g));
|
||||
priority_queue<pair<int, pii>> pq;
|
||||
g[Cr][Lr] = 0;
|
||||
pq.push({-h(Cr, Lr), {Cr, Lr}});
|
||||
while (!pq.empty()){
|
||||
auto [curCost, curCoords] = pq.top();
|
||||
pq.pop();
|
||||
|
||||
auto [c, l] = curCoords;
|
||||
|
||||
if (vis[c][l]) continue;
|
||||
vis[c][l] = 1;
|
||||
|
||||
if (c == Cs && l == Ls){
|
||||
cout << g[c][l] << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 2; i++){
|
||||
for (int j = -2; j <= 2; j++){
|
||||
int nc = c + i, nl = l + j;
|
||||
if (!valid(nc, nl)) continue;
|
||||
|
||||
int cost = COSTS[i + 2][j + 2];
|
||||
int newG = g[c][l] + cost;
|
||||
if (newG < g[nc][nl]){
|
||||
g[nc][nl] = newG;
|
||||
int f = g[nc][nl] + h(nc, nl);
|
||||
// insere custo negativo pois por padrao a priority queue é uma max heap
|
||||
pq.push({-f, {nc, nl}});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
while (cin >> C >> L, C && L){
|
||||
cin >> Cr >> Lr;
|
||||
cin >> Cs >> Ls;
|
||||
cin >> W;
|
||||
memset(alagado, 0, sizeof(alagado));
|
||||
memset(vis, 0, sizeof(vis));
|
||||
for (int i = 0; i < W; i++){
|
||||
int C1, C2, L1, L2;
|
||||
cin >> C1 >> L1 >> C2 >> L2;
|
||||
for (int k = C1; k <= C2; k++)
|
||||
for (int l = L1; l <= L2; l++)
|
||||
alagado[k][l] = 1;
|
||||
}
|
||||
solve();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
33
ra-preguicosa/src/checker.cpp
Normal file
33
ra-preguicosa/src/checker.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "testlib.h"
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
setName("compare files as sequence of lines");
|
||||
registerTestlibCmd(argc, argv);
|
||||
|
||||
std::string strAnswer;
|
||||
|
||||
int n = 0;
|
||||
while (!ans.eof()) {
|
||||
std::string j = ans.readString();
|
||||
|
||||
if (j.empty() && ans.eof())
|
||||
break;
|
||||
|
||||
strAnswer = j;
|
||||
std::string p = ouf.readString();
|
||||
|
||||
n++;
|
||||
|
||||
if (j != p)
|
||||
quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
|
||||
compress(j).c_str(), compress(p).c_str());
|
||||
}
|
||||
|
||||
if (n == 1)
|
||||
quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
|
||||
|
||||
quitf(_ok, "%d lines", n);
|
||||
}
|
||||
83
ra-preguicosa/src/generator.cpp
Normal file
83
ra-preguicosa/src/generator.cpp
Normal 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;
|
||||
}
|
||||
1
ra-preguicosa/src/script.sh
Normal file
1
ra-preguicosa/src/script.sh
Normal file
@@ -0,0 +1 @@
|
||||
generator
|
||||
5963
ra-preguicosa/src/testlib.h
Normal file
5963
ra-preguicosa/src/testlib.h
Normal file
File diff suppressed because it is too large
Load Diff
47
ra-preguicosa/src/validator.cpp
Normal file
47
ra-preguicosa/src/validator.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#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(0, 1000, "C");
|
||||
inf.readSpace();
|
||||
int R = inf.readInt(0, 1000, "R");
|
||||
inf.readEoln();
|
||||
if (C == 0 && R == 0) break;
|
||||
ensure(C != 0 || R != 0);
|
||||
|
||||
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();
|
||||
R1 = inf.readInt(1, R, "R1");
|
||||
inf.readSpace();
|
||||
C2 = inf.readInt(1, C, "C2");
|
||||
inf.readSpace();
|
||||
R2 = inf.readInt(1, R, "R2");
|
||||
inf.readEoln();
|
||||
ensure(C1 <= C2);
|
||||
ensure(R1 <= R2);
|
||||
}
|
||||
|
||||
}
|
||||
inf.readEof();
|
||||
return 0;
|
||||
}
|
||||
5
ra-preguicosa/statement/description.tex
Normal file
5
ra-preguicosa/statement/description.tex
Normal 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.
|
||||
6
ra-preguicosa/statement/input.tex
Normal file
6
ra-preguicosa/statement/input.tex
Normal 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$.
|
||||
0
ra-preguicosa/statement/notes.tex
Normal file
0
ra-preguicosa/statement/notes.tex
Normal file
2
ra-preguicosa/statement/output.tex
Normal file
2
ra-preguicosa/statement/output.tex
Normal 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'.
|
||||
0
ra-preguicosa/statement/preamble.tex
Normal file
0
ra-preguicosa/statement/preamble.tex
Normal file
0
ra-preguicosa/statement/tutorial.tex
Normal file
0
ra-preguicosa/statement/tutorial.tex
Normal file
Reference in New Issue
Block a user