feat: new Divide and Conquer problem partialy formated.
This commit is contained in:
@@ -4,6 +4,12 @@ Repositório com a formatação de problemas que exploram variadas técnicas de
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Divide and Conquer
|
||||||
|
|
||||||
|
- [Dominância de Pontos](./dominancia-de-pontos/)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Greedy
|
## Greedy
|
||||||
|
|
||||||
- [Caching Offline](./caching-offline)
|
- [Caching Offline](./caching-offline)
|
||||||
|
|||||||
97
dominancia-de-pontos/Makefile
Normal file
97
dominancia-de-pontos/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
|
||||||
BIN
dominancia-de-pontos/dominancia-de-pontos.pdf
Normal file
BIN
dominancia-de-pontos/dominancia-de-pontos.pdf
Normal file
Binary file not shown.
39
dominancia-de-pontos/dominancia-de-pontos.tex
Normal file
39
dominancia-de-pontos/dominancia-de-pontos.tex
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
\documentclass{maratona}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\begin{ProblemaAutor}{}{Dominância de Pontos}{1}{256}{}
|
||||||
|
|
||||||
|
Considere um conjunto de \( n \) pontos \( P = \{(x_0, y_0), (x_1, y_1), \ldots, (x_{n-1}, y_{n-1}) \} \) no plano cartesiano \( \mathbb{R}^2 \).
|
||||||
|
|
||||||
|
Dizemos que um ponto \( A = (x_a, y_a) \) \textbf{domina} outro ponto \( B = (x_b, y_b) \) se, e somente se, as seguintes condições forem satisfeitas simultaneamente:
|
||||||
|
\begin{itemize}
|
||||||
|
\item \( x_a < x_b \)
|
||||||
|
\item \( y_a < y_b \)
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
O objetivo é contar o número total de relações de dominância existentes no conjunto \( P \). Uma relação de dominância é definida por um par ordenado de pontos \( (P_i, P_j) \) tal que \( P_i \) domina \( P_j \).
|
||||||
|
|
||||||
|
\Entrada
|
||||||
|
|
||||||
|
A entrada consiste em um único caso de teste.
|
||||||
|
|
||||||
|
A primeira linha contém um inteiro \( n \) (\( 1 \le n \le 10^5 \)), representando o número de pontos no conjunto.
|
||||||
|
|
||||||
|
As próximas \( n \) linhas contêm, cada uma, dois inteiros \( x_i \) e \( y_i \) (\( -10^9 \le x_i, y_i \le 10^9 \)), representando as coordenadas de cada ponto.
|
||||||
|
|
||||||
|
\Saida
|
||||||
|
|
||||||
|
A saída deve conter uma única linha com um número inteiro representando o total de relações de dominância encontradas no conjunto de pontos dado.
|
||||||
|
|
||||||
|
\ExemploEntrada
|
||||||
|
\begin{Exemplo}
|
||||||
|
\texttt{3} & \texttt{0}\\
|
||||||
|
\texttt{1~1} & \\
|
||||||
|
\texttt{2~2} & \\
|
||||||
|
\texttt{3~3} & \\
|
||||||
|
\end{Exemplo}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\end{ProblemaAutor}
|
||||||
|
\end{document}
|
||||||
188
dominancia-de-pontos/maratona.cls
Normal file
188
dominancia-de-pontos/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
|
||||||
|
|
||||||
64
dominancia-de-pontos/problem.json
Normal file
64
dominancia-de-pontos/problem.json
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"problem": {
|
||||||
|
"title": "Dominância de Pontos",
|
||||||
|
"event": "",
|
||||||
|
"time_limit": 1.0,
|
||||||
|
"memory_limit_mb": 256,
|
||||||
|
"input_file": "stdin",
|
||||||
|
"output_file": "stdout",
|
||||||
|
"interactive": false,
|
||||||
|
"grader": false,
|
||||||
|
"subject": {
|
||||||
|
"en_us": [
|
||||||
|
"divide-and-conquer"
|
||||||
|
],
|
||||||
|
"pt_br": [
|
||||||
|
"divisão-e-conquista"
|
||||||
|
],
|
||||||
|
"es": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "",
|
||||||
|
"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": 1
|
||||||
|
},
|
||||||
|
"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": 512,
|
||||||
|
"maximum_output_size_kb": 24096
|
||||||
|
}
|
||||||
|
}
|
||||||
10
dominancia-de-pontos/src/ac.cpp
Normal file
10
dominancia-de-pontos/src/ac.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
// TODO
|
||||||
|
cout << 0 << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
dominancia-de-pontos/src/checker.cpp
Normal file
18
dominancia-de-pontos/src/checker.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "testlib.h"
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
setName("compare two numbers");
|
||||||
|
registerTestlibCmd(argc, argv);
|
||||||
|
long long ja = ans.readLong();
|
||||||
|
long long pa = ouf.readLong();
|
||||||
|
|
||||||
|
if (ja != pa)
|
||||||
|
quitf(_wa, "expected %lld, found %lld", ja, pa);
|
||||||
|
|
||||||
|
quitf(_ok, "answer is %lld", ja);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
93
dominancia-de-pontos/src/generator.cpp
Normal file
93
dominancia-de-pontos/src/generator.cpp
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#include "testlib.h"
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MIN_N = 1;
|
||||||
|
const int MAX_N = 1e5;
|
||||||
|
const int MIN_COORD = -1e9;
|
||||||
|
const int MAX_COORD = 1e9;
|
||||||
|
|
||||||
|
const int rnd_test_n = 30;
|
||||||
|
|
||||||
|
template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
|
||||||
|
dest.insert(dest.end(), orig.begin(), orig.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
string output_tc(const vector<pair<int, int>> &coords) {
|
||||||
|
ostringstream oss;
|
||||||
|
oss << coords.size() << endl;
|
||||||
|
for (const auto [x, y] : coords) {
|
||||||
|
oss << x << " " << y << endl;
|
||||||
|
}
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string> generate_sample_tests() {
|
||||||
|
vector<string> tests;
|
||||||
|
tests.push_back(output_tc({{1, 1}, {2, 2}, {3, 3}}));
|
||||||
|
return tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string> generate_manual_tests() {
|
||||||
|
vector<string> tests;
|
||||||
|
tests.push_back(output_tc({{1, 1}}));
|
||||||
|
return tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<pair<int,int>> generate_random_coords_array(int size) {
|
||||||
|
vector<pair<int, int>> coords(size);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
coords[i].first = rnd.next(MIN_COORD, MAX_COORD);
|
||||||
|
coords[i].second = rnd.next(MIN_COORD, MAX_COORD);
|
||||||
|
}
|
||||||
|
return coords;
|
||||||
|
}
|
||||||
|
|
||||||
|
string rnd_test(int i){
|
||||||
|
int min_n = MIN_N;
|
||||||
|
int max_n = MAX_N;
|
||||||
|
|
||||||
|
if(i<rnd_test_n / 3){
|
||||||
|
max_n = 50;
|
||||||
|
}
|
||||||
|
else if(i<rnd_test_n / 2){
|
||||||
|
max_n = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = rnd.next(min_n, max_n);
|
||||||
|
return(output_tc(generate_random_coords_array(n)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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(generate_random_coords_array(MAX_N)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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
dominancia-de-pontos/src/script.sh
Normal file
1
dominancia-de-pontos/src/script.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
generator
|
||||||
5963
dominancia-de-pontos/src/testlib.h
Normal file
5963
dominancia-de-pontos/src/testlib.h
Normal file
File diff suppressed because it is too large
Load Diff
23
dominancia-de-pontos/src/validator.cpp
Normal file
23
dominancia-de-pontos/src/validator.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "testlib.h"
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
const int MIN_N = 1;
|
||||||
|
const int MAX_N = 1e5;
|
||||||
|
const int MIN_COORD = -1e9;
|
||||||
|
const int MAX_COORD = 1e9;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
registerValidation(argc, argv);
|
||||||
|
int n = inf.readInt(MIN_N, MAX_N, "n");
|
||||||
|
inf.readEoln();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
inf.readInt(MIN_COORD, MAX_COORD, "xi");
|
||||||
|
inf.readSpace();
|
||||||
|
inf.readInt(MIN_COORD, MAX_COORD, "yi");
|
||||||
|
inf.readEoln();
|
||||||
|
}
|
||||||
|
inf.readEof();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
9
dominancia-de-pontos/statement/description.tex
Normal file
9
dominancia-de-pontos/statement/description.tex
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Considere um conjunto de \( n \) pontos \( P = \{(x_0, y_0), (x_1, y_1), \ldots, (x_{n-1}, y_{n-1}) \} \) no plano cartesiano \( \mathbb{R}^2 \).
|
||||||
|
|
||||||
|
Dizemos que um ponto \( A = (x_a, y_a) \) \textbf{domina} outro ponto \( B = (x_b, y_b) \) se, e somente se, as seguintes condições forem satisfeitas simultaneamente:
|
||||||
|
\begin{itemize}
|
||||||
|
\item \( x_a < x_b \)
|
||||||
|
\item \( y_a < y_b \)
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
O objetivo é contar o número total de relações de dominância existentes no conjunto \( P \). Uma relação de dominância é definida por um par ordenado de pontos \( (P_i, P_j) \) tal que \( P_i \) domina \( P_j \).
|
||||||
5
dominancia-de-pontos/statement/input.tex
Normal file
5
dominancia-de-pontos/statement/input.tex
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
A entrada consiste em um único caso de teste.
|
||||||
|
|
||||||
|
A primeira linha contém um inteiro \( n \) (\( 1 \le n \le 10^5 \)), representando o número de pontos no conjunto.
|
||||||
|
|
||||||
|
As próximas \( n \) linhas contêm, cada uma, dois inteiros \( x_i \) e \( y_i \) (\( -10^9 \le x_i, y_i \le 10^9 \)), representando as coordenadas de cada ponto.
|
||||||
0
dominancia-de-pontos/statement/notes.tex
Normal file
0
dominancia-de-pontos/statement/notes.tex
Normal file
1
dominancia-de-pontos/statement/output.tex
Normal file
1
dominancia-de-pontos/statement/output.tex
Normal file
@@ -0,0 +1 @@
|
|||||||
|
A saída deve conter uma única linha com um número inteiro representando o total de relações de dominância encontradas no conjunto de pontos dado.
|
||||||
0
dominancia-de-pontos/statement/preamble.tex
Normal file
0
dominancia-de-pontos/statement/preamble.tex
Normal file
0
dominancia-de-pontos/statement/tutorial.tex
Normal file
0
dominancia-de-pontos/statement/tutorial.tex
Normal file
Reference in New Issue
Block a user