# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299656 | suren | Arranging Shoes (IOI19_shoes) | C++14 | 1 ms | 288 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 mk make_pair
#define pb push_back
#define F first
#define S second
int count_swaps( vector < int > vc ){
int ans = 0, i;
map < int , int > mp;
for( i = 0; i < vc.size(); i ++ )
mp[ vc[i] ] = 1;
if( mp.size() == 2 ){
vector < int > zn, brn;
for( i = vc.size()-1; i >= 0; i -- ){
if( vc[i] < 0 )
zn.pb( i );
else
brn.pb( i );
}
while( zn.size() > 0 && brn.size() > 0 ){
if( zn[zn.size()-1] < brn[brn.size()-1] ){
ans += brn[brn.size()-1] - zn[zn.size()-1] - 1;
}
else{
ans += zn[zn.size()-1] - brn[brn.size()-1];
}
zn.pop_back();
brn.pop_back();
}
return ans;
}
while( vc.size() > 0 ){
for( i = 1; i < vc.size(); i ++ ){
if( vc[i] == vc[0] * -1 ){
if( vc[i] < 0 ){
ans += i;
vc.erase( vc.begin() + i );
vc.erase( vc.begin() + 0 );
break;
}
else{
ans += i-1;
vc.erase( vc.begin() + i );
vc.erase( vc.begin() + 0 );
break;
}
}
}
}
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... |