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 <bits/stdc++.h>
#include "shoes.h"
using namespace std;
long long x=0;
long long count_swaps(vector<int> s) {
//x=s.size();
//x/=2;
/*if(x==1){
return s[0]<0?0:1;
}else{
x=x*(x-1)/2;
return x;
*/
while(!s.empty()){
long long i=0;
if(s[i]<0 && s[i]==-s[i+1]){
vector<int> ant(s.begin()+3,s.end());
s=ant;
}
while(s[i]>0){
i++;
}
x+=i;
long long abso=-1*s[i];
vector<int> ant(s.begin(),s.begin()+i);
vector<int> pos(s.begin()+i+1,s.end());
ant.insert(ant.end(),pos.begin(),pos.end());
s=ant;
i=0;
while(s[i]!=abso){
i++;
}
x+=i;
vector<int> ante(s.begin(),s.begin()+i);
vector<int> post(s.begin()+i+1,s.end());
ante.insert(ante.end(),post.begin(),post.end());
s=ante;
}
return x;
}
# | 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... |