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;
typedef long long int ll;
long long count_swaps(std::vector<int> s) {
int n = s.size();
vector <bool> used(n + 1);
ll ans = 0;
// O(n^2)
for (int i = 0; i < n; i++){
if (!used[i]){
int cur = 0;
for (int j = i + 1; j < n; j++){
if(!used[j]){
cur++;
}
if (!used[j] and s[i] == -s[j]){
used[j] = true;
break;
}
}
ans += cur;
if (s[i] < 0){
ans--;
}
used[i] = true;
}
}
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... |