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;
int n;
long long count_swaps(std::vector<int> s) {
n = s.size();
if (n == 2){
if (s[0] < 0){
return 0;
}
return 1;
}
ll ans = 0;
vector <bool> used (n + 1, false);
for (int i = 0; i < n; i++){
if (!used[i]){
ll cnt = 0;
for (int j = i + 1; j < n; j++){
if(!used[j]){
cnt++;
}
if (!used[j] and s[i] == -s[j]){
used[j] = true;
break;
}
}
cnt--;
// cout << "cnt : " << cnt << "\n";
ans += cnt;
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... |