# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1138842 | vusal | Arranging Shoes (IOI19_shoes) | C++20 | 0 ms | 0 KiB |
#include <vector>
#include <cmath>
#include <algorithm>
class FenwickTree {
private:
std::vector<int> tree;
int size;
public:
FenwickTree(int n) : tree(n + 1, 0), size(n) {}
void update(int index, int value) {
while (index <= size) {
tree[index] += value;
index += index & (-index);
}
}
int query(int index) {
int sum = 0;
while (index > 0) {
sum += tree[index];
index -= index & (-index);
}
return sum;
}
};
long long count_swaps(std::vector<int>& S) {