Řešení KSP úlohy 33-3-4 Obsazování území https://ksp.mff.cuni.cz/h/ulohy/33/zadani3.html#task-33-3-4
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
930 B

use db::LayoutDB;
use city::City;
use itertools::Itertools;
mod city;
mod db;
mod combine;
fn main() {
let mut db = LayoutDB::from_file("layouts.sqlite").expect("Failed to load the DB");
eprintln!("Loaded the DB, {} stored layouts", db.layouts().len());
let city = City::read_from_file("01.in");
eprintln!("Loaded the city file, {} houses", city.get_house_count());
let layouts = db.layouts();
let sorted: Vec<_> = layouts.iter().sorted_by(|x, y| city::get_price(&city, x.houses()).cmp(&city::get_price(&city, y.houses()))).collect();
let first = sorted[1];
let second = sorted[0];
eprintln!("Combining layouts (ID {}, price {}) and (ID {}, price {})",
first.id(),
city::get_price(&city, first.houses()),
second.id(),
city::get_price(&city, second.houses()),
);
combine::try_combine(&city, first.houses(), second.houses());
}