# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316722 | Tahmid690 | Arranging Shoes (IOI19_shoes) | C++14 | 1 ms | 256 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;
long long count_swaps(vector<int> ara){
int flag=0;
for(int i=1;i<ara.size();i++) if(abs(ara[i])!=abs(ara[i-1])) flag=1;
if(flag==0){
long long ans=0;
long long m,x=0;
m=ara.size()/2;
for(int i=0;i<ara.size();i++){
if(ara[i]<0){
swap(ara[i],ara[x*2]);
ans+=(abs(i-2*x));
x++;
}
}
return ans;
}
long long n;
n=ara.size();
n/=2;
if(n==1){
if(ara[0]<0) return 0;
else return 1;
}
return (n*(n-1))/2;
}
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... |