This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "shoes.h"
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef int64_t lld;
typedef pair<int, int> pii;
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<typename T, typename comp = less<T>>
using OST = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> p){
return out << "(" << p.ff << ", " << p.ss << ")";
}
map<int, int> cnt;
struct comp{
bool operator()(const pii& a, const pii& b) const {
if(abs(a.ff) != abs(b.ff))return abs(a.ff) < abs(b.ff);
if(a.ss != b.ss)return a.ss < b.ss;
return a.ff < b.ff;
}
};
OST<pii, comp> ost;
long long count_swaps(vector<int> s) {
lld ans = 0;
for(auto i: s)ans += ost.size()-ost.order_of_key({i, cnt[i]}), ost.insert({i, cnt[i]++});
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |