# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340609 | israeladewuyi | Arranging Shoes (IOI19_shoes) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<string> vs;
#define PB push_back
#define pb pop_back
#define in insert
#define endl "\n"
const unsigned int M = 1000000007;
ll count_swaps(vi s){
ll n = s.size();
ll swaps = 0;
for(int i = 0; i < n-1; i++){
int y = abs(s[i]);
for(int j = i + 1; j< n; j++){
if(abs(s[j]) == y){
while(abs(s[i+1]) != y){
swap(s[j],s[j-1]);
swaps++;
j = j-1;
}
}
}
if(s[i] > 0)swaps++;
}
return swaps;
}
//int main(){
// vi v;
// v.PB(2);
// v.PB(-2);
// v.PB(2);
// v.PB(-2);
// cout<<count_swaps(v);
//}