Correctin: BSB; but it's quite slow.
This commit is contained in:
4
Makefile
4
Makefile
@@ -26,7 +26,7 @@ BUILD_OUT_B_DIR = $(BUILD_DIR)/$(SOL_B)_out
|
||||
|
||||
DIRS = $(BUILD_DIR) $(BUILD_TARGET_DIR) $(BUILD_GEN_DIR) $(BUILD_VAL_DIR) $(BUILD_CHK_DIR) $(LOG_DIR) $(BUILD_IN_DIR) $(BUILD_OUT_A_DIR) $(BUILD_OUT_B_DIR) $(BUILD_TEST_DIR)
|
||||
|
||||
CXXFLAGS = -Wall -O2 -std=c++2a
|
||||
CXXFLAGS = -Wall -O3 -std=c++2a
|
||||
GENFLAGS = -N $(N) -M $(M) -pm $(pm)
|
||||
|
||||
SRC_MAIN_FILES = $(wildcard $(SRC_DIR)/*/main.cpp)
|
||||
@@ -66,7 +66,7 @@ $(BUILD_DIR) $(BUILD_TARGET_DIR) $(BUILD_GEN_DIR) $(BUILD_VAL_DIR) $(BUILD_CHK_D
|
||||
|
||||
$(BUILD_TARGET_DIR)/%: $(SRC_DIR)/%/main.cpp | $(BUILD_TARGET_DIR)
|
||||
@echo "Compiling Solution $< -> $@"
|
||||
$(CXX) $(CXXFLAGS) -fsanitize=undefined,address -o $@ $<
|
||||
$(CXX) $(CXXFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_GEN_DIR)/%: $(GEN_DIR)/%.cpp | $(BUILD_GEN_DIR)
|
||||
@echo "Compiling Generator $< -> $@"
|
||||
|
||||
@@ -20,6 +20,13 @@ namespace GMS {
|
||||
using namespace std;
|
||||
using ll = unsigned long long;
|
||||
|
||||
using DIST = tuple<double, ll, ll>;
|
||||
ostream& operator<<(ostream& os, DIST& dist)
|
||||
{
|
||||
os<<'(' << get<0>(dist) << ' ' << get<1>(dist) << ' ' << get<2>(dist) << ')';
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename KEY, typename VALUE>
|
||||
class L33 {
|
||||
private:
|
||||
@@ -56,20 +63,20 @@ class L33 {
|
||||
assert(!b || it_B->second == b.value());
|
||||
it_BLIST->erase(it_B);
|
||||
|
||||
if (it_BLIST->size() == 0) {
|
||||
if (it_BLIST->size() == 0 && UB[B] != it_ILIST) {
|
||||
blocks.erase(it_BLIST);
|
||||
|
||||
if (d01 == 0)
|
||||
D0.erase(it_ILIST);
|
||||
else {
|
||||
else if(d01 == 1){
|
||||
UB.erase(it_ILIST->first);
|
||||
D1.erase(it_ILIST);
|
||||
|
||||
if (D1.empty()) {
|
||||
auto it_BLIST = blocks.emplace(blocks.end());
|
||||
auto it_ILIST = D1.emplace(D1.end(), B, it_BLIST);
|
||||
UB[B] = it_ILIST;
|
||||
}
|
||||
// if (D1.empty()) {
|
||||
// auto it_BLIST = blocks.emplace(blocks.end());
|
||||
// auto it_ILIST = D1.emplace(D1.end(), B, it_BLIST);
|
||||
// UB[B] = it_ILIST;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ pair<DIST, unordered_set<ll> > BMSSP(ll l, vector<ll> S, DIST B,
|
||||
const ll k, const ll t) {
|
||||
assert(S.size() <= (1uLL << (l * t)));
|
||||
|
||||
// cerr<<"LEVLE "<<l<<endl;
|
||||
// cerr<<"LEVEL "<<l<<endl;
|
||||
// cerr<<"S: "; for(auto i:S) cerr<<i<<' '; cerr<<endl;
|
||||
|
||||
if (l == 0) {
|
||||
@@ -146,24 +146,33 @@ pair<DIST, unordered_set<ll> > BMSSP(ll l, vector<ll> S, DIST B,
|
||||
// for(auto i:W) cerr<<i<<' ';
|
||||
// cerr<<endl;
|
||||
|
||||
// cerr<<get<0>(B)<<' '<<get<1>(B)<<' '<<get<2>(B)<<endl;
|
||||
// cerr<<B<<endl;
|
||||
|
||||
L33<ll, DIST> D(M, B);
|
||||
for (auto i : P) D.Insert(i, dist[i]);
|
||||
|
||||
// D._debug(std::cerr);
|
||||
|
||||
const ll LIMIT = k * (1uLL << (l * t));
|
||||
|
||||
// cerr<<"LIMIT: "<<LIMIT<<endl;
|
||||
|
||||
unordered_set<ll> U;
|
||||
DIST B_;
|
||||
DIST B_ = B;
|
||||
while (U.size() < LIMIT && !D.empty()) {
|
||||
auto [Bi, Si] = D.Pull();
|
||||
// cerr<<get<0>(Bi)<<' '<<get<1>(Bi)<<' '<<get<2>(Bi)<<endl;
|
||||
// cerr<<"Si: "; for(auto i:Si) cerr<<i<<' '; cerr<<endl;
|
||||
|
||||
// cerr<<"I'm LEVEL "<<l<<endl;
|
||||
// cerr<<"S: "; for(auto i:S) cerr<<i<<' '; cerr<<endl;
|
||||
|
||||
// cerr<<"goto BMSSP("<<l-1<<", Si, "<<Bi<<", *, *, "<<k<<", "<<t<<");"<<endl;
|
||||
// cerr<<"Si: "; for(auto i:Si) cerr<<i<<' '; cerr<<endl;
|
||||
auto [Bi_, Ui] = BMSSP(l - 1, Si, Bi, adj, dist, k, t);
|
||||
B_ = Bi_;
|
||||
// cerr<<"received B_: "<<B_<<endl;
|
||||
// cerr<<"received Ui: "; for(auto i:Ui) cerr<<i<<' '; cerr<<endl;
|
||||
|
||||
// cerr<<get<0>(Bi_)<<' '<<get<1>(Bi_)<<' '<<get<2>(Bi_)<<endl;
|
||||
// cerr<<"Ui: "; for(auto i:Ui) cerr<<i<<' '; cerr<<endl;
|
||||
@@ -176,7 +185,12 @@ pair<DIST, unordered_set<ll> > BMSSP(ll l, vector<ll> S, DIST B,
|
||||
if (relex(u, dist[u], len, v, dist[v])) {
|
||||
// cerr<<"OK!"<<endl;
|
||||
if (Bi <= dist[v] && dist[v] < B)
|
||||
{
|
||||
// cerr<<"[!] INSERT: "<<v<<' '<<dist[v]<<endl;
|
||||
// D._debug(cerr);
|
||||
D.Insert(v, dist[v]);
|
||||
// D._debug(cerr);
|
||||
}
|
||||
else if (Bi_ <= dist[v] && dist[v] < Bi)
|
||||
K.insert(v);
|
||||
}
|
||||
@@ -192,8 +206,12 @@ pair<DIST, unordered_set<ll> > BMSSP(ll l, vector<ll> S, DIST B,
|
||||
|
||||
// for(auto [s, _]: K_) cerr<<s<<' ';
|
||||
// cerr<<endl;
|
||||
|
||||
|
||||
// cerr<<"[!A]"<<endl;
|
||||
// D._debug(std::cerr);
|
||||
D.BatchPrepend(K_);
|
||||
// cerr<<"[!B]"<<endl;
|
||||
// D._debug(std::cerr);
|
||||
}
|
||||
|
||||
B_ = min(B_, B);
|
||||
|
||||
Reference in New Issue
Block a user