Submission #1156468

#TimeUsernameProblemLanguageResultExecution timeMemory
1156468blackslexBubble Sort 2 (JOI18_bubblesort2)C++20
38 / 100
9092 ms1472 KiB
#include "bubblesort2.h" #include<bits/stdc++.h> #define lsb(x) (x &(-x)) using namespace std; std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){ int Q=X.size(); std::vector<int> answer(Q); vector<int> c; for (auto &e: A) c.emplace_back(e); for (auto &e: V) c.emplace_back(e); sort(c.begin(), c.end()); c.resize(unique(c.begin(), c.end()) - c.begin()); int csz = c.size(); vector<int> fwk(csz + 5); auto upd = [&] (int idx, int val) { for (; idx < fwk.size(); idx += lsb(idx)) fwk[idx] += val; }; auto qr = [&] (int idx) { int res = 0; for (; idx > 0; idx -= lsb(idx)) res += fwk[idx]; return res; }; for (auto &e: A) e = lower_bound(c.begin(), c.end(), e) - c.begin() + 1; for (auto &e: V) e = lower_bound(c.begin(), c.end(), e) - c.begin() + 1; for (int i = 0; i < Q; i++) { A[X[i]] = V[i]; for (auto &e: A) { answer[i] = max(answer[i], qr(csz + 1) - qr(e)); upd(e, 1); } for (auto &e: A) upd(e, -1); } // for (int j=0;j<Q;j++) { // answer[j]=X[j]; // } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...