# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
653893 | aryan12 | Arranging Shoes (IOI19_shoes) | C++17 | 1 ms | 300 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 "shoes.h"
#include <bits/stdc++.h>
using namespace std;
long long count_swaps(vector<int> A)
{
long long ans = 0;
map<int, queue<int> > mp;
for(int i = 0; i < A.size(); i++)
{
// cout << "holyfuck" << endl;
if(mp[-A[i]].size() == 0)
{
mp[A[i]].push(i);
continue;
}
int pos = mp[-A[i]].front();
mp[-A[i]].pop();
// cout << "i = " << i << ", pos = " << pos << endl;
for(int j = i; j > pos + 1; j--)
{
swap(A[j], A[j - 1]);
ans++;
}
if(A[pos] > A[pos + 1])
{
swap(A[pos], A[pos + 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... |