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) {
/*while(!s.empty()){
int i=0;
while(s[i]>0){
i++;
}
x+=i;
int abso=-s[i];
s.erase(s.begin()+i);
i=0;
while(s[i]!=abso){
i++;
}
x+=i;
s.erase(s.begin()+i);
}
return x;*/
int num;
if(s[0]<0){
num=-s[0];
}else{
num=s[0];
}
while(s[0]==-num && s[1]==num){
s.erase(s.begin(),s.begin()+2);
}
int tam=s.size();
while(s[tam-2]==-num && s[tam-1]==num){
cout << "a";
s.erase(s.end()-2,s.end());
tam=s.size();
}
while(!s.empty()){
int con=0;
while(s[con]!=-num){
con++;
}
x+=con;
s.erase(s.begin()+con);
con=0;
while(s[con]!=num){
con++;
}
x+=con;
s.erase(s.begin()+con);
}
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... |