# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087671 | MahmytM | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 352 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;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
void afterdot(int n){
cout<<setprecision(n)<<fixed;
}
ll count_swaps(vector<int> s){
if(s.size()==2){
if(s[0]<=0){
return 0;
}
return 1;
}
int ans=0;
for(int i=0;i<s.size();i++){
if(s[i]>0){
int z=-1*s[i],num=1e9,in;
for(int j=0;j<s.size();j++){
if(s[j]==z){
if(num>abs(i-j)){
num=abs(i-j);
in=j;
}
}
}
if(in>i){
for(int j=i;j<in;j++){
swap(s[j],s[j+1]);
ans++;
}
}else{
for(int j=in;j<i-1;j++){
swap(s[j],s[j+1]);
ans++;
}
}
}
}
return ans;
}
Compilation message (stderr)
# | 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... |