#include "shoes.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fst first
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i<b; i++)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset(a,v,sizeof(a))
#define FIN ios::sync_with_stdio(0); cout.tie(); cin.tie(0);
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> iset;
long long count_swaps(std::vector<int> s) {
ll n = SZ(s);
ll res = 0;
forn(i,0,n){
ll pos = -1;
forn(j,i+1,n){
if(abs(s[j])==abs(s[i])){
pos=j;
break;
}
}
ll aux = -1;
for(int j = pos-1; (s[i]<0?(j>i):(j>=i)); j--){
res++;
aux=s[j];
s[j]=s[j+1];
s[j+1]=aux;
}
i++;
/*cout<<"-------------\n";
cout<<res<<'\n';
forn(j,0,n) cout<<s[j]<<" "; cout<<'\n';*/
}
return res;
}
# | 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... |