Kattis - Mega Inversions
Authors: Benjamin Qi, Oscar Garries
For each , compute number of and independently.
With Indexed Sets
#include <bits/stdc++.h>#include <ext/pb_ds/assoc_container.hpp>using namespace std;using namespace __gnu_pbds;typedef long long ll;typedef vector<int> vi;typedef pair<int, int> pii;template <class T>
With BITs
#include <bits/stdc++.h>using namespace std;using ll = long long;const int MX = 2e5 + 5;ll bit2[MX], bit1[MX];int n;void upd(int i, int val, ll ar[]) {
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!