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"
#define pii pair <int, int>
using namespace std;
long long count_swaps(vector<int> s){
int n = (int)s.size();
for(int i = 0; i < n; i++){
if(s[i] < 0){
s[i] = -1;
}else{
s[i] = +1;
}
}
long long ans = 0;
vector <pii> St;
for(int i = 0; i < n; i++){
if(!St.empty() && St.back().first == -s[i]){
ans += (i - St.back().second - (St.back().first < s[i]));
St.pop_back();
}else{
St.push_back({s[i], 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... |