# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677034 | hello_there_123 | 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 "shoes.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
long long count_swaps(vector<int> s) {
int ans = 0;
int n = s.size();
bool arr[n+3];
memset(arr,0,sizeof(arr));
for(int i=0;i<n;i++){
if(arr[i]) continue;
int cnt = 0;
for(int j=i+1;j<n;j++){
if(s[j] == -s[i] && arr[j] == 0){
arr[j] = 1;
ans+=cnt;
break;
}
else if(arr[j] == 0) cnt++;
}
if(s[i]>0) ans++;
}
return ans;
}