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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int used[100005];
long long count_swaps(vector<int> s)
{
int ans = 0;
int n = s.size();
for(int i = 0; i < n; i++)
{
if(used[i]) continue;
int idx = -1;
for(int r = i+1; r < n; r++)
{
if(s[r]==(-1*s[i]))
{
idx = r;
break;
}
}
int cnt = 0;
while(idx-1!=i)
{
swap(s[idx], s[idx-1]);
idx--;
cnt++;
}
if(s[idx]<s[idx-1])
{
swap(s[idx], s[idx-1]);
cnt++;
}
//cout << i << ' ' << idx << '\n';
//for(int j = 0; j < s.size(); j++) cout << s[j] << ' ';
//cout << '\n';
ans+=cnt;
used[i] = 1;
used[idx] = 1;
}
return ans;
}
# | 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... |