summaryrefslogtreecommitdiff
path: root/other/pbs.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
committermzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
commit5ab8a5088b729a9953b8dff1b2a985dc8fb2098b (patch)
treeed40d6936c0e9eee40ba62751cbf99ecddbaddc2 /other/pbs.cpp
parentadabbad9c51cf7cd3874bfde8eac1fbcf84fec10 (diff)
updated tcr
Diffstat (limited to 'other/pbs.cpp')
-rw-r--r--other/pbs.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/other/pbs.cpp b/other/pbs.cpp
new file mode 100644
index 0000000..45577e2
--- /dev/null
+++ b/other/pbs.cpp
@@ -0,0 +1,32 @@
+// Q = Anzahl der Anfragen
+// C = Anzahl der Schritte der Operation
+
+vector<vector<int>> focus;
+vector<int> low, high, ans;
+
+ans.assign(Q, C + 1);
+low.assign(Q, 0);
+high.assign(Q, C);
+focus.assign(C + 1, vector<int>());
+for (bool changed = true; changed;) {
+ changed = false;
+ for (int i = 0; i <= C; i++) focus[i].clear();
+ for (int i = 0; i < Q; i++) {
+ if (low[i] > high[i]) continue;
+ focus[(low[i] + high[i]) / 2].pb(i);
+ }
+
+ // Simulation zurücksetzen
+
+ for (int k = 0; k <= C; k++) {
+ // Simulationsschritt
+
+ for (int q : focus[k]) {
+ changed = true;
+ if (/* Eigenschaft schon erfüllt */) {
+ // Antwort updaten
+ high[q] = k - 1;
+ ans[q] = min(ans[q], k);
+ } else {
+ low[q] = k + 1;
+}}}}