# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299001 | REALITYNB | Arranging Shoes (IOI19_shoes) | C++14 | 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>
#include "shoes.h"
using namespace std;
#define int long long
int count_swaps(vector<int> a){
int n = a.size() ;
int ans = 0 ;
for(int i=0;i<n;i++){
if(a[i]==0) continue ;
// cout <<a[i] << " " ;
int ze = 0 ;
for(int j=i+1;j<n;j++){
if(a[j]==0) ze++ ;
if(a[j]==a[i]*-1){
ans+=(j-i-(a[i]<0)-ze) , a[j]=0 ;
cout << j << " " << a[i] << endl ;
break ;
}
//if(a[j]==a[i]*-1) break ;
}
}
// cout << ans ;
return ans ;
}